Top tag
Next privilege 125 Rep.
Vote down
0 people reached

  • 0 posts edited
  • 0 helpful flags
  • 126 votes cast
comment Why is the minus sign, '-', generally not overloaded in the same way as the plus sign?
Maybe this is an example of historical baggage, a lot of languages allow string concatenation with + even if no other operator overloading is supported. I can think of the Metrowerks Pascal compiler and a few BASIC variants off the top of my head that allow + for strings even though every other mathematical operator is limited to numeric data-types.
comment What are my choices for server side sandboxed scripting?
JavaScript knowledge is widespread enough to make it a good choice as a scripting language. You may want to define some globals as well as calls for users since you are restricting access to calls. Think of how the browser defines window variables for JavaScript to enable interaction.
comment Short circuit evaluation, is it bad practice?
Language guarantee for short circuit operators are important, otherwise your results can be compiler dependent. Historically some Mac Pascal compilers treated & and | as short circuit and some treated them as identical to and and or.
comment Is “White-Board-Coding” inappropriate during interviews?
I've used whiteboard coding, the positive part is that it finds really good junior programers. The negative of whiteboard coding is the high failure rate, but those people aren't very good to start with. I've asked people to write as little as one line of code on the board and still had very high failure rates. On the other side I have been asked whiteboard questions as an interviewee and I've always found the questions reasonable. I much prefer whiteboard coding to listing off peoples favorite algorithms for specific problems.
awarded  Autobiographer
comment Is it okay to use exceptions as tools to “catch” errors early?
Fail early is the way to go if there is no way to recover from an error or condition. For example if you need to copy a file and the source or destination path is empty then you should throw an exception right away.
comment Why do C arrays not keep track of their length?
The unterminated arrays also fits with the bare metal approach of C. Remember that the K&R C book is less than 300 pages with a language tutorial, reference and a list of the standard calls. My O'Reilly Regex book is nearly twice as long as K&R C.
comment How would another popular language avoid having to use the factory pattern while managing similar complexity as in Java/Java EE?
I use a lot of the static method factories when I need to choose a subclass based on context but the differences should be opaque to the caller. For example I have a series of image classes that all contain draw(OutputStream out) but generate slightly different html, the static method factory creates the right class for the situation and then the caller can just use the draw method.
comment Why do JavaScript frameworks/libraries have functions which already exist in pure JavaScript?
The functions are there to support old browsers and to support old code that calls the library and the programmer doesn't want to rewrite. Even if you've dropped support for IE 6 you probably still have some JavaScript in use written when you did need to support ancient copies of IE.
comment Able to read Code but struggling majorly to write it
Programming requires both coding and someone to help you when you get stuck. I would not have gotten very far as a programmer in high school or college without some friends and classmates to help me out many times. Find someone in your dorm or class to help you out.
comment What is the advantage of wrapping exceptions
Upper layers of the program probably just care if the data was retrieved, not why the retrieval failed. Overly specific exceptions force the higher levels of the program to duplicate error handling when the effect of the exception is more important than the reason.
comment When is code “legacy”?
IMHO Legacy code is a function of the programmers age, the younger programers tend to see more recent code as legacy than older programers. The tendency to discount older code is independent of how up to date the programmers skills are, an older programmer who does JavaScript programming will less likely to see C++/Fortran code as legacy than a younger programmer.
comment How to convince/prove my manager that a rewriting is needed rather than a refactoring
Big ball of mud code usually has dependencies in the data that only get exposed by refactoring. For a previous job I had to wrap a series of database calls in a function because it turned out that there were undocumented order dependencies in the database driver state. Commenting code as you refactor is very helpful since you need to remember all the gotcha's you found.
comment Efficient methods for storing tens of millions of objects for querying, with a high number of inserts per second?
Memcached can be split across machines to increase the amount of ram available. You could have a second server serializing data to the filesystem so that you will not lose things if a memcache box goes down. The Memcache API is very simple to use and works from any language allowing you to use different stacks in different places.
comment Why is it hard to make a Java program 'appear native'?
Placement of buttons, exact sizes, and preferred GUI styles vary by platform and getting Java to mimic them takes work. Swing can give you the native button but if it's 10 pixels to tall the user will still think something is off. Apple has the Human Interface Guidelines and Microsoft has the User Interface Guidelines to help you get the correct native look. You will need to change UI somewhat between platforms.
comment Why not free memory as soon as its reference counter hits zero
@PieterB is correct, smartphones and tablets dominate computer sales and all of them have heavily constrained memory. See for a great overview of how garbage collection issues are very real in the mobile/tablet world.
comment Is there really anything to gain with complex design?
@Telastyn I've had to redo projects when requirements became too much for the system to handle. However given the choice I'd rather know that something needs to be redesigned than be stuck with an overly complex mess that fails slowly.
comment Is there really anything to gain with complex design?
I've seen many projects fail because of overly complex code. Simpler designs may show their limitations, but at least you can see the problems. Complex designs hide their limitations until you need to fix or change something.
comment Is it better to have constructors with or without parameters?
I've been bitten by incomplete constructor bugs many times, granted in C++ sometimes incomplete constructors are required because of the limitations of the language. In Java I find that the factory constructor technique can almost always eliminate incomplete constructors.
comment What are the safety benefits of a type system?
Runtime type systems like Java or Objective-C defer type casting errors to runtime, but at least you get a good explanation. In C++ dynamic typecasts are very risky since you may crash without getting an exception.