title: How important are PHP notices really?

text: I recently turned all possible error-messages on with `error_reporting(-1);`, on my PHP project. Of course, right away I got alot of messages. For example: > **Notice:** Undefined variable: foo in /.../file.php on line **205** So I started updating my code to get rid of all the notices. Mostly, by adding `isset($foo)` and making the `$foo = NULL;` So, I'm wondering. How important are these notices really? I mean, if the `$foo` variable is not set, then it should be false/null/not-set by default..so technically the code works?! If I would get rid of all notices, then does it make the process faster or slow it down (because I'm adding more code, `isset($foo)`, `$foo = NULL` etc)? How do you guys deal with these notices, or do you even pay attention to them?   I guess, the most important question is: Should the code be written so strict, that it would never generate any notices or warnings?


title: About empty line of code

text: Why do my colleagues hate it when I add an empty line of code? Sometimes I add a few lines to see when a method ends and another one starts more easily.


title: What is the standard practice for extracting an auto-incrementing primary key?

text: I have some objects that will be created an entered into the database. There is no guarantee that any of their fields will be unique except for the auto- incrementing primary key. I would like to be able to access these objects later in the program using their primary key. What is the best way to get this key out of the database? I can think of two methods to obtain the primary key after adding the object's data to the database:   1. Find the maximum primary key as this was the one most recently added.   2. Delete the current object, compare the data in the database with the data in the program, and then create a new object based on the row that is not contained in the program. Both of these seem error-prone and hacky and I am wondering if there was a more standard way do to this.


title: Writing arguments in constructors

text: When creating constructors with multiple arguments, is ok to use the generic `String[] args` or is it better to list the arguments? Does it really make any significant difference as the coding becomes more complicated?               public static void Something (String[] args)      {     }      or               public static void Something (String lots, ... int some, ... etc)      {     }


title: sell applications that run only on a GPL v2 Server

text: I have been testing Pentaho BI server community edition, and after reading their licensing terms I found out that the community edition is under GPLv2. As you may know the server is intended to host different types of files and applications (like reports, olap cubes,etc...) My question is : are we allowed to sell applications that run on the GPLv2 server ? (we will maybe modify the server source code a bit but we won't charge it to our clients. thus the modified GPL server will be just an execution environment or a container for the reports and applications that we intend to sell) ? this suggests that our clients must install the GPL v2 edition first and then buy from us the reports that work on it but not their source code. Thanks in advance.


title: Tomcat + Spring + CI workflow

text: We're starting our very first project with `Spring` and `java` web stack. This project will be mainly about rewriting quite large ERP/CRM from `Zend Framework` to `Java`. Important factor in my question is that I come from `php` territory, where things (in terms of quality) tend to look different than in `java` world. **Fatcs** :   * there will be 2-3 developers,    * at least one of developers uses Windows, rest uses Linux,   * there is one remote linux-based machine, which should handle test and production instances,   * after struggling with buggy legacy code, we want to introduce good programming and development practices (CI, tests, clean code and so on)   * client: internal, frequent business logic changes,   * scrum, daily deployments What I want to achieve is good workflow on as many development stages as possible (coding -> commiting -> testing -> deploying). The problem is that I've never done this before, so I don't know what are best practices to do this. **What I have so far is:**   1. developers code locally,   2. there is `vagrant` instance on every development machine, managed by `puppet`. It contains the same `linux`, `jenkins` and `tomcat` versions as production machine,   3. while coding, developer deploys to vagrant machine,   4. after local merge to `test` branch, `jenkins` on vagrant handles tests,   5. when everything is fine, developer pushes commits and merges   6. `jenkins` on remote machine pulls commit from `test` branch, runs tests and so on,   7. if everything looks green, `jenkins` deploys to `test` `tomcat` instance   8. Deployment to production is manual (altough it can be done using helping scripts) when business logic is tested by other divisions and everything looks fine to client. **Now, the real question: does above make any sense? Things that I'm not sure about:**   1. Remote machine: won't there be any problems with two (or even three, as jenkins might need one) instances of same app on `tomcat`?   2. Using `vagrant` to develop on `php` environment is just vise. Isn't this overkill while using Tomcat? I mean, is there higher probability that `tomcat` will act the same on every machine?   3. Is there sense of having local `jenkins` on vagrant?


title: Cost Estimation For Aspect Oriented Programming AOP

text: There are many estimation techniques, such as counting lines of code, Function Points, Object Points, etc. However, my next project is using Aspect Oriented Programming. Are there any special estimation methods or techniques that can be applied to software developed using this paradigm? Is there something like function points or object points for AOP?


title: What is the correct way to deal with similar but independent features?

text: Let's say we have a feature request come in and we begin work on it, which we'll call _feature-1_. It introduces some new logic to the application, which we'll call _logic-A_ and _logic-B_. A programmer branches from the release branch and begins work on the feature. Soon after, we get another feature request, which we'll call _feature-2_. It will implement _logic-A_ and _logic-C_ into the application. The _logic A_ being implemented by this feature is the same _logic-A_ as was implemented in _feature-1_. Let's also say that given _logic-B_ , _logic-A_ might be implemented slightly differently than it would have been given _logic-C_ , and also differently given both _logic-B_ and _logic-C_ (eg. with only one feature, the code would be less flexible than with both). How should this situation be handled? **Concrete Example** (to help with any confusion in my wording)   * _feature-1_ is a feed from programmers.stackexchange.com.   * _feature-2_ is a feed from gaming.stackexchange.com.   * _logic-A_ is the implementation of a feed at all (assuming the application currently has no feeds), which links to the content as well and gives related information.   * _logic-B_ is that the feed's source is from programmers.stackexchange.com.      * Adds to _logic-A_ that the related programming language is displayed.   * _logic-C_ is that the feed's source is from gaming.stackexchange.com.      * Adds to _logic-A_ that the related game's name and box art is displayed.


title: Alternative to Perl's POD Documentation in Other Languages?

text: Perl has this really cool documentation method that makes documenting really easy. It's called POD (Plain Old Documentation). Here is an example:               =head1 NAME          Example::Module - an example          =head1 SYNOPSIS              use Example::Module;         my $object = Example::Module->new();         print $object->as_string;          =head1 DESCRIPTION          Just an example.          =head2 Methods          =over 12          =item C<new>          Returns a new My::Module object.          =item C<as_string>          Returns a stringified representation of     the object. This is mainly for debugging     purposes.          =back          =head1 LICENSE          This is released under the Artistic      License. See L<perlartistic>.          =head1 AUTHOR          Dynamic           =head1 SEE ALSO          L<perlpod>          =cut      The output of this would be in HTML, like this example on CPAN (not what I wrote). Cool right! So is there a method similar to POD in which a developer can put there documentation inside of the code itself, without it being a comment?


title: Create Tickets From TODO (or otherwise annotated) comments

text: Is there any software that will allow me to generate trouble tickets (for Trac, Team Foundation Server, etc.) from TODO or otherwise annotated comments in the source code?


title: A defense for boilerplate?

text: To me, boilerplate code is obviously bad. However I've met a developer who displays resistance in any attempt to reduce boilerplate. I realized I didn't have a readily formed, well thought out argument past the abhorrence I have developed for it over time. So that I can form a convincing argument for favoring less boilerplate, what are some counterarguments? In other words what are the arguments (if any) in favor of boilerplate? (I mean what I think is generally meant by boilerplate, but a good example is getters and setters in Java.)


title: How can I improve upon this "pattern"?

text: I have a series of method calls that all share similar qualities. The basic layout is               public void CallDataBase()     {        Utility sqlHelper = new Utility();                StringBuilder query = new StringBuilder(200);        query.Append(@"update " + Environment.NewLine);//or insert, select        query.Append(@" table " + Environment.NewLine);        //...        utility.ConnectAndExecuteNonQuery(query);//or query, scalar       }      I'm not a big fan of the `StringBuilder` in this case, but it does help readability to have line breaks in the inline SQL. Stored Procedures are not an option (way too much work to convert, have higher priorities). LINQ and EF are not options. Company is on SQL 2000 and there are no concrete plans to upgrade.


title: How can I prevent programmers from capturing data entered by users?

text: I'm developing a web application with a strong focus on security. What measures can be taken to prevent those who work on the application (programmers, DBAs, quality assurance staff) from capturing user entered values that should be well-protected, such as passwords, social security numbers, and so forth?


title: How to decide whether to implement an operation as Entity operation vs Service operation in Domain Driven Design?

text: I am reading Evans's Domain Driven Design. The book says that there are entity and there are services. If I were to implement an operation, how to decide whether I should add it as a method on an entity or do it in a service class? e.g. `myEntity.DoStuff()` or `myService.DoStuffOn(myEntity)`? Does it depend on whether other entities are involved? If it involves other entities, implement as service operation? But entities can have associations and can traverse it from there too right? Does it depend on stateless or not? But service can also access entities' variable, right? Like in do stuff myService.DoStuffOn, it can have code like               if(myEntity.IsX) doSomething();      Which means that it will depend on the state? Or does it depend on complexity? How do you define complex operations?


title: Command-Query-Separation and multithreading safe interfaces

text: I like the command query separation pattern (from OOSC / Eiffel - basically you either return a value or you change the state of the class - but not both). This makes reasoning about the class easier and it is easier to write exception safe classes. Now, with multi threading, I run into a major problem: the separation of the query and the command basically invalidates the result from the query as anything can happen between those 2. So my question is: how do you handle command query separation in an multi- threaded environment? * * * Clarification example: A stack with command query separation would have the following methods:   * push (command)   * pop (command - but does not return a value)   * top (query - returns the value)   * empty (query) The problem here is - I can get empty as status, but then I can not rely on top really retrieving an element since between the call of empty and the call of top, the stack might have been emptied. Same goes for pop & top. If I get an item using top, I can not be sure that the item that I pop is the same. This can be solved using external locks - but that's not exactly what I call threadsafe design.


title: What is the canonical reference on probabilistic data structures?

text: I've heard of probabilistic data structures like Skip Lists and Bloom Filters being immensely useful and I'd like to learn more about them in general. Is there a canonical reference on the subject on the level of Cormen et al.?


title: BDD: Getting started

text: I'm starting with BDD and this is my story:               Feature: Months and days to days         In order to see months and days as days         As a date conversion fan         I need a webpage where users can enter         days and months and convert them to days.      I have some doubts ... Should I write my scenarios before coding anything or should I first write a scenario and then write code, write a scenario again and then write code, and so on ... ? If I should write my scenarios before, can my steps be approved and production code still does not get done? When should I do refactoring on my code? After the feature is done or after each scenario implementation?


title: Ethics and best practices when forking code base

text: I have a question as to the proper best practices and ethics revolving forking code. I've taken code base licensed under Creative Commons Attribution- NonCommercial-ShareAlike 3.0 and brought significant changes to it to suit my needs. I feel as though my version could benefit others and wish to redistribute it. I'm unsure what liberties I have for redistribution or what is ethically and morally accepted. Can I rename the projects? Should I start a new v.1 or continue from the original version number? What is considered giving proper attribution to the original author? Should I consult the author and ask permission before releasing (although he is already aware)?


title: Is it acceptable within the community of developers to copy open-source software and branch it?

text: Is it generally, to a reasonable developer, considered morally acceptable, to take a branch of an open-source repository, and start making changes to it and calling your own? You would be taking this to another open-source. Assume that you will link to the original. Note that this is a question of what is considered acceptable, _not_ what is legal. If this is okay, where is the line of how much you change that allows you to call it your own?


title: Migrating from PHP to ASP .NET MVC

text: I plan on migrating a website from PHP to ASP .NET MVC. However, since the website is large and this migration can't be done in a short time I plan to use both MVC and PHP pages together. So the idea is to replace each PHP page or group of pages with an MVC equivalent. I have to refactor each page and rewrite it overall anyways so I thought I might as well move to the ASP .NET MVC framework for various reasons. The question is, does anyone know what are some of the problems I will face while doing this? Here are some I thought of: \- Logins \- I plan to overcome this with an ajax request to the ASP .NET website on the background and keeping the login information separately for asp .net. \- Sessions \- I'm not sure how I can share sessions or if I will even need to. Other than that, I'm not sure if anything else will arise. Anyone experienced that have a few things to say?


title: What can I use to generate API documentation with my custom formatting?

text: I want to automatically generate documentation for a java project, but I'd like to have my own custom styling for it. As an example, take the stackoverflow api (method description page), can that be done by an automated tool? Can it "take me close" to that?   I wouldn't mind having to manually change a few things to achieve the result I want (ie: it doesn't have to be 100% automated)


title: Are first person comments distracting and unprofessional?

text: I just found myself writing the following comment in some (archaic Visual Basic 6.0) code I was writing:               If WindowState <> 1 Then         'The form's not minimized, so we can resize it safely         '...     End if      I'm not sure why I subconsciously use "we" in my comments. I suspect it's because I imagine someone stepping through the code, as if they were actually "doing" all of the commands on each line, rather than just watching them happen. With this mindset, I could have used `I can resize it`, since I'm the one "doing" it currently, or `you can resize it`, as if I were speaking to whomever is "doing" it in the future, but since both of those of these cases will most likely happen, I use "we" as if I'm leading someone else through my code. I can simply rewrite it as `it can be resized` and avoid the issue, but it's sparked my curiosity: is it common to use first person like this in comments, or is it considered distracting and/or unprofessional?


title: How to hire a contract/outsourced architect for

text: The company I work for has a legacy application that we are looking at rewriting and enhancing using more modern technology. We are a very small company (5 people) and do not have the resources to hire a full time permanent architect so we are looking to hire an architect as a consultant for a short term (about 6 months) engagement to help us design the software and then we will take care of (or use additional staff augmentation) of developing based on the design. We have compiled a list of general high level requirements as well as some other lists of more specific functional requirements. How feasible is what we are trying to do? What kinds of information should we have prepared so that we can provide enough information to potential candidates for them to determine if they will be able to come up with a design for us that we can take over and develop from? What should we ask for from them to base our hire decision on?


title: Does forcing a user to add numbers or uppercase letters really make a password stronger?

text: Recently my university updated their password storage procedure, and they have several criteria such as that the password must contain a number, symbol, and uppercase character, and has a length requirement. Realistically, when a brute force / dictionary attack is being performed, doesn't this just make it easier for the person to crack one that works? I understand that this is to prevent people from doing things like "password," but what about one such as "youwillneverguessmypassword" ?


title: How to keep up with the Rails world?

text: How should I keep up to date with the ever-changing Rails community? I have been trying to learn Rails off and on for a year now and the brick wall I keep running into is the fact that I'm trying to balance learning most of the Rails' community best practices and they keep changing direction. For example, I obviously need to learn Rails and Ruby (I've done some work with both but I've forgotten a bit). When I was using it before it was still Rails 2.3.4, so now Rails 3 is out and changed some things; I'm not sure if Ruby 1.9 had any major changes. I like my version control, and the Rails world is solidly behind Git, so I have to use Git (again I've used it before but not recently). I want to make sure my app is solid so I want to write tests; the new trend in Rails seems to be to use RSpec or similar BDD frameworks instead of the built-in test framework, and mocks/factories instead of fixtures. I'm having a very hard time keeping up with all the things I need to pick up to be successful using Rails, and it seems that it's always changing and I end up frustrated because I will choose something, then when I research how to do something I find loads of blog posts saying don't use it anymore, use this new thing instead. So I have to ask how much this matters? If I'm going to be revisiting Rails I obviously want to be using Rails 3. I've used Git so I can stick with that. Should I even bother with RSpec/HAML/SASS/whatever else the "cognoscenti" is hyping or should I just focus on mastering the framework and stick with the built-in stuff (e.g. use the built-in ERB engine for HTML, Test::Unit for testing, Fixtures instead of mocks/factories, etc) as much as possible (stupid thing to ask, I know, but the way my brain works I am always torn between doing the easiest thing that will benefit me and doing things the "right" way as the really high-end guys suggest) so I can focus on actually developing my application? Should I extend that to Javascript as well, meaning should I just say screw it and use RJS or is that actually worth using jQuery (I've used jQuery for my .NET work a fair bit although I'm by no means an expert) due to the benefits? I would like to "nail down" a stack that I can use and not deviate but again I find myself constantly wondering "If the top Rails guys are using XXX now am I hurting myself by not switching to it myself?" For example I'd like to just decide 100% on:   * Framework: Rails (obviously) Source   * Control: Git Test Framework:   * Test::Unit w/Factories HTML Engine:   * ERB Javascript Framework: jQuery but whenever I try this there's a voice in the back of my heading saying I'm "doing it wrong" and should be using RSpec/Shoulda/HAML/library du jour instead.


title: How do you accept arguments in the main.cpp file and reference another file?

text: I have a basic understanding of programming and I currently learning C++. I'm in the beginning phases of building my own CLI program for ubuntu. However, I have hit a few snags and I was wondering if I could get some clarification. The program I am working on is called "sat" and will be available via command line only. I have the main.cpp. However, my real question is more of a "best practices" for programming/organization. When my program "sat" is invoked I want it to take additional arguments. Here is an example:               > sat task subtask      I'm not sure if the task should be in its own task.cpp file for better organization or if it should be a function in the main.cpp? If the task should be in its own file how do you accept arguments in the main.cpp file and reference the other file? Any thoughts on which method is preferred and reference material to backup the reasoning?


title: Should you create a class within a method?

text: I have made a program using Java that is an implementation of this project: http://nifty.stanford.edu/2009/stone-random-art/sml/index.html. Essentially, you create a mathematical expression and, using the pixel coordinate as input, make a picture. After I initially implemented this in serial, I then implemented it in parallel due to the fact that if the picture size is too large or if the mathematical expression is too complex (especially considering the fact that I made the expression recursively), it takes a really long time. During this process, I realized that I needed two classes which implemented the `Runnable` interface as I had to put in parameters for the `run` method, which you aren't allowed to do directly. One of these classes ended up being a medium sized static inner class (not large enough to make an independent class file for it though). The other though, just needed a few parameters to determine some indexes and the size of the for loop that I was making run in parallel - here it is:               class DataConversionRunnable implements Runnable         {             int jj, kk, w;                  DataConversionRunnable(int column, int matrix, int wid)             {                 jj = column;                 kk = matrix;                 w = wid;             }                  public void run()             {                 for(int i = 0; i < w; i++)                     colorvals[kk][jj][i] = (int) ((raw[kk][jj][i] + 1.0) * 255 / 2.0);                 increaseCounter();             }         }      My question is should I make it a static inner class or can I just create it in a method? What is the general programming convention followed in this case?


title: Design Pattern for Skipping Steps in a Wizard

text: I'm designing a flexible Wizard system that presents a number of screens to complete a task. Some screens may need to be skipped based on answers to prompts on one or more previous screens. The conditions to skip a given screen need to be editable by a non-technical user via a UI. Multiple conditions need only be combined with `and`. I have an initial design in mind, but it feels inelegant. I wonder if there's a better way to approach this class of problem. **Initial Design** **UI** ![UI Mockup](http://i.stack.imgur.com/biEbk.png) where The first column allows the user to select a question from a previous screen. The second column allows the user to select an operator applicable to the type of question asked. The third column allows the user to enter one or more values depending on the selected operator. **Object Model**               public enum Operations { ... }     public class Condition     {         int QuestionId { get; set; }         Operations Operation { get; set; }         List<object> Parameters { get; private set; }     }          List<Condition> pageSkipConditions;      **Controller Logic**               bool allConditionsTrue = pageSkipConditions.Count > 0;     foreach (Condition c in pageSkipConditions)     {         allConditionsTrue &= Evaluate(previousAnswers, c);     }           // ...          private bool Evaluate(List<Answers> previousAnswers, Condition c)     {         switch (c.Operation)         {             case Operations.StartsWith:                 // logic for this operation             // etc.         }     }


title: Initializing derived classes in the same way

text: I have a class Base that has several children, say A, B, C. For testing purposes I'd like to mock those derived classes by deriving from them. So MockA derives from A, MockB derives from B and so on. The problem is, that MockA, MockB, ... all inherit protected members from Base that have to be set in the same way in each mock class. The code looks like this:               MockA::init()     {         x = 1;     // inherited from Base         y = "abc"; // inherited from Base         z = 0.5;   // inherited from Base     }          MockB::init()     {         x = 1;     // inherited from Base         y = "abc"; // inherited from Base         z = 0.5;   // inherited from Base     }      and so on. So my question is, how can I avoid this cut&paste initialization? Can I achieve it without touching Base, A, B, C, ...?


title: Call a script over the network

text: I have a Python script on a box that I want to call from a Java server, over the network. I know that I can start a server on the Python side and then connect to it from the Java site, but I am trying to see if there is a way to avoid the overhead of running a server on the Python side. Is there any other way of doing it?


title: is coding important?

text: Is coding important to be good at computer science? Should one implement the algorithm to know it well ? I remember one cs professor's idiom that " **I never code"**


title: Client side authentication through signatures instead of passwords

text: I want to save some user-generated data with some signature of the user that generated it (let's say that the user has to fill some forms with some data and I want him to sign the written data). The server side is some random server language (that has big enough libraries to cover everything I'll need to do), the client side is Javascript (and the webapp is a SPA, Single Page Application). The client machine can be a cellular (a fairly new smartphone... but still a slow CPU compared to standard desktops/laptops) The DB backend is "insecure". It is possible to tamper the data (many persons have access to the machine, perhaps it's "in the cloud"), but there is and a strong sequential continuous backup where it is very difficult to tamper with the already written data (something similar to a secured sequential log) (perhaps a digest of the log is shipped continuously to a secure server, or the sequential log is kept in another cloud totally separate from the first one, or if it only has to save some hashes, even a random machine can do it). What I want to be able to do is make very difficult for third parties that have read/write access to the DB machine and read access to the server machine to add/modify records created by the user. For the deletion I'll do this: the program doesn't do any real update/delete operation. Every update/delete simply add a new version of the data and marks the old as "old". The hash of all the data is continuously saved on the tamper proof backup. This will even protect me from updates to old data. The only thing it won't protect me is against adding new data through spoofing an existing user. I will use https to secure transmission (with certificates bought from some SSL cert authority). I know I can't really secure the site (as in "the javascripts that will go to the user"), so that this is a weak point (someone could install a keylogger directly in the javascript code). I've watched around but it doesn't seem possible to sign some javascript code, send it to a client and let the client check the signature (probably because the javascript, being a dynamic language, would let a malicious javascript inject himself in the signed code/in a random piece of the javascript base library, so it would be very difficult to firewall everything the pre-existing environment). I could check the signature from the server side (the server program is signed and sends only javascripts that are signed). I don't want to use client-side SSL certificates because they are difficult to use for the user (if the user changes computer he has to reinstall the certificate, if the user forgets he has a certificate in a computer it's possible to steal it...) The solution I thought was to use ECDsa, generate a public/private keypair from the user password (plus some other data) and then the client signs the user's data client-side. The public/private key generation happens client side. When the user is created and the password is chosen, the client generates the public/private keypair and tells the server the generated public key. The user only needs to remember its password. Clearly the weak point of this is that someone could add a new public key of the user on the server and sign something with the new public key, but it would be quite easy to spot this, because there would be a new public key. Something more clever would be to change an old public key and then resign everything the user signed with that new key, so it would be impossible to show if the data was tampered, but for this there is the tamper-proof log. Another weak point would be from the user side: someone could install a keylogger and steal the password, but this is a problem of all the "standard" password schemes (for this I'll add a TOTP authentication, see at the end) Password recovery would be handled "manually" (a super-user would have to confirm the identity of the user and then sign the change of the password with the super-user's key) Now let's make it a little more complex: the private key is generated from the PBKDF2 of a salt unique for each user (sent by the server) plus the user's password. Sadly to make the software compatible with cell phones I will need to keep the iterations of PBKDF2 low (mmmh... On my old Optimus W, 1000 iterations require 8 seconds, while with the S3 it's nearly instantaneous... But 1000 iterations isn't very strong) (perhaps I could use Scrypt instead of PBKDF2... It should be more resistant to GPU attacks) So in the end it would be: User inserts username and password and press a button. The client asks the server for the salt, for the number of iterations of the hashing function and for the time of the day (this to stop attacks based on reusing the same signature), then calculates the hash of the password by using PBKDF2/Scrypt, regenerates the ECC private key, signs the message (that contains the operation requested and the time of the day received by the server) and sends the signature. The server must remember what challenges he has given and what have been replied (and so are "exhausted"). After this I could add a two step verification (using the algorithm used by Google Authenticator, for example). The key of this would be shared between user and server. The one-time password could be inserted in the various messages signed by the client. The server could save the calculated time of the TOTP so that it would be easy to verify at a later time. So the question is: is everything ok? Is there a pre-made solution that does everything? Is there an hole in my reasoning?


title: A job in big company like IBM/Microsoft vs. own small 1-2 people software company?

text: I hope all programmers have gone through the stage at I am. I'm an iPhone and mobile apps developer and currently working in a company which is 1 of the best in my city. Now I am at a stage where I've two options. The first is with a big company like IBM or the second is with my own small company in which one of my friends and I will be starting. You might be wondering why am I asking this question instead of trying my own company but I know that once getting myself into a business going back to a job after closing a business would be a painful condition for me. What's your preference? What advice can you suggest?


title: One or many RESTful APIs for large company?

text: I work for a large company which has several non-RESTful APIs. I am tasked with building a web application to interact with these APIs. Each API handles and provides very different business processes and data. I'd like to build RESTful (a) interface(s) fronting the APIs so as to make them reusable by other future web applications. Then, I'd like JavaScript to interact with the RESTful interface(s). Should I build one RESTful API (one subdomain) for my entire company               http://api.mycompany.com         /business_process_1/resource/         /business_process_2/resource         /business_process_3/resource      and make it front the very different business processes and data? Or, should I build multiple APIs (multiple subdomains)?               http://business-process-1.mycompany.com     http://business-process-2.mycompany.com     http://business-process-3.mycompany.com


title: ASP.NET MVC: Getting User input in your Controller?

text: I wanted to get your opinion on best practices for getting user input while doing something in a controller. I am inside a Action method in my controller and I am processing some data. The data may force me to ask the user for further input, based on that input I will then do something with that data. What is the best practice to go about this? 1) How do I issue an alert or confirm box to get user input from the Controller? This Action is initiated by an update button on a Telerik MVC grid. 2) How do I persist my data from initially processing it, to asking the user for input, and then continue processing the data? It's a fair amount of data. If the initial request was started from a ajax call in a javascript function, I think I would know how to do this. I would probably have the Action method pass back a JSON object back to the javascript method that would in turn ask the user and then decide which controller action to call and then pass this json object to it. Am I on the right track here? If so, my problem would be with the Telerik MVC grid. I would need the update event of my grid to be bound client side. Any help or thoughts on this is appreciated. Steve


title: Why is Software Engineering not the typical major for future software developers?

text: While most agree that a certain level of Computer Science is essential to being a good programmer, it seems to me that the principles of good software development is even more important, though not as fundamental. Just like mechanical engineers take physics classes, but far more engineering classes, I would expect, now that software is over a half century old, that software development would begin to dominate the undergraduate curriculum. But I don't see much evidence of this. Is there a reason that Software Engineering hasn't taken hold as an academic discipline?


title: How would you like to be coached?

text: My boss is going through a certification process reggarding "Coaching", and he asked me if he could coach me. According to what I understood from him, I should have an objective on what should I be coached at and some initial questions from where the coaching process would stem from. As a software developer who likes to embrace new technologies and has lately been specially enjoying the "requirements negotiation" part of the work, I have no idea on what could I be coached or what kind of questions could I bring him. Maybe you guys here would have nice ideas?


title: What do I tell my colleagues when they complain that our Rails-based website has an API but is not a Web Service?

text: People want SOAP or a WDSL. I've just got a defined API. What's wrong with that?


title: Is it appropriate to ask for reasons after rejected after the interview?

text: I thought I did okay in the interviews but apparently the interviewers didn't think so. Is it appropriate to ask for a reason after I have received the rejection email? After all I don't want to annoy the HR person. I am a student, so not so much job hunting experience so far. Bear with me if this question sounds stupid.


I have to do an economic viability analysis for an iPhone app and I do not know if you could help me in some questions like link text:   * How can I estimating an iPhone application development costs?   * Cost per hour of a programmer?   * Time that 1 programmer takes in doing an app similar to “Spend Free - Personal Budgeting” link text supposing that it has experience in Java but is rookie in the world of development of aplicaiones for iPhone (neither Objective-C nor Cocoa Touch knows …)   * Time in integration testing?   * Return on investment (ROI)? Where can I find information?


title: Do Ruby (and other dynamic language) programmers use IoC / Dependency Injection?

text: I'm primarily an ASP.NET developer and the single thing i've been introduced to in recent years that has had the most dramatic impact on the quality of the code I write has learning how to use IoC containers to manage dependencies between different layers of the application efficiently. I've recently made it my hobby to learn Ruby (and Rails) for personal projects, and I love the language so far. However, one of the things i've noticed from the various tutorials and references i've been using, has been that there has been no mention yet of using IoC. This is in stark contrast to .NET where it is (and where it isn't, should be) drummed into developers at an early stage. I appreciate that one reason why dependency injection may not be necessary in Ruby, is that everything in a class is public and virtual so open to modification so it's not really needed in order to write good unit tests. But there are of course many other benefits to using IoC containers such as the decoupling options this brings, managing object creation and lifetime etc. Is dependency injection used in Ruby? If not, why is this not an issue?


title: Why is SIT called SIT when it serves for system testing?

text: I should define a testing strategy and environments and I have encountered rather terminology issue (but might well be my fault) so I hope someone will correct me here. We are using INT environment where the application is deployed at first and then SIT environment, where is the app passed if it is fine on INT. So, testers do all system tests on SIT. But according to all definitons, SIT is system integration testing which is done after the system tests and validates cooperation of more systems. So why SIT serves actually for system testing, yet it is said to be a phase which actually follows the system testing? EDIT: According to common knowledge-books:   1. Unit   2. Integration (modules to larger pieces)   3. System test   4. ().. System Integration Test --if there are more system to integrate Our apps consist of db, services, frontend. So to make a system test, they must be integrated, otherwise testers cannot do anything. So SIT precedes actual system testing (both funtional and non functional) which does not match with described processes. And environment for testers is also called SIT..


title: Class diagrams - do aggregated/composed classes automatically see each other?

text: Let's say that in the game, a player has a pet: Player<>------Pet Obviously player can access Pet's fields and methods, but I assume Pet does not know about the player? I need that Pet can access the player as well, how should I model that?


title: Deleting Lookup Item

text: I was wonder what people do in this situation. You have an admin area of a system where you let users define a list of values they want to see in a dropdowns across the system. What do you do in your application is a user wants to delete this option? What do you do with data records which already use this value?


title: How to see bits of an integer in Visual Studio

text: As far as I know it is not possible to see the bits of an integer in Visual Studio, you can see variables in decimal or hexadecimal format in the Locals and Watch windows in the debugger. Why is this limitation in place and are there any tools/addins to see integers as bits?


title: Data aggregation like polyvore.com

text: I'm creating a website that is going to aggregate women shoes from across the web into one website. Kinda like polyvore.com does with all their products but mine is only going to be shoes. Which makes my job a lot easier but I'm still lost as to how I go about getting all the data. I have access to 3 APIs so far. Which provide over 15000 line items so far but there are 1000's of sites out there and millions of products. What is the best method to aggregate all this data? Is it even possible? Or should I rely on a social aspect as well, like polyvore where users can upload any products that aren't on the website? Also, do I have to resort to screen scraping? And is this possible as a one man show? Polyvore has a team of 30 programmers, do I need a team to do this properly?


title: What is the most frequently used design pattern?

text: Which design pattern do you think is the most popular?


title: What are your experiences with off-shore or outsourced testing?

text: **Has anyone had experience** with out-sourced testing? Is it worth the fairly high premium you have to pay? Can you simply hire some _off-shore_ 'mechanical turks' (who offer the same services, but a lot cheaper) with a testing script as a cheaper alternative to professional software testing services?


title: Is SugarCRM really adequate for custom development (or adequate at all)?

text: Have you used SugarCRM for custom development successfully?, if so, have you done it programmatically or through the Module Builder? Were you successful? If not, why? I used SugarCRM for a project about two years ago, I ran into errors from the very installation, having to hack the actual installation file to deploy the software in the server and other erros that I can't recall now. Two years after, I'm picking it up for a project once again. I'm feeling like I should have developed the whole thing from scratch myself. Some examples:   * I couldn't install it in the server (again).  I had to install it locally, then copy the files and database over to the server and manually edit the config file.   * Constantly getting deployment errors from the module builder.  One reason is SugarCRM keeps creating a record in the upgrade_history table for a file that does not exist, I keep deleting such record and it keeps coming back corrupt. I get other deployment errors, but have not figured them out. then I have to rollback all files and database to try again.   * I deleted a custom module with relationships, the relationships stayed in the other modules and cannot be deleted anymore, PHP warnings all over the place.   * Quick create for custom modules does not appear, hack needed.   * Its whole cache directory is a joke, permanent data/files are stored there.   * The module builder interface disappears required fields.   * Edit the wrong thing, module builder won't deploy again, then pray Quick Repair and/or Rebuild Relationships do the trick. My impression of SugarCRM now is that, regardless of its pretty exterior and apparent functionality, it is a very low quality piece of software. This even scared me more: http://amplicate.com/hate/sugarcrm; a quote: > I wis this info had been available when I tried to implement it 2 years > ago... I searched high and low and the only info I found was positive. Yes, > it's a piece of crap. The community edition was full of bugs... nothing > worked. Essentially I got fired for implementing it. I'm glad though, > because now I work for myself, am much happier and make more money... so, I > should really thank SugarCRM for sucking so much I guess! I figured that perhaps some of you have had similar experiences, and have either sticked with SugarCRM or moved on to another solution. I'm very interested in knowing what your resolutions were -or your current situations are- to make up my own mind, since the project I'm working on is long term and I'm feeling SugarCRM will be more an obstacle than an aid. After further failed attempts to continue using this software I continued to stumble upon dead-ends when using the module editor, I could only recover from this errors by using version control. We are now moving on to a custom implementation using Symfony; perhaps if we were using it with its out-of-the- box modules we would have sticked with it.


title: Is php|architect any good?

text: Kind of a hard topic to search for, as architect turns up a lot about software architects instead. After 8 months of PHP self-study, I finally stumbled across the php|architect site. The length of time it took me to find it makes me suspicious of its quality. 3 related questions:   * do professional PHP coders read/care about php|architect?   * is it a good source for PHP beginners?   * assuming yes to either of the above, how far back in the archives to articles remain relevant? (ex: does stuff written about PHP4 still matter?)


title: "C++ Templates: The Complete Guide" (c) 2002 -- up to date with C++11?

text: The book _C++ Templates: The Complete Guide_ , (c) 2002, looks very appealing to me, but as it's 12 years old, I'm concerned it may be out of date. There are some highly favorable Amazon reviews dated as recently as a year ago, and I don't see any other very recent titles on C++ templates. Does anyone know whether a book about templates published in 2002 (as opposed to a book specifically about the STL) would have syntax or concepts that have been superseded or added to by, say, C++11? The following is from the Amazon book description: > Templates are among the most powerful features of C++, but they are too > often neglected, misunderstood, and misused. C++ Templates: The Complete > Guide provides software architects and engineers with a clear understanding > of why, when, and how to use templates to build and maintain cleaner, > faster, and smarter software more efficiently. > > C++ Templates begins with an insightful tutorial on basic concepts and > language features. The remainder of the book serves as a comprehensive > reference, focusing first on language details, then on a wide range of > coding techniques, and finally on advanced applications for templates. > Examples used throughout the book illustrate abstract concepts and > demonstrate best practices. > > Readers learn > >   * The exact behaviors of templates >   * How to avoid the pitfalls associated with templates >   * Idioms and techniques, from the basic to the previously undocumented >   * How to reuse source code without threatening performance or safety >   * How to increase the efficiency of C++ programs >   * How to produce more flexible and maintainable software >


title: UDP segments that are lost

text: i know that UDP does not care about segment (packet) order and their arrival on the destination. then how on earth are we able to stream videos?   * if a segment is lost (doesn't reach the destination), destination has no idea about it. so, it can't ask the target to retransmit it.   * if a segment arrives out of the order, should't the video being streamed be distorted? since the whole segment order is wrong now, because of that one segment is not on its place.


title: If another team haven't done a requested task, are we supposed to mention it in every Daily Scrum as an Impediment until they do?

text: Is it really necessary to mention the same impediment (blocking issue) in every daily standup, if the whole Scrum team already know about it because it's been mentioned at previous daily standups?


title: Interface naming: prefix 'Can-' vs suffix '-Able'

text: It's common to use '-able' as a suffix for interfaces e.g. Serializable Printable Enumerable Drinkable Shootable Rotatable I was thinking that 'Can-' might better because it may be more descriptive. Yes, it is more wordy and it adds noise to the interface name. In particular, passive verbs can be used. _E.g. 1_ does Shootable mean that the object is able to shoot (a gun might implement this), or does it means that it can be shot at (a target board might implement this). With the 'Can-' prefix, the former would be "CanShoot" and the latter would be "CanBeShotAt" or "CanShootAt". _E.g. 2_ A document 'CanBePrinted' and a printer 'CanPrint' Or, should we stick with '-Able' and _let the documentation provide the context?_ Any opinions.


title: How to elegantly work with a lot of print functions?

text: I'm working on a Python project that is executed on a terminal (or console) for which I am planning to implement a GUI. I did not major in CS so I really have no idea how to effectively design a terminal GUI such that:   1. the user interface looks good   2. in GUI, it is directed to a certain widget, let's say, a text label, or a bottom bar, or a hide-able frame. Do you have any suggestions? Currently, I am using the `print` function to provide essential information on `STDOUT` during execution, so a lot of `print` calls are distributed here and there in the code. I'm thinking of using macro-like variables such as 'FILE_NOT_EXISTS_MESSAGE' for printing, and all of them and their values would be defined in one file. Is that a standard way to do this? Should I introduce a logging system? In summary, I'm looking for a pattern for handling console output that is effective and adaptable.


title: When accessing/manipulating complex data, is it better to store it in many small pieces or one large chunk?

text: I am building a web app that manipulates fairly complex data: guitar tabs.                   As a reference, guitar tabs look like this:     Eb|-------------------------------------------------------------------------|     Bb|-------------------------------------------------------------------------|     Gb|--5-5-5-5----------------------------------------------------------------|     Db|--5-5-5-5--3-3-3-3--7-7-7-7--5-5-5-5--2-2-2-2--3-3-3-3--2-2-2-2--5-5-5-5-|     Ab|--3-3-3-3--3-3-3-3--7-7-7-7--5-5-5-5--2-2-2-2--3-3-3-3--2-2-2-2--5-5-5-5-|     Eb|-----------1-1-1-1--5-5-5-5--3-3-3-3--0-0-0-0--1-1-1-1--0-0-0-0--3-3-3-3-|      Would it be more efficient for performance to store this data as a large chunk, or to break it up and store it on a "note by note" basis?               As a use case:     User changes first chord from:       to:                              Eb|---   Eb|---                              Bb|---   Bb|---                              Gb|--5   Gb|--4                              Db|--5   Db|--4                              Ab|--3   Ab|--2                              Eb|---   Eb|---      If I store it as a block, the code to manipulate the tabs would have to be much more complex. If I store it note by note, the database will have to be accessed a lot more. **Which method is more efficient?** Potentially, a lot of users will be modifying the data. I want the **best performing web app.** I will be using MySQL if that affects the answer at all.


title: How do you answer "explain current architecture of your project" question in interviews?

text: The application which I am working on currently is a bit huge. It cannot be explained in 15 minutes or so. Last time I ended up drawing some class diagrams and how they are linked, but I could see that the interviewer was not happy with the answer. What are the main things that should be highlighted when answering this question? For example, how session is managed, how persistence is achieved are few things. What are other things, which should not be missed?


title: How to optimize Cartesian product

text: Is there a better way to compute cartesian product. Since cartesian product is a special case that differs on each case. I think, I need to explain what I need to achieve and why I end up doing cartesian product. Please help me if cartesian product is the only solution for my problem. If so, how to improve the performance. ## Background: We are trying to help customers to buy products cheaper. Let say customer ordered 5 products (prod1, prod2, prod3, prod4, prod5). Each ordered product has been offered by different vendors. ## Representation Format1: Vendor1 - offers prod1, prod2, prod4 vendor2 - offers prod1, prod5 vendor3 - offers prod1, prod2, prod5 vendor4 - offers prod1 vendor5 - offers prod2 vendor6 - offers prod3, prod4 In other words ## Representation Format2: Prod1 - offered by vendor1, vendor2, vendor3, vendor4 Prod2 - offered by vendor5, vendor3, vendor1 prod3 - offered by vendor6 prod4 - offered by vendor1, vendor6 prod5 - offered by vendor3, vendor2 Now to choose the best vendor based on the price. We can sort the products by price and take the first one. In that case we choose prod1 from vendor1 prod2 from vendor5 prod3 from vendor6 prod4 from vendor1 prod5 from vendor3 ## Complexity: since we chose 4 unique vendors, we need to pay 4 shipping price. Also each vendor has a minimum purchase order. If we don't meet then we end up paying that charge as well. In order to choose the best combination of product. We have to do cartesian product of offered products to compute the total price.               total price computation algorithm:          foreach unique vendor      if(sum(product price offered by specific vendor * quantity)<minimum purchase order limit specified by specific vendor)     totalprice +=sum(product price * quantity) + minimum purchase charge + shipping price     else     totalprice +=sum(product price * quantity) + shipping price     end foreach      In our case {vendor1, vendor2, vendor3, vendor4} {vendor1, vendor3, vendor5} {vendor6} {vendor1, vendor6} {vendor2, vendor3} 4 * 3 * 1 * 2 * 2 = 48 combination needs to be computed to find the best combination. {vendor1,vendor1, vendor6, vendor1, vendor2}=totalprice1, {vendor1, vendor3, vendor6, vendor1, vendor2}=totalprice2, . . {vendor4, vendor5, vendor6, vendor6, vendor3}=totalprice48 Now sort the computed totalprice to find the best combination. ## Actual Problem: If customer order's more than 15 products.Lets assume, each product has been offered by 8 unique vendor then we end up computing 8^15=35184372088832 combination. Which takes more than couple of hours. If customer order's more than 20 products then it takes more than couple of days. Is there a solution to approach this problem in a different angle?


title: Memoization, Caching, Buffering and Page Filing?

text: I'm writing something on how iterative Fibonacci is substantially better than recursive Fibonacci - a few lines. The main reason of this I find, as do many prominent researchers I believe, is that you don't recalculate values - space vs time. From this I thought **ah ha!** caching! But I'm not sure if it is caching, memoization, buffering or one of the others. I personally think buffering to be the preloading of material before something is done with it vs caching and memorization being more of a processing based thing. The buffering notion is that I get from such a _buffering_ a picture or a video. What is the difference between buffering, memoization, caching and page filing?


title: Is there any "Set" database?

text: Is there any "set" database? For example Neo4j is a "graph" database. What I'm looking for is database which can be used to organize "items" into "sets" and then be able to query them with set operations. For example "items that are in set A and B but not in set C". Or which one of current databases can efficiently do this data modeling? Sets are not limited, they can be added/edited/removed as data, just like items or like links in a graph database. For example making a new set called D or Set2347 and add some item in it. An example would be pages liked by users, where each page is a "set" which is liked by users as "items" it contained. To clarify my question I would better quote Karl Bielefeldt comment: > The question isn't whether it's possible to use a relational database for > this use case. Obviously it is. It's possible to use a relational database > for a graph, but we have graph databases anyway which make working with > graphs a lot easier. Asking if something similar exists for sets is not an > unreasonable or unclear question, even if the answer happens to be no. Maybe > people have some good ways to make working with sets on relational databases > easier.


title: How to slow down your computer (for testing purposes)?

text: As most people agree, encouraging developers to make fast code by giving them slow machines is not a good idea. But there's a point in that question. My dev machine is fast, and so I occasionally write code that's disturbingly inefficient, but that only becomes apparent when running it on other people's machines. What are some good ways to temporarily slow down a turbocharged dev machine? The notion of "speed" includes several factors, for example:   * CPU clock frequency.   * Amount of CPU cores.   * Amount of memory and processor cache.   * Speed of various buses.   * Disk I/O.   * GPU.   * etc.


title: Problem and Requirements Definition

text: I was recently hired to redesign a management system from scratch. This is my first business-scale project. I have assisted with business applications in the past, but I am the only one dedicated to redesigning and programming the system with the assistance of a company employee. This employee built the previous version of the management system. We all agree that we want this done, and done right. I am willing to put in the time upfront to define the problem and requirements so I do not have to reap bad seeds during testing. At the moment, I am trying to capture the problem and gather the requirements for this management system. What questions should I ask this employee to be able to move forward with some documentation? I realize these requirements can change constantly, but I would like a starting point to work with. Here are a few questions I have come up with: > What is the purpose of the management system?   >  What is the problem we are trying to solve?   >  What will be the features of this system?   >  Who will be using the system? (Employees? Outside Entities?)   >  What are the means of security for this system? (Can an outside entity see > what an employee can see? etc.)


title: Using Map in Java (or other strongly-typed languages) to work with unstructured data

text: After looking at the core data type for frameworks that deal with unstructured data in java:   * json java library: JsonObject   * Mongodb java api: BasicBSONObject   * SolrJ (Solr java client): SolrDocument the common theme seems to be that data are first de-serialized into Map, then transformed into an given class by reflection.   So this raises the question, why not just work with these Map (or sub-type of map) directly? You can extend Map and create your own sub-type, and you will still have all the benefit of OO programming. **Edit** I am not concerned with the cost of deserialization, but the flexibility that Map offers when dealing with unstructured data. By this, I mean not having to define a class that the data can be deserialized into.   **Edit 2** I am more interested in the "why not (disadvantages)", since the framework I mentioned already demonstrated that it could be done.


title: Starting to be a team leader

text: After half a year working for the company, I got two students to be leader for. So, I got some technical management responsibility. As I think, I should be not just a leader, but a teacher and the one who is example. What are common steps to educate junior developers? How to be not just a boss, who gives the task, but a 'senior fellow'? Is it appropriate to give some advices which are not properly related to coding(for example, human interaction and so on). I want to be a good leader for them, but don't have any experience in that and don't know what to begin from. Thanks.


title: Client wants to resell the app I programmed

text: Not sure if this is the right forum. If it's not, please let me know and I'll move it. So I have been asked by a client to develop a RoR Web App for them. He asked me if the development is their property. I said yes, you can request the source code and database migrations anytime. Then he says "I'm asking you this, because we plan to resell the app to other branches. That's why I'm asking you if the development is ours and we have rights to resell it." So I'm thinking they do. I mean, they paid me to program for them. Is there a recommendation from any of you more experienced programmers? I'm thinking about of course, telling him he has the right to resell it, and I could help him deploying the app in more servers and cut him a web hosting deal so I can also benefit from my app being resold. What do you guys think?


title: Why shouldn't you develop on production database?

text: I need help with organizing my arguments for why it's MADNESS to develop against production data. **Backstory:** I started working here six months ago and I noticed we're developing directly against production data. The codebase is local, but the database we're connected to is live data! So i have to be super careful constantly when doing update/store operations, so that I don't break anything. We have an annual software meeting soon and I want to raise my concerns, and come loaded with arguments but I have a really hard time coming up with good solid points to something that's should be obvious as this. It's as if they would ask me to come up with arguments to why I need to breathe. **My Question:** What arguments are there for NOT developing on production database directly?


title: Safely fixing production database data

text: Bugs happen and sometimes data has to be fixed in production. What is the safest way to go about this from a big company standpoint? Are there tools that can help? Here are some considerations driving this requirement...   1. We need to log who ran the query and what they ran   2. Ideally we need to give the person access to only run queries against the tables of interest and only for a short time   3. Whatever is running the queries needs to have some smarts about it to not allow long running and locking SQL to run without explicit permission   4. This process needs to be DB agnostic or at least understand DB2, Oracle, and SQL Server. We are trying to reduce the risk of ad-hoc prod fix-up queries from doing the "wrong thing" and at the same time add some security/audtis to the process. Thoughts or Ideas?


title: How do you deal with clients asking for manual data edits in the database?

text: I've recently started working on a legacy application that frankly doesn't do all that it should. It's lacking a lot of features, has barely any administration capacities and doesn't check half the data it should. As such, it's very easy for users to do something stupid and get stuck. _"Oops, I added this item of the wrong type to this thingie and now it won't let me remove it"_. Indeed, the application should have checked for this, but allowed adding the wrong item. And now, when it comes to deleting the wrong item, it becomes extremely protective and refuses that anything be removed. Problem is, the clients (who are actually users within the company) don't care much for that. They need the application to hold the real-world data as it should be, so they ask the developers to "fix it" by changing the data. In this example, deleting the wrong item. In other cases, it will be reassigning items to different parents, fixing various values, etc... Since the application has almost no admin GUI, everything ends up being done directly in the database (augh!), risking even more issues down-the-line unless you know _exactly_ how it works (which no one really does considering the massive application). Ultimately, it feels like the database has become a huge Excel file that devs edit day by day at the whims of the clients, because of failures of the application. It's obvious to me that fixing the application to avoid such situations should be top priority, but it seems the clients prefer asking for a lot of new features instead and it's accepted as such. What can a developer do in such a situation? Is it even possible to refuse DB edits in favor of fixing things? There are so many bugs that it feels like they're never going to wait _that_ long...


title: How many ALU additions are needed to add three numbers?

text: Please give reasons for your answer. As I found, two additions are needed. This is because every number to be add needs to changed to binary. Then addition is done between two binary numbers where the XOR gate is used for addition. When a carry bit is required an AND gate is involved to add the carry bit to the next line. Therefore if more than 3 binary numbers are added together there can be more than one carry bit and the AND gate doesn't support that. Am I right or I am confusing everything and nothing make sense? Thank you for your time.


title: Reading/resources for improving architect and senior engineer skills

text: I am working on improving my architect / senior engineer skills. In particular, I want to focus on "getting lost in the weeds" - spending a lot of time on a problem while a better solution could have been achieved and "not seeing the forest for the trees" - missing the big picture and only providing part of the functionality - issues. What is some recommended reading/source material that can help me along?


title: Java Swing ActionListener design

text: I have a form that includes an area for putting in address information and a table that shows the addresses that have been added. I've separated out the ActionListener for the "add address" button on the form into it's own top level class and I'm finding it tricky and cumbersome to refer back to the form that has the text boxes and the table. From a design perspective, is it a bad idea to put the class that implements the ActionListener for the add address button as an inner class in the form class? The ActionListener class will be specifically tied to the parent form alone, so I'm figuring that an inner class might be the better route to go. I'm going to perform any business logic outside of the form class, of course...


title: Advice for transitioning into a Java developer position from doing other types of web development?

text: I've been doing web programming and currently work at a company working with mainly PHP and Javascript. For a little while now I've been becoming more and more frustrated with the shortcomings of this type of development and want to move to a company with a more defined development process that values doing things the "right way" such as using Unit tests, dependency injection / IoC, etc. I've been learning JEE / Java as much as I can on my own time but would really like to make a switch to doing this as my career and leave behind the PHP world altogether. I'm just wondering if anyone can give me advice on which things to put my main focus on right now to make myself marketable as an entry level Java developer? Basically, I feel that I'm not really learning anything new at my current job that will benefit me and its only making me more and more frustrated so I figure if there is any way to position myself for a transition I would rather do it sooner than later.


title: Creating a text input simplifaction tool

text: I have been working on a project for several months now to write a web-based tool that will help me at work. I work at a call center and the CRM software that is used is wretched, we basically have to input all of our information into notepad templates and then paste it in to a description box. My initial goal was to create a web-interface for the templates so that I didn't have to use notepad anymore. I was just going to write it with HTML5/CSS/JS, both as a learning experience and, if I was fortunate enough, an opportunity for advancement. As I worked on coding this tool I continuously found myself changing the foundation of the project, attempting to integrate more functionality in my tool. It has gotten to the point where I want the tool to be used alongside the CRM software for every call I receive. I want to be able to simply copy the customer's information off of CRM (simply with Ctrl + A/Ctrl + C), then be able to paste the block of jumbled text into a text box. The program will then pick out the customer's info by looking for keywords in specific positions to fill out a user selected template. The rest of the information is input manually and then the output is generated with the push of a button. The information will also be parsed into a backup text file. The text file will be created automatically based on the date. If the text file for the current date exists, it will simply concatenate the info. As I wrote my code I found myself getting distracted looking at different coding languages and possibilities. I kept looking back at what I had completed and I was disappointed, I've started over from scratch two times now. Now for the actual question: I am thinking of starting over, writing my program with AngularJS. I like the idea of a smooth, single page, app-like interface, but I'm scared of hitting more barriers and starting over using something else. Based on my description of how I want my program to run, can anyone suggest how to go about implementing this? Should I look into a different language, or is JS really the way to go these days? I just discovered Dart and am intrigued, but the idea of learning yet another language is discouraging instead of exciting. I feel like I'm missing a pretty big point. I hope this question is appropriate for this forum. I feel a bit lost with StackExchange, and the last thing I want to do is receive negative attention for a bad post. I'm just feeling a bit lost when it comes to this project, and perhaps even programming in general. Regardless, any feedback will be appreciated. Even direction to a forum for emotionally distraught fledgeling programmers would be a welcome answer. >.< Thank you.


title: Unit testing side effect-heavy code

text: I'm starting to write C++ code to run a robot, and I don't know how to incorporate unit testing, if indeed I can. I have been provided with a library which allows the creation of "commands" for the robot, which are automatically scheduled and executed. The mechanism to create these commands is to subclass a command base class they provide, and implement virtual `void Initialize()`, `void Execute()`, and `void End()` methods. These functions are run purely for their side effects, which do things to the robot (run motors, extend pistons, etc.). Because of this, I don't really see anywhere to attach unit tests to the code, short of mocking the entire library so that I can check the virtual before and after states of the robot. Is there a way to unit test this that isn't overly burdensome? ## Edit I think I may have been misleading about the functionality of the library. The library provides most of the interface to the robot as well as the command/scheduling system, so it's not as simple as mocking the command base class, I'd have to mock the entire interface to the hardware. I unfortunately just don't have the time to do that.


title: What's a typical team size using a Git repo?

text: We've been using Git as our version control but as the team grows, there are more and more pains when it comes to getting all our changes onto a single branch ready for a deployment. I'm wondering if maybe we're outgrowing Git as an effective collaboration tool. I know there are large OSS projects with many developers that use Git but there also tend to be some gatekeepers responsible for the merging of branches into the final build/deployment branch. In an office environment, where the developers are relatively independent and can be trusted to merge their own changes, how many people can effectively collaborate on Git? Additionally, are there any tips for effective use of Git? We've been using the rebase workflow, I'm not entirely convinced switching to a merge based workflow would improve the situation but then, I haven't seen a formal description of how a large group would work together in a merge workflow (It seems like the history would just turn into merge hell). Addendum: So that it's easy to find for anyone else wondering:   * We're using a feature branch strategy   * The code base is well organized and pretty clean. It's Python (with some HTML/JS), MVC via pyramid for the web app, separate package (different top level folder in same repo, itself split up into well defined layers) for a large chunk of the non-web specific application functionality.   * We experience pain as far as merging code because developers are frequently making changes in the same files, like, one dev owns auth, so they're touching the views, etc... related to auth, but another dev is handling internationalization, so they're touching all the views, etc.


title: What are good ways of balancing informative exceptions and clean code?

text: With our public SDK, we tend to want to give very informative messages about why an exception occurs. For example:               if (interfaceInstance == null)     {          string errMsg = string.Format(               "Construction of Action Argument: {0}, via the empty constructor worked, but type: {1} could not be cast to type {2}.",               ParameterInfo.Name,               ParameterInfo.ParameterType,               typeof(IParameter)         );              throw new InvalidOperationException(errMsg);     }      However, this tends to clutter up the flow of the code, as it tends to put a lot of focus on error messages rather than what the code is doing. A colleague started refactoring some of the exception throwing to something like this:               if (interfaceInstance == null)         throw EmptyConstructor();          ...          private Exception EmptyConstructor()     {         string errMsg = string.Format(               "Construction of Action Argument: {0}, via the empty constructor worked, but type: {1} could not be cast to type {2}.",               ParameterInfo.Name,               ParameterInfo.ParameterType,               typeof(IParameter)         );              return new InvalidOperationException(errMsg);     }      Which makes the code logic easier to understand, but adds a lot of extra methods to do error handling. What are other ways to avoid the "long-exception-messages clutter logic" problem? I'm primarily asking about idiomatic C#/.NET, but how other languages manage it are helpful as well. **[Edit]** It would be nice to have the pros and cons of each approach as well.


title: What could be the use of forking a repository in a github's organization?

text: I'm trying to figure it out some nice workflow for our company, and we have so far the main repository on the github's organization account and we all, the members of the team working on the branches of that repo. Could you please mention some advantages on forking the repo or some use, by the members of the organization? I was thinking, that for example, I could make a fork and perform a upgrade of the libraries, but someone pointed that, "what is the differences on doing it simply in another branch,without forking? Thank you in advance, for your time.


title: Changing a variable through a series of statements ... What is this technique called?

text: I'm looking at a function that that has several statements like this:               n = returnDifferentVersionOf(n);      I.e., the value of _the same_ variable `n` changes progressively several times during the course of a subroutine -- rather than a newly named variable being assigned at each change. What is the generic name of this technique (if there is one)? * * * A more full example might be (in Ruby):               # reuse same var     def cromulentize(str="")        str = "wowza" if str.empty?        str += " adios!"        str = str * 3        str.gsub!('a', 'X')        str = str[0..-3]        str.upcase     end      What is that technique called, as opposed to this one:               # uses diff vars     def cromulentize(str="")        non_empty_str = str.empty? ? "wowza" : str        adios_str = non_empty_str += " adios!"        multiplied_str = adios_str * 3        gsubbed_str = multiplied_str.gsub!('a', 'X')        spliced_str = gsubbed_str[0..-3]        upcased_str = spliced_str.upcase     end      (Note that in Ruby the value of a method's last expression is the return value.)


title: Do I need to add an index on a table with one row?

text: I'm creating a parameter table in our database. This table will have 1 row with values that are environment specific (production, development, etc). Is there any reason why I should define an index on this table? **Update**   This table is a parameter table which will be used to drive our job queue system. The table will be defined like this:               QueuePrm       LogLvl    integer       ShowMs    boolean       Restart   boolean      This table will only ever have 1 row. No other table in our system will reference it.


title: Is it advisable to ask employees to create 'work' GitHub accounts?

text: I've moved all our company Git repositories to GitHub and now I want to add employees to the projects. Since most employees already have personal GitHub accounts, I'm wondering whether I should ask them to create a _work_ GitHub account. The reason that I'm thinking of doing this is to decrease the chances of unauthorized access to our code base since their personal accounts may be well publicized through their personal activity on the site, increasing chances of targeted attacks. Furthermore, if their personal account is ever compromised it won't mean the whole company code is accessible to the hijacker. Since this will bring the burden of maintaining two accounts for the employees I'm wondering whether it is the correct approach and whether it even makes sense. I would love to hear your opinions on this. **Update** Thanks for all the useful insights. I won't set an answer as accepted because of the subjective nature of the question/answers and since I took the best points from several different answers. I have decided to go forward this way: I will remind employees that work- related GitHub e-mail notifications will have to be sent to their work e-mail accounts for practical reasons. Therefore it would make more sense to create work GitHub accounts. If they are willing to use their personal GitHub accounts and connect it to their work e-mail accounts then that's fine. _In any case_ , employees will have to agree in written form to a number of conditions tied to using GitHub. These are related to account security: choosing a secure password using a secure random password generator that is not used with any other account, not accessing GitHub through computers not owned or administered by them, etc. At the end of the day employees will have to decide themselves whether a work account makes more sense for them or not.


title: Is anything in programming truly evil?

text: So, there are a bunch of questions appearing asking is X evil, is Y evil. My view is that there are no language constructs, algorithms or whatever which are evil, just ones which are badly used. Hell, if you look hard enough there are even valid uses of goto. So does absolute evil, that is something which is utterly incompatible with best practice in all instances, exist in programming? And if so what is it? Or is it just bad programmers not knowing when something is appropriate? Edit: To be clear, I'm not talking about things programmers do (such as not checking return codes or not using version control - they're choices made by bad programmers), I mean tools, languages, statements, whatever which are just bad...


title: What is the average lifespan of a cookie

text: I am wondering if there is any research on the lifespan of cookies on users computers? For a website I'm building we are looking at giving the users some personalization based on a previous selection when they come back at a later point. However, our users mostly will come back a few months or even a year later. Of course I can set the expiration time of the cookie to a year or longer. But overtime people get a new computer, a new install, or just a new browser (version). Or there might be other changes which make the cookie be deleted. I'm guess that the cookie won't survive the length of a year. Will it be worth saving this in a cookie? E.g., how much percentage of the cookies will still be there by that time?


title: Rewrote GNU GPL v2 code in another language: can I change a license?

text: I rewrote some parts of Mercurial (which is licensed under GNU GPL v2) in C#. Naturally, I looked a lot into original Python code and some parts are direct translations from Python to C#. Is is possible have "my code" licensed under different terms or to even make a part of a closed-source commercial application? If not, can I re-license "my- code" under LGPL, open-source it and _then_ use this open-sourced C# library in my closed-source commercial application?


title: What is the role of C++ today?

text: Currently I'm an IT student and I'm wondering what is still important in C++ today, what for is it used? I completed basic C++ course in my university but I can't imagine where can I use my knowledge and in which direction should I go learning C++. In other words what should I learn to become a successful C++ programmer? Currently I'm learning Java just because I don't see clearly in which area C++ could be useful today, but I clearly know which kind of work I'll be doing as a Java programmer. But I still hope that C++ isn't dead.


title: Should we push for more JavaScript on the JVM, alongside Java and Scala? Or, if not, why?

text: With JavaScript becoming one of the most widely used languages around, I began asking myself why people do not find ways to use it extensively on the JVM. As a programmer who spends half day writing Java, and the other half, writing JavaScript, I do see a lot of potential in this. Was it just the timing that shot Scala up straight? Or the nature of the language itself. Although JavaScript and Java are fundamentally different languages, it is certainly not a problem to compile JS to Java bytecode. That's what Rhino has been doing for many years, right? Or the maybe the problem lies in the performance? Whatever it is, I would be interested to know.


title: Should a c# dev switch to VB.net when the team language base is mixed?

text: I recently joined a new development team where the language preferences are mixed on the .net platform.               Dev 1: Knows VB.net, does not know c#     Dev 2: Knows VB.net, does not know c#     Dev 3: Knows c# and VB.net, prefers c#     Dev 4: Knows c# and VB6(VB.net should be pretty easy to pick up), prefers c#      It seems to me that the thought leaders in the .net space are c# devs almost universally. I also thought that some 3rd party tools didn't support VB.net but when I started looking into it I didn't find any good examples. I would prefer to get the whole team on c# but if there isn't any good reason to force the issue aside from preference then I don't think that is the right choice. Are there any reasons I should lead folks away from VB.net?


title: What best practices should be employed in a PHP login script?

text: I am wanting to re-write my login scripts for clients websites to make them more secure. I want to know what best practices I can implement into this. Password protected control panels are in their abundance, but very few seem to impliment best practices in terms of code writing, speed and security. I will be using PHP and a MYSQL database. I used to use md5, but I see that sha256 or sha512 would be better (together with secure hash and salt). Some login scripts log the ip address throughout the session or even the user agent, but I want to avoid that as it isn't compatible with proxy servers. I am also a little behind the best practice in using sessions in PHP 5 (last time I read up was PHP 4) so some best practices with this would be helpful. Thanks.


title: Is shipping a Clojure desktop app realistic?

text: I'm currently shipping a desktop Java application. It is a plain old Java 5 Java / Swing app and so far everything worked nicely. Java 5 was targetted because some users were on OS X version / computers that shall never have Java 6 (we may lift this limitation soon and switch to a newer Java and simply abandoning my users stuck with Java 5). I'm quickly getting up to speed with Clojure but I haven't really done lots of Clojure-to-Java and Java-to-Clojure yet and I was wondering if it was realistic to ship a Clojure desktop application instead of a Java application? The application I'm shipping is currently about 12 MB with all the _.jar_ so adding Clojure doesn't seen to be too much of an issue. My plan would be to have Clojure call Java APIs: my application is already divided in several independent jars. If I understand correctly calling Clojure from Java is harder than calling Java code from Clojure which is why I'd basically rewrite all the UI (part of the UI, mixing Swing components and self-made BufferedImages needs to be rewritten anyway due to the rise of retina display), and do all the 'wiring' from Clojure. So that's the problem I'm facing: is it realistic to ship a Clojure desktop app? (it certainly doesn't seem to be very widespread but then shipping plain Java desktop apps ain't that common either and I'm doing it anyway) Technically, what would need to be done? (compared to shipping a Java app)


title: C++ Typecasting VS performance

text: Let's say we're designing a video game. We have some sprites on the map and we want to call some method of the particular sprite at some particular position. We are using _one broadly-known C++ framework_. It has an `GraphicsItem` class, and ALL our sprites are derived from it. Now, framework has a method to get a pointer of the `GraphicsItem` at any position on the map. We've got two options now:   1. Cast from `GraphicsItem*` to our `Sprite*` and call `Sprite`'s method. (We know for sure that all the graphics items on the map are instances of `Sprite`)   2. _Make some crazy things like_ Store pointers to `Sprite` in some container, iterate through them, compare address vales and get straight `Sprite*` without casting. The question is: what is the best practice in this case? I was always told to avoid typecasting because it means you've got design issues. But how can I change design to avoid typecasting here? And extra iteration over a container with a comparison is just... crazy...


title: As a student, how to answer a random question: "Is 'something' about the topic unclear to you?"

text: While attempting to make a list programming subjects/topics that were unclear to me, I was unable to come up with anything. I know I can't be clear on everything. What steps can I take to get an accurate self-assessment of my knowledge and "know what I don't know"?


title: How to communicate with a co-worker that considers frameworks a performance hit

text: How can one sell an idea like "we should use jQuery because its highly optimized and cross browser compatible" or "entity framework is cool because its neat and takes care of our model automagically" when the common response is a blanketed statement such as "jquery doesn't perform well" or "entities bring in 12 columns on a table when we only need 10"? I am a pragmatic guy that tends to trust axioms I've developed through experience (its not a performance problem until there's a visible slowdown). I don't know if there's a specific "category" that the other extreme fits into, whereas everything is a performance problem until proven otherwise...or even where to begin the communication here.


title: Do you write unit testing or TDD as a line item requirement into your contracts or statements of work?

text: If you do, do you discuss coverage, continuous integration, quality control, or anything related to the difference between unit testing, functional testing and TDD in general? If clients ask, do you simply state that you will unit test, but leave out specifics?


title: What would motivate you to do free programming work for work after work?

text: I'm not talking about working overtime for a project, but R&D, or test bed applications that benefit the company. These would become teaching tools, and eventually sales tools. I know it sounds crazy to even ask, but I'm seeing a trend in this industry with regard to rapidly changing technology, and a problem with getting programmers to bring the after hours knowledge gained in house. You would think it would spill over naturally, but I find most leads holding back because the work would then be "managed" by the company, and now the property of the company. Are there solid programs or initiatives that stimulate a back-and-forth, where you can actually bring something to the table and be rewarded for it? **EDIT** Can anyone provide additional feedback on this: _Are there solid programs or initiatives that stimulate a back-and-forth, where you can actually bring something to the table and be rewarded for it?_ There appears to be a miscommunication here, where some users are under the impression I'm trying to figure out how to get free work out of colleagues. Just the opposite is true. I want to know if there are programs that exist, or ideas that you have that would motivate you, which doesn't necessarily have to be money.


title: How can I help open source win in the future against closed systems like iPhone and iPad?

text: I would like to donate a lot of my time over the next few years to helping open source hold its own against closed systems like the iPhone and iPad in the mobile and appliance computing space. If that's my goal, what's the better strategy -- to do development work for Android or for Ubuntu? I know Ubuntu is behind on the mobile front, but they work great on netbooks and are gradually moving into the tablet space. And there are questions over whether Android is really faithful to the spirit of open source. http://www.wired.com/epicenter/2010/10/is-android-open/ Any suggestions? I'm primarily a Ruby programmer who has done a lot of iOS programming.


title: gRaphael plugin best practices

text: I'm looking for best practices when creating a plugin for gRaphael. I'm looking for something like jquery where in its documentation you have the best practices of how to write a plugin. So far I haven't found nothing so I'm starting to imagine that it just comes down to best practices with javascript and not with a particular order of the code or configurability... any thoughts?


title: Should cases be reopened for bugs, or should bugs be opened as a new case?

text: Currently at my work place we use FogBugz for managing all our features and bugs for our different web applications. When a new feature is to be added to one of our web applications, a new Case is created. For example "Create CSV Upload Form". I then work on the case recording the amount of time I've spent on it. Once this case is completed, I then resolve it, and it gets assigned back to the case opener (usually the project manager), who then closes the case. If there are any bugs with the feature, my Project Manager then re-opens the case, and assigns it back to me with a bullet point list of bugs. In my opinion I believe these bullet pointed bugs should be opened as individual bug cases, so that they can be tracked easier, and not get cluttered with the original feature case notes. My managers disagree with me stating that it is easier to work out the total time spent on the feature if its all in one case. Furthermore they believe it is less confusing for our clients as they only have 1 case number reference for the feature. However I would stress that the bugs should be dealt with as seperate cases as this is post-completion of the original case. Am I right in stating that bugs should be reopened as a new case? And what are the pros/cons of each way of managing this?


title: Is it possible to use the framework behind Metro UI to make Exposé?

text: Is it possible to use the framework behind the Windows 8 Metro UI to make Exposé-like application for Windows? I tried Mac and I really like this feature, on another side i like that I can drag the screen from the top of the screen into the Metro UI, but that is completely useless. So imagine if it is possible to use this functionality in a Exposé-like application for windows. Is it even feasible? If not, maybe at a later stage? I am a programming rookie, but it could be a fun project. Thanks in advance for any answers, suggestions and information.


title: Can I use Visual Studio 2010 Architectural features to enforce design on code, without feature packs?

text: I am studying Visual Studio 2010's architectural tools for application lifecycle management. After we have sketched some modeling diagrams, we wonder now how should be the natural workflow to convert that to architecture-compliant code. We noticed that UML Explorer tab keeps track of entities created in class diagrams, sequence diagrams and component diagrams, but not so with layer diagrams and activity diagrams. The main problem is: when the modeling is ready, how would be the expected way to convert it to a compliant code? Possible paths could be:   * "you have to manually keep track of everything";   * "you can use feature X and/or technique Y";   * "There's no way to do that without the Modeling Feature Pack"; As far as I have researched until now, everything suggests that the Feature Pack is needed, but I wonder what would be the point to have those standard modeling projects if the greatest advantages of modeling (tracking and validating development code) cannot be performed... UPDATE: This blog post shows how to use Layers Diagram of a modeling project (via Validation flag on modeling project's properties tab) to RAISE BUILD ERRORS in case a layer dependency (which can be manually created) is violated. That seems promising, and I wonder which more of these hidden features the "non-feature-packed" Visual Studio 2010 might have. Thanks for any help


title: Is there a general method to evaluate the optimality of an optimization algorithm?

text: is there a general method to evaluate the optimality of an optimization algorithm, for example an algorithm solving an otherwise NP-hard or NP- complete problem? The only method I came up so far is comparing the results of the algorithm against already known optimal solutions. If not, are there specific methods for some special problems? **EDIT** To clarify: By optimality I mean how close the result is to an optimal solutions result.


title: What differentiates the exceptional programmers from the really good ones?

text: You know who they are. They are the rock stars of programming:   * They code 10X faster.   * Their code just works.   * They not only know their primary language inside and out, but they also know how it works under the hood.   * They know the answer to most any question before you ask it.   * A few of them invented the programming principles we all use.   * And they tend to be uncharacteristically humble, as well. What is it about these folks? Is there something about their thought process that is fundamentally different from the above-average programmer? Or are they simply very talented people that work hard? To put it another way: How can I be like them? I know what I think I need to learn to be that good, but it seems like it will take me the next ten years to learn it, and then my knowledge will be obsolete.