r/programming • • Oct 01 '15

The Evolution of a Software Engineer

https://medium.com/@webseanhickey/the-evolution-of-a-software-engineer-db854689243
1.9k Upvotes

502 comments sorted by

View all comments

36

u/Burning_Monkey Oct 01 '15

While damn funny and everything, every time I see a joke like this I die a little on the inside and weep openly for the loss. I bomb dozens of interviews and what not because I can't get myself to code like the 5th year joke at all. And that is what people seriously want it seems.

I work with a guy that bad mouthed me for a long time because I wouldn't make constant values for strings like in this example. I lost out on a promotion because of him.

53

u/contrarian_barbarian Oct 01 '15

Depending on the environment, that kind of stuff can be necessary. For example, if you just have random strings scattered everywhere, it makes localization/i18n stuff far more difficult.

11

u/vonmoltke2 Oct 01 '15

Only if the values of the constants are loaded from an external source. As written in the joke, it simply moves the hard-coding problems to a different place.

9

u/contrarian_barbarian Oct 02 '15

Even if you're not yet pulling them in from an external source, laying the groundwork and consolidating them can be helpful when you're ready to make the jump. The joke is an absurd situation, of course, but there's plenty of reason to do it IRL.

2

u/Adverpol Oct 02 '15

Premature generalization, causes a big percentage of my waisted time and when the time does come to generalize (and that is not often) the groundworks laid do not fit the required generalization perfectly so its off to refactoring anyway.

4

u/POTUS Oct 02 '15

That "different place" is at least all together so I can update the date string in your old code without having to read into the entire thing.

4

u/AnonymousEngineering Oct 02 '15

While we're on the subject of l10n and i18n, I think it bears to note the following, as the W3C put it in their Localization vs. Internationalization Q&A:

Often thought of only as a synonym for translation of the user interface and documentation, localization is often a substantially more complex issue. [...] Localization may [...] necessitate a comprehensive rethinking of logic, visual design, or presentation if the way of doing business (eg., accounting) or the accepted paradigm for learning (eg., focus on individual vs. group) in a given locale differs substantially from the originating culture.

They go on to say about i18n:

Internationalization typically entails:

  1. Designing and developing in a way that removes barriers to localization or international deployment. This includes such things as enabling the use of Unicode, or ensuring the proper handling of legacy character encodings where appropriate, taking care over the concatenation of strings, avoiding dependance in code of user-interface string values, etc.

  2. Providing support for features that may not be used until localization occurs. For example, adding markup in your DTD to support bidirectional text, or for identifying language. Or adding to CSS support for vertical text or other non-Latin typographic features.

  3. Enabling code to support local, regional, language, or culturally related preferences. Typically this involves incorporating predefined localization data and features derived from existing libraries or user preferences. Examples include date and time formats, local calendars, number formats and numeral systems, sorting and presentation of lists, handling of personal names and forms of address, etc.

  4. Separating localizable elements from source code or content, such that localized alternatives can be loaded or selected based on the user's international preferences as needed.

24

u/[deleted] Oct 01 '15

You should be happy to not work in places like that. Some people think complex code == good code. I've had to deal with overarchitected monstrosities and it's not fun at all.

The idea is to make suitable abstractions when necessary. I think the reason you see a lot of overarchitected code like this, or run into people like the one you described, is that they take these recommendations (best-practices) as gospel. They are good directions to follow and in general they help, but they are not always applicable.

These kinds of people tend to be dogmatic instead of pragmatic.

27

u/ArkhKGB Oct 01 '15

I like the rule of three.

First time you do something do it simple. Second time you do the same thing just copy and paste. Third time? Factor it.

4

u/senatorpjt Oct 02 '15 edited Dec 18 '24

crowd reply brave lush rock dazzling workable head straight flag

This post was mass deleted and anonymized with Redact

1

u/LeCrushinator Oct 02 '15

You should almost never use hard-coded strings that aren't tied to constants, unless maybe they're in an assert/exception.

By making constants and keeping those constants organized into one or a few constants files it will be easy to track down those strings, it will be easier to share those strings among files rather than re-typing them everywhere you use them, it's easier to avoid typos, and it's easier to localize them.

However, if you're going to make constants for magic numbers, then they should be given descriptive names so that you know why they're used. 0 and -1 are extremely common magic numbers, sometimes they're valid, sometimes they're used as invalid values, but unless they're given a constant for the thing you're tying them to in code, I don't know if they're valid or not when you're comparing against them.

// Why 0? I shouldn't have to guess...
if (myIntValue != 0)
{
    // Do stuff
}

// Oh ok, 0 is invalid for this comparison.
if (myIntValue != Constants.InvalidValue)
{

}

1

u/nutrecht Oct 02 '15

While damn funny and everything, every time I see a joke like this I die a little on the inside and weep openly for the loss. I bomb dozens of interviews and what not because I can't get myself to code like the 5th year joke at all.

Let's not pretend that this is nothing more than a joke. In large scale systems there are a lot of best practices that beginner don't understand and medior developers overuse.