Reputation
4,394
Top tag
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
1 10 27
Newest
 Nice Answer
Impact
~288k people reached

May
21
comment Is static universally “evil” for unit testing and if so why does resharper recommend it?
As a fan of using static methods I previously lost this argument to a TDD-oriented developer. Let's say you have a static helper method that does a simple task (in a completely stateless mannner). That method is used in 15 different places throughout other methods, it also has a bug causing every other method that uses it to fail their tests. The primary goal of TDD is to isolate code for testing without side-effects. A static method that gets called inside another method will always be a side effect.
May
17
comment is this javascript property defaulting pattern a code smell?
Here, FTFY thisBool = (typeof(thisbool) === 'undefined') ? true : thisBool;
May
17
comment Re-architecting a classic inheritance design
@pdr Isn't that what namespaces are for? Defining everything in the global namespace is no different than creating mega-monolithic classes. While interfaces can make code organization messy if misused, it's a lot harder to code yourself into a corner the same way a lot of people manage to do with class inheritance.
May
17
comment Are regular expressions a programming language?
@Tacroy Nice to see somebody chimed in to parrot advice about parsing HTML with regex. While not for the faint-of-heart, combining regexes like the one above with a stack is a basic (and efficient) recipe for building a context-free parser.
May
17
comment Are regular expressions a programming language?
Not all programming languages are turing complete. For example, purely context-free declarative languages like XML that aren't turing complete without being paired with an interpreter could be considered programming languages. It all depends on your definition of 'programming language'. All you need to transform a 'regular' language to a 'context-free' language is a push-down stack. Then it's turtles all the way down.
May
17
comment Re-architecting a classic inheritance design
Nice, I came to mention Step 4 but your answer says it all and more. Interfaces are the key to escaping inheritance hell.
Mar
15
comment What's the difference between syntax and semantics?
@SK-logic I guess I read your comment to mean the opposite of what you intended. I thought you were talking about cases where only a lexer is needed - like in purely 'regular' or 'context-free' languages. In higher level languages a lexer may not be necessary but it provides a quick way to run a single pass syntax validation. I completely agree that there are many cases where it would be beneficial to turn off or completely eliminate the lexer stage.
Mar
15
comment What's the difference between syntax and semantics?
@SK-logic Only in purely context-free languages is the parser unnecessary. As soon as another level of context is added the parser becomes necessary. For example access levels (private/public/protected), inheritance, preprocessing, etc all require additional context to determine the semantics - therefore the code that implements them is broken/useless after performing just the lexer stage. Some code may be available in a pre-parsed state (ie dlls, bytecode) but it had to go through the lexer/parser/compiler stage at some point.
Mar
15
comment What's the difference between syntax and semantics?
@Ptharien'sFlame I'm just going to pull this discussion back out of the clouds for a second by highlighting the 'in theory' part of your statement. In practice, enforcing semantics in code requires additional syntax to give the compilers cues as to the functionality. Additional semantic checking comes as a cost (ie complexity/readability). Stating that a language can be powerful enough to check all semantic errors is like saying a legal system can be perfect enough to prevent all crime. Personally, I prefer freedom over safety but that's what makes this a 'religious' topic.
Mar
3
comment Why shouldn't a GET request change data on the server?
Tracking counts/analytics via GET requests is a hacky approach to begin with. Much better to fire off a separate HEAD request to a handler/server designed specifically for that function. Else, you're unnecessarily mixing concerns at the expense of clean/solid modularity.
Feb
27
comment Should we use python 2.6 or 2.7 or 3.x?
@Ashinkn The changes can be found here docs.python.org/3.0/whatsnew/3.0.html. The major compatibility-breaking change being the switch from using Unicode (as opposed to ASCII) as the default string type. Where people used strings as byte[] before there is a new bytearray type that is used instead. Also, any 2x strings explicitly defined as unicode need to be changed to regular strings.
Feb
10
comment What is a real-world use case of using a Chomsky Type-I (context-sensitive) grammar
What about HTML 'quirks mode' and code preprocessors, wouldn't they count?
Feb
7
answered Why don't we use a class and its static members to do what a singleton does?
Feb
7
comment Why don't we use a class and its static members to do what a singleton does?
Because the Singleton pattern came from GOF and GOF is cool... /s
Feb
1
comment How do programming languages benefit from being based on English?
I completely agree that trying to shoehorn English grammar into programming languages is a complete mistake. I don't agree with "this meaning is very jargon-y, specialized". As a native English speaker, describing concepts as analogues to pre-existing terms is typical of everyday communication. English as a language is just loosely interpreted and very context-specific in general. As for the German equivalents, it's not a big surprise. English borrows much of it's structure from German, and a lot of it's vocabulary from other languages. It's like the 'mystery meat' of natural languages.
Feb
1
comment How do programming languages benefit from being based on English?
Why is Italian the language of musical notation or Latin the music of Science? For technology it's English. With international acceptance as the 'lingua franca' it's inevitable that English will have the most extensive technology-specific vocabulary. A rich vocabulary is essential to effective (and universal) communication, so people are willing to adopt the language.
Jan
30
revised Shipping my first class library. Any gotchas I need to be aware of?
deleted 24 characters in body
Jan
29
comment What should my “code sample” look like?
If he's smart, he's probably trying to see if you'll just copy code straight from the web. Being able to copy and integrate code is a lot different from actually understanding it. Considering the amount of copypasta there is in the PHP community, that's one red flag I know I'd check for in a new recruit.
Jan
26
awarded  Good Question
Jan
25
comment I don't understand why algorithms are so special
Just take a good long look at how Quantization and Huffman Coding are used for lossless compression in the MP3 and JPEG formats. I mean, really understand it. Then imagine that the majority of electronic devices sold today provide hardware implementations of either or both. Physics is amazing because it involves understanding the underlying mechanisms of nature, algorithms is the same but the mechanisms are all man-made. Algorithms are the meta-language of machine consciousness.