Tag Info

Hot answers tagged

93

Immutability simplifies the amount of information you need to track mentally when reading code later. For mutable variables, and especially mutable class members, it's very hard to know what state they will be in at the specific line you're reading about, without running through the code with a debugger. Immutable data is easy to reason about - it will ...


92

I think it rather falls along the lines of "All SDKs are/contain APIs but not all APIs are SDKs". An SDK seems to be a complete set of APIs that allow you to perform most any action you would need to for creating applications. In addition an SDK may include other tools for developing for the platform/item that it is for. An API on the other hand if just a ...


89

Free Functionality Properly using <label>s means you can click the label to enter the text field. Many browsers will add logical default functionality to many tags per the official specification, meaning you can use less JavaScript plugins and write less code than a site made entirely out of <div>s and <span>s. Accessibility Related to ...


79

Encapsulation is there to protect your program against change. Is the representation of a Name going to change? If not, then you're wasting your time and YAGNI applies. Edit: I've read the blog post and he has a fundamentally good idea. The problem is that he's scaled it way too far. Something like String orderId is really bad, because presumably ...


71

Semantics ~ Meaning Syntax ~ Symbolic representation So two programs written in different languages could do the same thing (semantics) but the symbols used to write the program would be different (syntax). A compiler will check your syntax for you (compile-time errors), and derive the semantics from the language rules (mapping the syntax to machine ...


46

That's just crazy:) Use common sense Don't over-engineer! Keep it small simple! You Arent Gonna Need It (YagNi)


41

API = Application Programming Interface SDK = Software Development Kit So the real difference is, that an API is no more or less than an interface to "some service", while an SDK is a set of tools/components/classes for a specific purpose. An SDK in fact presents you with an API to interface with. But you might use an API without having the underlying ...


23

I think the term "production" has come from other industries like automotive or electronics, where once a component/product is ready to be used, it becomes part of producing/usage in something bigger like in a "production line" or "construction pipeline". In software the term "production environment" might hold parallel in the sense that people use this ...


22

I agree with the author, mostly. If there is any behavior peculiar to a field, like validation of an order id, then I would create a class to represent that type. His second point is even more important: if you have a set of fields that represent some concept like an address, then create a class for that concept. If you are programming in Java, you are ...


21

When talking about overloads, the name of the function is overloaded, not the function itself. The functions overloading the name are "overloads" and overload the name, but not each other. In your example, "public void foo()" and "public void foo( string bar )" both overload the name "foo". Therefore, you cannot speak in terms of overloader and overloadee of ...


21

Your code should express your intention. If you don't want an object to be modified once created, make it impossible to modify. Immutability has several benefits: The intention of the original author is expressed better. How would you be able to know that in the following code, modifying the name would cause the application to generate an exception ...


16

Actually there are not two levels but three: lexical level: how characters are combined to produce language elements ( i and f produces if) syntactical level: how language elements are combined to produce language expressions ( if, (, 42, ==, answer and ) produces a conditional statement) semantic level: how language expressions are converted to CPU ...


15

Don't do it; it will overcomplicate stuff and You Ain't Gonna Need It ... is the answer I would have written here 2 years ago. Now, though, I'm not so sure; in fact, in recent months I've started migrating old code to this format, not because I have nothing better to do but because I genuinely needed it for implementing new features or changing existing ...


14

OK, this is a fun question. I would also like to have a general else for while and for loops, for when the condition isn't true on the first test: while (condition) { // process } else { // condition was never true } This avoids the awkward re-computation of the condition or storing it in a variable.


14

The term dates back to the time when the field was known as "Data Processing." Back then, users did not perform their own data entry. Instead, they filled out coding sheets that were punched onto decks of punch-cards by data entry personnel. These card decks were physically queued up for processing by a person known as the "production scheduler." All ...


12

Smalltalk. Everything's done with message sending, so 1 + 2 * 3 means "send * with parameter 3 to the object returned by sending the message + with parameter 2 to the object 1". That throws people (it threw me) because of how we usually write maths, but since I can never remember C's operator precedence I cope in the same manner in both languages - I use ...


12

Semantics describe the logical entities of a programming language and their interactions. Syntax defines how these are expressed in characters. For example, the concept of pointer arithmetic is part of C's semantics; the way the + and - operators can be used to express pointer operations are part of its syntax. Sometimes, two languages share part of their ...


12

Depending on the language, it may not be necessary to use a call stack. Call stacks are only necessary in languages that allow recursion or mutual recursion. If the language does not allow recursion, then only one invocation of any procedure may be active at any moment, and local variables for that procedure may be statically allocated. Such languages do ...


12

There are many single-threaded reasons to use immutability. For example Object A contains Object B. External code queries your Object B and you return it. Now you have three possible situations: B is immutable, no problem. B is mutable, you make a defensive copy and return that. Performance hit but no risk. B is mutable, you return it. In the third ...


11

If you were writing Perl, you'd essentially be duplicating Data::Dumper's functionality. It takes a Perl object and turns it into a string representation that can then be used to recreate that object (essentially -- this isn't really true for blessed objects). The description of this module says it creates "stringified perl data structures". Thus the ...


11

I would simply say foo is overloaded. There is certainly no master/slave or parent/child relationship going on here.


11

What does the semantic markup offer? A way for the machines to understand the data. What's a search engine? A machine. Back in the days, the search engines just looked for the words in a page and showed the page when you search the keywords. However, this led to farm websites with thousands of keywords just to rank higher than anything else, but this wasn't ...


10

Why not mash a few answers into one? while (expr) { // Executed every iteration, unless first{} is present. // May be explicitly called rest{} if you like first{} to come first. // Blocks may return results, and consequently be used in expressions. return expr; } first { // Executed only on the first iteration. } pre { // ...


10

A Helper class is a lesser known code smell where a coder has identified some miscellaneous, commonly used operations and attempted to make them reusable by lumping them together in an unnatural grouping. Successive developers have then come onto the project and not realised that the helper class exists, and have consequently rewritten the same common ...


9

See this article in wikipedia with a good explanation. The difference is that parameters appear in method/function definitions, while arguments are concrete values you pass to a method/function.


9

"SDK" is collective in a larger sense than "API". You typically find only one SDK to cover an entire platform. There's one MacOS X SDK and one iOS SDK, for example, and those each contain the API's for many different areas of functionality. "API" was originally used as a collective term as well, and it's still often used that way (MAPI, WSAPI, etc.), but ...


9

API → documented interface SDK → interface documentation ( + examples & tools )


8

S. Lott really hit the nail on the head but unfortunately only posted a comment. The nuance that people seem to be missing here is that the word production does not refer to the state of the software itself but how the software is being used. You might have the exact same build of the software, byte-for-byte, running in production and testing environments. ...


8

The answer to that is simply to convey information and to structure your document. When you use spans and divs, you document does not have a structure. There is no lists, no paragraphs, no tables, no hyperlinks. Nothing. There is really no point to choose HTML as a markup language and then ignore the vocabulary it offers to express and structure your ...



Only top voted, non community-wiki answers of a minimum length are eligible