title: Naming a class that processes orders

text: I'm in the midst of refactoring a project. I've recently read Clean Code, and want to heed some of the advice within, with particular interest in Single Responsibility Principle (SRP). Currently, there's a class called OrderProcessor in the context of a manufacturing product order system. This class is currently performs the following routine every n minutes:   * check database for newly submitted + unprocessed orders (via a Data Layer class already, phew!)   * gather all the details of the orders   * mark them as in-process   * iterate through each to:     * perform some integrity checking     * call a web service on a 3rd party system to place the order     * check status return value of the web service for success/fail     * email somebody if web service returns fail   * constantly log to a text file on each operation or possible fail point I've started by breaking out this class into new classes like:   * OrderService - poor name. This is the one that wakes up every n minutes   * OrderGatherer - calls the DL to get the order from the database   * OrderIterator (? seems too forced or poorly named) -    * OrderPlacer - calls web service to place the order   * EmailSender   * Logger I'm **struggling to find good names for each class,** and implementing SRP in a reasonable way. How could this class be separated into new class with discrete responsibilities?


title: Best practice for managing dynamic HTML modules?

text:
I've been building web apps that add and remove lots of dynamic content and even structure within the page, and I'm not impressed by the method I'm using to do it. When I want to add a section or module into a position in the interface, I'm storing the html in the code, and I don't like that:               if (rank == "moderator") {        $("#header").append('
' +           // content, using + to implement line breaks        '
');     }      This seems like such a bad programming practice.. There must be a better way. I thought of building a function to convert a JSON structure to html, but it seems like overkill. For the functionality of the apps I'm using:   * Node.js   * JS   * JQuery   * AJAX **Is there some common way to store HTML modules externally for AJAX importation?**


title: DAL vs BLL functions' return types

text: Here is how I see the main differences between the DAL and the BLL:   * The DAL directly query the database.   * The DAL **doesn't create new information**. It may execute complex sql requests, joining several tables, but the result of such a request never gives any information that wasn't already in the database.   * The BLL applies a business logic on the DAL's informations to create new informations. Now, I wonder what datatypes these layers' functions are supposed to return. For the moment, all my DAL's function return DataTable. But my BLL's functions return some class or list of class that I created. For example:   * dal.getAllPortfolios() returns a DataTable (I'm working with Visual Studio), result of a join on several tables.   * bll.getAllPortfolios() calls dal.getAllPortfolios, but return a List of Portfolio. With my public Portfolio class being in the BLL's namespace. Sometimes, the BLL function doesn't really apply any "business logic" but only map the DataTable from de DAL into a BLL's class. I wonder if this is ok. Maybe all the mapping work should be done by the DAL? If this is the case, where to put my personal mapping classes? In the BLL or DAL namespace (those classes being required in layers above the BLL)?


title: How should I evaluate new browser languages?

text: In these days there are many projects whose aim is to bring new languages to the browser by compiling them to JavaScript. Among the others one can mention ClojureScript, CoffeScript, Dart, haXe, Emscripten, Amber Smalltalk. I'd like to try a few of these out, but I am not sure what I should be looking for when evaluating these languages to see if they are suitable for production. How should I evaluate a new browser language, and what are the pitfalls I should be looking for?


title: Do ORMs enable the creation of rich domain models?

text: After using Hibernate on most of my projects for about 8 years, I've landed on a company that discourages its use and wants applications to only interact with the DB through stored procedures. After doing this for a couple of weeks, I haven't been able to create a rich domain model of the application I'm starting to build, and the application just looks like a (horrible) transactional script. Some of the issues I've found are:   * Cannot navigate object graph as the stored procedures just load the minimum amount of data, which means that sometimes we have similar objects with different fields. One example is: we have a stored procedure to retrieve all the data from a customer, and another to retrieve account information plus a few fields from the customer.   * Lots of the logic ends up in helper classes, so the code becomes more structured (with entities used as old C structs).   * More boring scaffolding code, as there's no framework that extracts result sets from a stored procedure and puts it in an entity. My questions are:   * has anyone been in a similar situation and didn't agree with the store procedure approach? what did you do?   * Is there an actual benefit of using stored procedures? apart from the silly point of "no one can issue a drop table".   * Is there a way to create a rich domain using stored procedures? I know that there's the possibility of using AOP to inject DAOs/Repositories into entities to be able to navigate the object graph. I don't like this option as it's very close to voodoo. * * * ## Conclusion First, thank you all for your answers. The conclusion that I've arrived is that ORMs don't enable the creation of Rich Domain models (as some people mentioned), but it does simplify the the amount of (often repetitive) work. The following is a more detailed explanation of the conclusion, but is not based on any hard data. Most applications request and send information to other systems. To do this, we create an abstraction in the model terms (e.g. a business event) and the domain model sends or receives the event. The event usually needs a small subset of information from the model, but not the whole model. For example in a online shop, a payment gateway requests some user information and the total to charge a user, but doesn't require the purchase history, available products, and all the customer base. So the event has a small and specific set of data. If we take the database of an application as an external system, then we need to create an abstraction that allows us to map the Domain Model entities to the database (as NimChimpsky mentioned, using a data-mapper). The obvious difference, is that now we need to handcraft a mapping for each model entity to the database (either a legacy schema or stored procedures), with the extra pain that, since the two are not in sync, one domain entity might map partially to a database entity (e.g a UserCredentials class that only contains username and password is mapped to a Users table that has other columns), or one domain model entity might map to more than one database entity (for example if there's a one-to-one mapping on the table, but we want all the data in just one class). In an application with a few entities, the amount of extra work might be small if there's no need to transverse the entities, but it increases when there's a conditional need to transverse the entities (and thus we might want to implement some kind of 'lazy loading'). As an application grows to have more entities, this work just increases (and I have the feeling that it increases non-linearly). My assumption here, is that we don't try to reinvent an ORM. One benefit of treating the DB as an external system, is that we can code around situations in which we want 2 different versions of an application running, in which each application has a different mapping. This becomes more interesting in the scenario of continuous deliveries to production... but I think this is also possible with ORMs to a lesser extent. I'm going to dismiss the security aspect, on the basis that a developer, even if he doesn't have access to the database, can obtain most if not all the information stored in a system, just by injecting malicious code (eg. _I can't believe I forgot to remove the line that logs the credit card details of the customers, dear lord!_ ). * * * ### Small update (6/6/2012) Stored procedures (at least in Oracle) prevent doing anything like continuous delivery with Zero downtime, as any change to the structure of the tables will invalidate the procedures and triggers. So during the time that the DB is being updated, the application will be down too. Oracle provides a _solution_ for this called Edition-Based Redefinition, but the few DBAs I've asked about this feature mentioned that it was poorly implmented and they wouldn't put it in a production DB.


title: Should programmers stay at the internship they had before they graduated?

text: I have heard several times from multiple people that "you shouldn't stay at the job you first arrived at as an intern before you got your BS degree". The thing I don't remember is: why not? **History:** I have been at my current company for 2.5 years as an intern (got in during the last year of community college), I transferred to a four-year university and am finishing my degree in the next 6 months. I plan to look around for a new job after I graduate (at least to just get my interviewing feet wet), but wonder if I should strongly consider a job where I currently work. **Pros:** I am familiar with the company, really love the people I work with, and am generally familiar with most software products we work on. Additionally, I have completed several projects there that I solely support (slightly better job security). **Cons:** Academically and professionally, I have a strong interest in web development which is something my current company does not do (it focuses mostly on Java/C++ computer applications). Academically, the classes I specialized in were aimed at web development (HTML/SQL/n-tier server side development/PHP/JSP/JavaScript/...). Also, the projects I implemented were developed when I didn't know several of the development patterns that I know now. If I had to re-implement them, I probably would have made some greatly different implementation decisions than I originally threw together 2 years ago. **The Big Question:** Professionally why shouldn't someone stay at their first job, especially since its pretty close to guaranteed job offer.


title: Are compilers used outside of development?

text: As far as my understanding goes, compilers are meant for developers compiling their code into executable (machine-code) files. Compilers don't extend to a client's machine or end-user system. Instead, developers just use the compiler to convert their code into machine code, which is then transported to the other machines for use as applications. Do compilers have a function outside of this process? If so, when are they used?


title: Are there pre-made commercial software licenses to choose from?

text: I currently have an open source project that is licensed under GPLv3. I'd like to dual license it, so I can offer it for commercial use. Are there any resources for choosing or creating a commercial software license?


title: How do you approach database design?

text: I am primarily a web developer and I have a couple of personal projects which I want to kick off. One thing that is bugging me is database design. I have gone through in school db normalization and stuff like that but it has been a couple of years ago and I have never had experience with relational database design except for school. So how you do you approach database from a web app perspective? How do you begin and what do you look out for? What are flags for caution?


title: Machine-Generated Data Sources for Infobright Coding Competition

text: I'm looking at entering the Infobright Coding Competition. They ask for public machine-generated data. I don't want to create my own. Anyone know where some exists? Here's what I'm looking at: http://www.infobright.org/contest/2011q1.


title: Breadth-first graph search problem

text: I thought I was doing breadth-first graph search correctly, but my instructor's grading script is telling me that my answer is incorrect. From the instructions: > Consider a breadth-first graph search on the graph below, where S is the > start and G is the goal state. Assume that ties are broken alphabetically > (so a partial plan S->X->A would be expanded before S->X->B and S->A->Z > would be expanded before S->B->A). You may find it helpful to execute the > search on scratch paper. > > Please enter the final path returned by breadth-first graph search in the > box below. Your answer should be a string with S as your first character and > G as your last character. Don't include arrows or spaces in your submission. > For example, if you believe the path is S->X->G, please enter SXG in the > box. ![breadth-first search on graph](http://i.imgur.com/gr3GuRr.png) I got and input the answer **SACBG** , which the grading script marked as incorrect. ("Your input was evaluated as SACBG, which is not correct.") Here are my steps for the breadth-first graph search on the above graph using the algorithm at http://en.wikipedia.org/wiki/Breadth-first_search#Pseudocode:   1. Enqueue the root node _S_. **Queue = [S], Path = []**   2. Dequeue _S_ and examine it. **Queue = [], Path = [S]**   3. Enqueue _S_ 's children, _A_ and _C_. **Queue = [A, C], Path = [S]**   4. Dequeue _A_ and examine it. **Queue = [C], Path = [S, A]**   5. _A_ has no children. Dequeue _C_ and examine it. **Queue = [], Path = [S, A, C]**   6. Enqueue _C_ 's children _B_ and _G_. **Queue = [B, G], Path = [S, A, C]**   7. Dequeue _B_ and examine it. **Queue = [G], Path = [S, A, C, B]**   8. _B_ 's only child _G_ is already in the queue. **Queue = [G], Path = [S, A, C, B]**   9. Dequeue the goal node _G_ and examine it. Quit the search and return. **Queue = [], Path = [S, A, C, B, G]** A node is placed in the path when it is dequeued and examined. Ties are broken alphabetically as required in the instructions. What am I doing wrong?


title: Php: Whats my next step?

text: So in college I started learning Php, mostly starting with the Larry Ullman books. I got a job at a company after, where I was able to learn some stuff from the higher up guys. Since then, I've done freelance stuff and sort of learned things as I needed to. I'm trying to figure out where to go next. I definitely want to stick with the web programming arena, and I'm enjoying concentrating on Php. I know MySQL as well, but VERY little Javascript / Ajax. I've also been reading a lot of OOP theory, and have a descent grasp of how it works, but it doesn't feel natural yet. Where should I go from here? Is it worth learning Java fort a while to really get the OOP stuff down? I took introductory Java in college, but it was only 1 semester. Or should I concentrate on some of the open source stuff (Wordpress, Drupal, JQuery, etc). How about E-commerce solutions? I have no experience with that. In terms of my goals, I don't have much plans for big, enterprise types of projects. I would mostly be interested in working freelance on websites of small, to medium size. But, I would like my coding to be as sound, and well structured as can be thanks for the help!


title: What do you call a developer with automated testing specialty?

text: Having been hired as a developer (5-6 years experience), I suggested to my employer that I also take a formal responsibility for our work with automated testing. Basically I find it interesting and stimulating to work in TDD-like ways, and want to drive this culture in the company I work in. **But, what would you call this type of job position?** I would like to specialize more in automated testing and TDD, and improve my chances of getting really interesting such jobs in the long term. So what would be a good title for this? My fear is that I would eventually come off as a QA testing engineer, which I would say is misleading since I work mainly as a developer. Suggestions: Software Engineer in Testing?   Testing Architect and Developer?   Automated Tests Developer? Anything better?


title: Concerns when designing an iPad video player

text: I've recently been asked to design a video player for the iPad. I've never done one before and I'm wondering if I could get some caveats in terms of it's development and design. Are there areas of building a video player that are particularly buggy or troublesome? What part of building one takes the most time? Generally speaking I'm just trying to get a feel of what will be the difficult part and what I'm about to get into. Thanks


title: Will real world applications ever need a 128-bit flat address space?

text: This is a bit "one megabyte should be enough for anyone", but... A 64-bit flat address space allows up to 4.3ish billion times more space than a 32-bit address space. That's 17,179,869,184 GiB. Obviously, the transition from 8 bits to 16 bits was pretty quick (I'm viewing things in a teen-during-the-80s way, ignoring all those mainframes and minis because they couldn't run a port of Elite). The transition from 16 bits to 32 bits took a bit longer, and 32 bits actually lasted quite a while. Now we have 64 bits, would it be stupid to say "17,179,869,184 GiB should be enough for anyone"? This is a programmers question because I really have the programming viewpoint in mind. Even if a computer some day has a seemingly infinite amount of working memory, that doesn't mean that applications will need to see a seemingly infinite flat address space. Basically, can we programmers breath a sigh of relief and say "well, whatever integers or floats may do, at least I don't have to worry about my pointers growing any more?".


title: Conflict resolution for two-way sync

text: **How do you manage two-way synchronization between a 'main' database server and many 'secondary' servers, in particular conflict resolution, assuming a connection is not always available?** For example, I have a mobile app that uses CoreData as the 'database' on the iOS and I'd like to allow users to edit the contents without Internet connection. In the same time, this information is available on a website the devices will connect to. What do I do if/when the data on the two DB servers is in conflict?   (I refer to CoreData as a DB server, though I am aware it is something slightly different.) Are there any general strategies for dealing with this sort of issue? These are the options I can think of:   1\. Always use the client-side data as higher-priority   2\. Same for server-side   3\. Try to resolve conflicts by marking each field's edit timestamp and taking the latest edit Though I'm certain the 3rd option will open room for some devastating data corruption. I'm aware that the CAP theorem concerns this, but I only want eventual consistency, so it doesn't rule it out completely, right? Related question: Best practice patterns for two-way data synchronization. The second answer to this question says it probably can't be done.


title: Is there a proper way to allow access to private list by reference?

text: I'm trying to provide a by-reference getter to a list of objects in a class. My setup looks something roughly like this:               class c_Container     {     public:         c_Item* Get(int uid);     private:         c_Item itemList[10];     }          class c_Item     {     public:         int uid;     }          c_Item* c_Container::Get(int uid)     {         for (int i = 0; i < 10; i++)         {             if (itemList[i].uid == uid)             {                 return &itemList[i];             }         }              return NULL;     }      This is a simplistic example showing usage, usually a c_Item object would have other methods that would do other things. We'd want to obtain the c_Item object from itemList by reference or by address so that we can directly modify it. When compiling, I get a lint error something like "Exposing low access member 'itemList'". If I try to return by reference instead of returning a pointer, I get the same thing. I guess I understand why, but I can't conceive of a better way to obtain an object from a container class like this by reference. I can fix the error by making itemList public, but that seems like unnecessary access. Outside of creating wrapper methods in c_Container for all of c_Item's methods (which seems redundant), is there a better way to handle a situation like this?


title: Duck typing in statically-typed languages

text: Is it a fair assumption to say that an overloaded constructor for a class can be thought of as a 'duck' for duck typing? Let's say that ClassA has an overloaded constructor, it would stand to reason that the different constructors are there for a reason -- the object is being used in a manner that indicates all of its properties do not have to be set for the object to perform correctly. So, I ask, is an overloaded constructor a duck?


title: What are good reasons to drop Windows XP support?

text: Recently the software team in my company decide to use VS2012 (upgrade from VS2008) but we found out that VS2012 does not provide a nice support for Windows XP (e.g. really hard to deploy .Net 3.5 managed C++ project). So we want to convince our manager to drop Windows XP compatible development and and target Windows 7 only. This allows us to use some new technologies such as .Net 4.5 (we are using 3.5 ATM). But we have many existing customers are using Windows XP and they will not able to upgrade to new version of our software (we may still provide bug fixes for XP though). So what are some good reasons to use VS2012 and drop XP compatibility? What in my list currently:   * Able to use .Net 4.5   * Use VS2012 (without compile some project using VS2008 tool chain)   * No need to test on XP machine


title: Is there a concept of a variable with phases of initialization: uninitialized, initializing, immutable?

text: I was looking at this thread on Stack Overflow and thinking about the functional programming I've been learning, and how immutability is so key there, and it occured to me that maybe some language has gotten the idea to have variables start out "null", then go to a "building" state, and finally become the same as any other immutable when initialization is done. Is this a valid concept and/or has it been tried or experimented with at the language level? It might look something like this:               string s new String(); // empty strings start out mutable     for x = 1 to 10       s = s + "z"     s.Freeze() // now it's immutable      It's just a thought.. maybe it's not a good one, but it seems like a hybrid of two things that seem to be opposing one another.


title: Session Management in distributable web-apps

text: I am working on a huge web application in which I need to add transparent failover feature. I understand the necessary steps to make a web application distributable, the most difficult thing being: to ensure that the objects stored in the session are serializable. I want to know which type of variables exactly should I store in the session? e.g. just login info or other things too. The web application is actually a gateway to numerous other smaller applications like generating business reports, setting calander etc. So will I have to make those other applications also serializable or just the logon application will suffice ? I am new to web development so excuse me if the question is trivial.


title: Push-Based Events in a Services Oriented Architecture

text: I have come to a point, in building a services oriented architecture (on top of Thrift), that I need to expose events and allow listeners. My initial thought was, "create an EventService" to handle publishing and subscribing to events. That EventService can use whatever implementation it desires to actually distribute the events. My client automatically round- robins service requests to available service hosts which are determined using Zookeeper-based service discovery. So, I'd probably use JMS inside of EventService mainly for the purpose of persisting messages (in the event that a service host for EventService goes down before it can distribute the message to all of the available listeners). When I started considering this, I began looking into the differences between Queues and Topics. Topics unfortunately won't work for me, because (at least for now), all listeners _must_ receive the message (even if they were down at the time the event was pushed, or hadn't made a subscription yet because they haven't completed startup (during deployment, for example) - messages should be queued until the service is available). However, I don't want EventService to be responsible for handling all of the events. I don't think it should have the code to react to events inside of it. Each of the services should do what it needs with a given event. This would indicate that each service would need a JMS connection, which questions the value of having EventService at all (as the services could individually publish and subscribe to JMS directly). However, it also couples all of the services to JMS (when I'd rather that there be a single service that's responsible for determining _how_ to distribute events). What I had thought was to publish an event to EventService, which pulls a configuration of listeners from some configuration source (database, flat file, irrelevant for now). It replicates the message and pushes each one back into a queue with information specific to that listener (so, if there are 3 listeners, 1 event would become 3 events in JMS). Then, another thread in EventService (which is replicated, running on multiple hots) would be pulling from the queue, attempting to make the service call to the "listener", and returning the message to the queue (if the service is down), or discarding the message (if the listener completed successfully). **tl;dr** If I have an EventService that is responsible for receiving events and delegating service calls to "event listeners," (which are really just endpoints on other services), how should it know how to craft the service call? Should I create a generic "Event" object that is shared among all services? Then, the EventService can just construct this object and pass it to the service call. Or is there a better answer to this problem entirely?


title: Is discoverability for developers a problem when using SOLID principles?

text: I do line of business apps where the all the other developers are used to doing basic CRUD apps or are focused solely on making pretty/functional interfaces and I am getting the following a lot. "With the way we use to do it Employee would have all the things you could possibly do with an employee." And it was true. That one "Class" had thousands of lines of code and anything you could do with an employee was there. Or, even worse, there was a table of employee data and each developer figured out how to do what they wanted to do in the event handler. All the bad things about that approach was true but at least the developer using employee could, without going to other documents, figure out how to enroll the employee in a health plan, give a pay raise, fire, hire, transfer etc. Same goes for Manager and all the other major ideas. Or, if they used the employee other needed data tables, could just do what they wanted. Yes, there was much duplicated code. Yes it was very brittle code. Yes testing it was way more difficult than necessary. Yes changing functionality was fear inducing and Copy Paste was a natural due to the approach. But they could at least discover what was available by creating one class or they could do what they need to get done without having to understand the difference between interfaces, abstract classes, concrete classes etc. And they didn't have to search anything other than the methods returned by intellisense or know the tables where the data resided. I have googled/binged and even yahoo!d but I haven't found any acknowledgement of this problem. So maybe there isn't a problem and I am just missing something. I have racked my brain trying to figure out a solution where the developer(s) that do not work the actual behavior/design can easily discover how to do something without having to reference any external documents or scan the class names in the various components/projects to find the one that sounds like it will work. The only thing I have been able to come up with is have these, for lack of a better name, "Table of Content Class" that does nothing more that return the actual classes (and really most of them are interfaces but they don't know the difference or even care) that other developers can use to perform the actual tasks desired. Still end up with really big classes but there is almost no behavior in them. Is there a better way that doesn't require intimate knowledge of the middle tier where the actual implementation of SOLID takes place? Basically what I am asking is there a way to allow CRUD type developers continue to be CRUD developers in a very complex system


title: C++ compiler structures such as Virtual method Table etc

text: I am aware of the C++ Virtual Table which allows dynamic dispatch for doing things at runtime (although if I am honest I am not completely sure of the full list of things it achieves). I am wondering what other "low level" aspects of C++ are there, which one doesnt usually come across when learning the C++ language? Things like: -How is multithreading and locking on objects performed? -Overloading/overwriting functions -Generics Are there other "structures", similar to the vtable, which assist with these types of things on a lower level? (and if anyone can help with what the VTable actually does it would be most appreciated!)


title: Master page design (reloads on new page)

text: Ive been building a website with 2 pages and 1 master page. The master master page works as a "Menu". The two pages inherits from the master page and have some content on them. On Page1 I have a link to Page2. Once I click on the link Page2 (and master page) loads. Pretty straight forward I guess. But my question is now:   The master page ofcourse reloads everytime I go to a new page and thereby the entire site "flicks" for short moment to switch to the next page. Is there some "best practice" for keeping the master page(the menu) on the page while only loading the content? I still want to split the two pages up in Page1.aspx and Page2.aspx and not having all my content in 1 page with panels showing the content of page1 and another panel showing the content of page2 etc.   Should I use some sort of control that has the pages inside them or is this just a stupid question and I shouldnt be bothered by the entire page flicking as this is just normal "web behaviour"? Hope you can help :)


title: What do neglected O'Reilly book topics tell us about that topic?

text: Does anybody know how O'Reilly chooses topics to publish? For some reason, I don't see how it can be based on demand. The reason, I ask, is because they haven't published a Delphi book in almost 12 years and Object Pascal is at least as esoteric as Erlang and as practical as PHP and as robust as C++. So, maybe someone knows what rationale is behind O'Reilly's publishing methodology or what it is supposed to tell us about the relative popularity or usefulness of any given language or programming technique? Oh, I forgot about pig and robotlegs


title: Compress range of numbers into blocks of used or unused

text: Given a numerical range and a list of used numbers that fall within that range I need to compress the range into blocks of used and unused numbers. For example:               range: 0 to 10     used:  3,4,5,9      I need an output like               0-2: free     3-5: used     6-8: free     9:   used     10:  free      Not sure where to start with this, so any guidance appreciated.


title: How to organize repetitive code?

text: My team creates a lot of one-off web forms. Most of these forms just send an e-mail, and a few do a simple database write. Right now, each form lives in its own separate solution in Visual Studio Team Foundation Server. That means we have close to 100 different form projects, which makes it difficult to maintain consistency. Each form is unique in that the fields are different, but all of them do pretty much the same thing. I'm looking to condense these somehow, and I could really use some guidance.   * Should I try to create one solution file with all of our form projects in it? There isn't a lot of plumbing code, although I could create a few helper classes to help with e-mail formatting and such. It would be very helpful to be able to share CSS, JavaScript, controls and images across projects.   * Given that we're a Microsoft shop, are there any tangible benefits to going with something like MVC over Webforms for this specific scenario? I am sold on the concept of MVC as a whole, but would it help me pull together a 15-field data collection form more efficiently if all that form does is send an e-mail? The form that got me thinking about this had a good bit of logic built in to show and hide fields based on the user's responses and seems like it would have been less efficient to use MVC and jQuery.


title: Pattern for mobile app data synchronisation using HTTP over 3G networks

text: I have a mobile app built using jquerymobile, PhoneGap and some custom CSS and JavaScript. The data objects are received in JSON and used to display different forms to the user. For example               { id: 1, type: personal_details, question_1: "First name", question_2: "Last name" },     { id: 2, type: work_details, question_1: "Occupation", question_2: "Experience" }      The user fills out these forms and sends the data back to a .NET application. Things work great when there is a good 3G connection but that is not always the case. As each form is sent there is a danger that not all the forms will make it back together. In our example the personal details could be sent first, the connection is lost and the work details are left on the mobile device or lost on the network either of which frustrates my users. What is the best strategy to handle and recover elegantly from network failures? Relying on the HTTP response codes doesn't seem to be working. E.g.               for ( form in forms ) {         $.ajax({             url: 'http://ac.me',             data: form,             success: function (){                 // delete from localStorage             },             error: function (){                 // show error message 'try again later'             }         });     }      The request can fail and the error function is never called. The alternative I see is sending all the forms in one JSON string but I am concerned about the performance implications of SQL server processing many short requests or fewer longer requests.


title: Derived Classes and namespaces

text: I am deriving a class, for use in my application, from a class provided by another group. Should the derived class be in the namespace for my application or the namespace of the parent class? While I am extending the class to add features I need, the added features are not specific to my application. The project that contains the parent class is also rarely updated so there is a chance my additions would never be picked up... Maybe none of this matters.


title: Would it make sense to add parameters of an inferred type to inheritance?

text: I'll write this in PHP (where this thought originated), but this is generic to any object-orientated language. Basically, this is an addition to abstract classes that defines the implementation of its subclasses. Obviously, this could never go into interfaces because it defines how classes will be implemented, an immediate contradiction. Here are two examples:               class Boat { }     class RowBoat extends Boat { }     class MotorBoat extends RowBoat { }     class Yacht extends MotorBoat { }          class Screwdriver { }     class SoftScrewdriver extends Screwdriver { }     class PhillipsScrewdriver extends Screwdriver { }          abstract class Parent {         public child function useScrewdriver(? extends Screwdriver &$screwdriver);              public child function canOperateSimpleBoat(? super Yacht $yacht);     }     class Child1 extends Parent {         public function useScrewdriver(SoftScrewdriver &$screwdriver) { }              public function canOperateSimpleBoat(RowBoat &$rowBoat) { }     }     class Child2 extends Parent {         public function useScrewdriver(PhillipsScrewdriver &$screwdriver) { }              public function canOperateSimpleBoat(MotorBoat &$motorBoat) { }     }      I used Java bounded type parameter syntax to represent how the abstract methods would work. What do you see as the positives and negatives of this language element? **EDIT:** It turns out that this is actually a solely PHP issue that I tried to make into a larger OOP idea. I've continued it here: http://stackoverflow.com/questions/21919069/what-version-of-php-allows-type- hints-to-override-typeless-identifiers/


title: What are some good ways for an intermediate programmer to build skills?

text: Preface: I work mostly in Python, and Web Dev languages (HTML, CSS, Javascript and Jquery, PHP) I'm proficient at coding but I want to get better. In larger more advanced projects my programming skills break down. The more code there is the more trouble I have fitting all the pieces together. I understand syntax well, and I can catch and correct errors fairly easier. But the more advanced it gets the more I struggle. I believe I have a good understand of the basic and nuts and bolts of programming and I understand what's going on, but when it comes to larger projects, especially ones with heavy math involved my confidence flags and I start making mistakes. It's not that I can't do it, I'm just not used to doing it. Does anyone have any advice for someone who knows programming, but wants to get better? The only tutorials I can really find are beginner basic type stuff. Basically what I'm saying is I want to be confident when I'm tackling advanced projects, but I can't because I have little experience dealing with difficult situations.


title: PHP framework most similar to ASP.NET MVC3?

text: I've done a bit of work with CodeIgniter and a lot with straight PHP... I had the opportunity to use asp.net mvc3 recently and was absolutely blown away with my productivity. Despite not "knowing" the framework, the combination of scaffolding + intellisense + code generation through the context menus left me feeling just as productive with asp.net as with PHP. I've evaluated YII, CakePHP, symfony (a long time ago, pre 2.0), and Kohana... and while YII seems most promising none quite matched up to my experience with mvc3.


title: How do I learn modern C?

text: I started programming about 20 years ago with the first edition of the book C for Dummies. It was a great introduction to code and I am now a professional software developer. However, these days I work with higher level languages most of the time (e.g. Ruby, PHP, Java, and lots of web stuff). I would like to revisit C but I know that a lot has changed, and two new standards (C99, C11) have come out since then. I would like to learn about the new features but I am mostly interested in writing portable code that I can write higher level language bindings for in some other language. Are there any good books or websites that talk about:   * What standard to target   * The differences between the standards   * Caveats in the standard libraries (like I understand these days one is supposed to look for buffer overflows when dealing with strings, etc.)   * UTF-8 support   * Commonly used libraries, like STL or Boost for C++ And anything else I might be missing.


title: How big is the gap between what you learn in CS curriculums and what you need in real life projects?

text: I'm in my last year in a 4 year CS curriculum and I would very much like to contribute to a FOSS project. Unfortunately, I feel that there is no way I can do useful coding, whether it is bug fixing or feature developing. The C/C++/Java projects we undertake at school are trivial compared to coding for serious projects and when I read the source code of a FOSS project I'm completely at loss. Do you agree there is a gap between CS education and actually programming for a real life project? How big do you think that gap is and how does one overcome it?


title: GitShell, how can I not type the username and passwords?

text: ![enter image description here](http://i.stack.imgur.com/zYKdJ.png) Open the CMD, and I should type the password and usename? In the GitShell opened by shortcut, I don't need to type the username and password. Related is here: How can I convert GitShell's commands into an .bat file? Is this useful, I cannot make it take effect now? http://stackoverflow.com/questions/6031214/git-how-to-use-netrc-file-on- windows-to-save-user-and-password


title: Should a surrogate key ever be exposed to a user?

text: Often in a table that has no natural key, it is still useful for users to be able to have a uniquely generated identifier. If the table has a surrogate primary key (and in such a case you would certainly expect it to) should that key be exposed to the user or should another field be used for that purpose? One reason not to expose the surrogate key is that now you can't do operations that preserve the relationship between records, but change the key values, such as certain kinds of deletion/re-insertion, many methods of copying data from one database to another, etc. The main advantage of exposing the surrogate key is the simplicity of using a field you have anyway. Under what circumstances is it better to directly expose the surrogate key to users?


title: When to bail on a proposed solution?

text: Here's a *hypothetical* issue. There is a performance issue in the current release. Its difficult to find the cause of this issue because the performance tests haven't been run in roughly 10+ releases (with anywhere from 10 - 100 changes per release). My idea is to automate the process of running the performance tests in each release. However, this automation took a bit longer than expected to get running. My (again *hypothetical*) response to the automation taking too long would be to simply perform the tests manually, and then run through the results with a set of scripts that I'd already written. In the end, this automation would be SOO beneficial to have, but it _could_ take longer than is normal for a task to be completed. Is that the right response to what could feel like a rapidly diminishing ROI on a proposed solution?


title: How detailed is the estimate you show your customers?

text: For custom software, when you are giving your customer an estimate, how much detail do you tend to include? Do you:   * break it down into small tasks that can be done in a few hours and give them the full list?   * give them one big number and work towards that? And if so does that come from a more detailed estimate that you don't need to show them?   * Do you break it up into big "phases" and give them a number of hours for each phase? This isn't for fixed bid contracts or anything, just more of a "We think this will cost you X hours at $Y an hour" kind of situation.


title: Where do you find motivation when working for someone else?

text: This answer to one of my recent questions got me thinking about something that's been (mostly subconsciously until recently) troubling me throughout my programming career. Basically: _where do you find the drive to stay focused and motivated when working for someone else?_ Now to explain how this is specific to programming (or at least to the specific kind of crafty knowledge work that programming is): lots of types of work are relatively straight forward in terms of goals. You either finish a task, or you don't. In programming, it really matters how switched on and motivated you are - but at the same time - a decent programmer can quite easily coast and get enough done not to get fired, while still be relatively unproductive, unhappy, unmotivated, and nowhere near their potential. This is basically what happens to me in any regular programming job (I've had four so far, 10 years into my career): I start out fresh, all excited about working at a new company, getting my hands dirty with a new codebase, learning a new domain, etc. The first few months are great. All excited and motivated, everything is just clicking. Then, once things are more routine and familiar, it's like my subconscious slowly starts to revolt against the "slavery" of it - as explained in the answer to my other question. I seem to come to a conclusion (on a deep, mostly subconscious level) that taking ownership of major/complex tasks is just way too much effort and stress. It slowly degenerates to the point where I'm working (more or less) just hard enough not to get fired (and I've never been fired). The underlying thought process (subconscious - but I've identified it now) is something like this: being fully switched on and taking ownership of major projects takes an order of magnitude more effort and stress than coasting along just hard enough not to get fired. On the flipside, the rewards for being one of the company rockstars are in most cases borderline insulting. Maybe a slightly bigger Christmas bonus than an average worker at the company. Maybe stock options worth a couple of months salary after many, many years of extreme effort, voluntary overtime and stress. Basically, the effort and stress feels extremely non-commensurate with the reasonably expected possible rewards and recognition. So I easily go into this kind of unfulfilled, coasting "salary slave" mode (think Peter Gibbons from "Office Space"). As the answer to my other question said, the answer is in startups (or in general in doing your own thing), but I'm curious to know if there is a secret to maintaining great motivation even in a standard job working for someone else, even on on stuff that you feel no deep personal interest in. I've worked with great rockstars and gurus over the years - who could somehow stay very focused and motivated even on jobs which they said they hated. They somehow bridged the gap and seemed to find motivation for what seemed like no reward to me. And it can't be personal purpose (they said quite directly that the job is "working on a boring business system" and they'd be outta there if they won the lottery) and it can't be family responsibilities or purely money (many were single and living with not-very-materialistic values).


title: How should I unit test a bitmap modifying method?

text: My `Sprite` class has a method: `private void updateWithBitmap(Bitmap b, int x, int y)` This will 'lay on top' the bitmap that's passed in, the top left corner of the passed in bitmap being at the x,y position of the parent bitmap. Now I want write unit tests to check that this method is working correctly. For example, we'll need to check that an exception is thrown when the passed in bitmap is larger, or is out of bounds of the parent bitmap.                   [TestMethod]         [ExpectedException(typeof(System.ArgumentOutOfRangeException))]         public void TestUpdateWithBitMap_SmallerParent_ThrowsOutOfRangeException()         {            Sprite parent =  new Sprite(new Bitmap(10,10));            Bitmap child = new Bitmap(20, 20);             parent.updateWithBitmap(child,0,0)                   }              [TestMethod]         [ExpectedException(typeof(System.ArgumentOutOfRangeException))]         public void TestUpdateWithBitMap_PassedBitMapOutOfBounds_ThrowsOutOfRangeException()         {             Sprite parent =  new Sprite(new Bitmap(10,10));             Bitmap child = new Bitmap(3, 3);              parent.updateWithBitmap(child, 9,9)                   }      Good so far. But also we want to test that the method genuinely is updating correctly. ![enter image description here](http://i.stack.imgur.com/51ZA6.png) For example, if the left most image is our parent bitmap, and the middle is the child bitmap, and we call our method with: `parent.updateWithBitmap(child, 3,3);` we get the rightmost bitmap as a result. The question is: Is it appropriate to store these bitmaps as resources, and then check the results are equal? eg.                   [TestMethod]                 public void TestUpdateWithBitMap_UpdatesCorrectly()         {             Sprite parent =  new Sprite(Properties.Resources.TestBitmapParent1);             Bitmap child = Properties.Resources.TestBitmapChild1;              parent.updateWithBitmap(child, 3,3)             #something like Assert.Equal(parent.getBitmap(), Properties.Resources.TestBitmapResult1);                         }


title: What does the static keyword do here?

text: **Can anyone explain this piece of code?** **CODE1**               int &fun()     {         static int x = 10;         int &b =x;         return b;     }     int main()     {         fun() = 3;         cout << fun();         return 0;     }      **Output: 3** **CODE 2**               int &fun()     {         int x = 10;         int &b =x;         return x;     }     int main()     {         fun() = 3;         cout << fun();         return 0;     }      **Output: 10**


title: Is it normal for programmer to work on multiple projects simultaneously

text: On a current job I have 2 projects to work on. First is very huge system and the second one is smaller but it also big (first project is being developed for 12 years, second for 4 years). At first I was working only on first project and was trying to get used to it. Then I was moved to second project and tried there, so my knowledge about first project became shady. Now I have to work on both projects at the same time. It's very hard for me because despite they both use java, they use different frameworks and the amount of code and business-logic to understand is very big so I really can't hold both that projects in my head. Is it normal and I should get used to it, although my expertise became very squashy, what won't happen if I would work only on a single project? Or should I raise a concern or maybe change employer?


title: Zero-knowledge code hosting?

text: In light of recent revelations about widespread government monitoring of data stored by online service providers, zero-knowledge services are all the rage now. A zero-knowledge service is one where all data is stored encrypted with a key that is not stored on the server. Encryption and decryption happens entirely on the client side, and the server never sees either plaintext data or the key. As a result, the service provider is unable to decrypt and provide the data to a third party, even if it wanted to. To give an example: SpiderOak can be viewed as a zero-knowledge version of Dropbox. As programmers, we rely heavily on, and trust some of our most sensitive data - our code - to a particular class of online service providers: code hosting providers (like Bitbucket, Assembla, and so on). I am of course talking about private repositories here - the concept of zero-knowledge does not make sense for public repositories. My questions are:   1. Are there any technological barriers to creating a zero-knowledge code hosting service? For example, is there something about the network protocols used by popular version control systems like SVN, Mercurial, or Git that would make it difficult (or impossible) to implement a scheme where the data being communicated between the client and the server is encrypted with a key the server does not know?   2. Are there any zero-knowledge code hosting services in existence today?


title: How to evaluate moving to Team Foundation Server

text: My development team presently uses the following software in our workflow:   * JIRA   * Bamboo (Atlassian continuous integration)   * Greenhopper (Atlassian agile project management)   * Confluence   * Git, hosted on BitBucket   * Visual Studio 2012 As you can see we are quite heavily invested in the Atlassian ecosystem. We are considering a move to TFS so we can get the niceties of advanced Visual Studio integrations such as code reviews and more importantly the Microsoft Test Manager. My previous experience with TFS was with 2005 or 2008 (I can't remember) and I have bad memories of it, although not quite as bad as my time with ClearCase. What criteria should we be looking at in order to properly evaluate our move to TFS?


title: Upgrading an app to support iOS5, 6 and 7

text: We are looking at an app that needs an upgrade. Currently it runs on iOS4, 5 & 6\. The upgrade will move to iOS5, 6 & 7\. It will also involve some UI changes and new features. I've been reading stuff on iOS7 and looking at things like auto-layout. What we are trying to figure out is the best way to handle the differences between the various iOS versions. Auto-layout seems like a good idea, but it's not available on iOS 5. There are also API changes to consider between all 3 versions and other new features of iOS7. So the questions:   1. How would you handle auto layout given iOS5 does not have it?   2. Are there any significant differences between the SDKs that you think would cause issues?   3. Would we be better off with separate code bases?


title: What is the history of the C compiler?

text: When we say that "Dennis Ritchie developed C language", do we mean that he has created a compiler (using an 'already' developed other language) which can compile the source code written in C language? if yes, what was language he used to write first C compiler? I understand a compiler is a program and we can create another compiler for C language using presently available C compiler. Is that correct?


title: Can I use MIT license to give some of my previous written code to employer so that I protect myself and don't lose my copyright?

text: My situation:   * I have written a framework before I started my new job. I own the copyright.   * It has a bunch of boilerplate logic inside of it, like any piece of software. (duh!)   * I don't want to use the whole framework in my new job, but **I do need to re-use some parts of it** in a similar framework that I am building for my new job.   * It is impractical to re-implement / re-think all the logic from scratch. It is a lot of logic and logic is logic, you can't make it much different. For example, how many different versions of a HashMap can you code? I bet they will be very similar and the third version can claim that you violated the copyright of the first version. :(   * It is impractical to try to re-invent the API. Can you re-invent the API of a HashMap? Maybe you can change `put(k,v)` to `add(k,v)`, but not much more than that. My idea to protect myself and my previous code: I will tell my employer that I am building the new framework based on a previous one that I have written under the MIT license. So in the future if I use my previous framework someplace else, **or even another derived version of it** , that has some pieces of code similar with this new framework I am building now for the employer, they won't be able to say I am using their code, the one I wrote for them. My questions:   * I am not distributing my code to anyone. I don't have to distribute my MIT licensed code to anyone, if I own the copyright, correct? I mean, can someone request that I release my code that I now claim it is under MIT license? It would not be the end of the world and I would certainly agree to do that under a legal threat.   * Does this strategy make any sense? My final goal is to be able to use a derived version of my previous coded framework without losing the copyright to it. At the same time, i do not want to distribute this code as an open-source project to anyone. I have other open-source projects, that I freely distribute, but this one I would like to keep it to myself so I can use on my jobs (not contractor jobs). It is like **claiming that you have a framework under the MIT license, without actually distributing and/or showing to anyone**. If it is out there, free and easily available, my employers don't need me anymore. They can just take the code and give it to someone else to use it. Notes:   * I have listed this framework as a previous invention before I started the job.   * I have not released this code anywhere. It is on my private SVN repo I host in my private server. My idea in a nutshel:   * My plan is to keep the previous code to myself, use parts of it in this new framework I am building for the employer and **tell the employer it is work derived from a MIT licensed framework I have coded before and have not distributed to anyone** ". I am not forced to distribute a software I coded under MIT license, am I? If later, some legal claim happens (hopefully not), i can immediately paste the license on all the sources and show/release the code.


title: What's a good format for documenting hundreds of data feeds?

text: Several governments are starting to publish **open data** : datasets generated by the goverment, made freely available for citizens to use for value-added app development, analysis, and feedback. For instance, the City of Vancouver (Canada) Open Data Catalogue publishes 130 datasets. The subject matter ranges from tabular files of city councillor contact information to geographical datasets of zoning districts. Formats range from Comma-Separated Value (CSV) to SHP to KML and beyond. It would be nice for each of these open data portals to have a dataset of datasets: their catalogue of datasets in structured data file form. The catalogue dataset should have metadata describing each dataset (name of dataset, URL of download page, the formats the dataset is available in, maybe a description of the dataset format and attributes or URL to same. What is a good data model and a good format for such a catalogue dataset? If this is a solved problem, I'd like to suggest that Vancouver reuse that solution, instead of inventing one. **Update** : in response to the question, why is it desirable to to have a catalogue as a structured dataset, I can think of three classes of use case.   1. Analysis across all the datasets of a data provider. It is convenient to get a list of all datasets, with links to descriptions etc., which I can import into a spreadsheet and annotate. Someone else may want to count total number of records published, or breadth of government activity covered by the data. In my case, I'm working on a _Vancouver Open Data language census_.   2. Analysis of corresponding datasets across multiple data providers. For instance, one might want to aggregate a list of all zoning boundary datasets published by Canadian cities. That is easier if one can sift through dataset lists by machine instead of by hand.   3. Analysis of dataset catalogue change over time. It might be interesting to analyse the growth in Open Data from one year to the next. Structured catalogues make this easier to automate.


title: What are the best algorithms out there to retrieve data from a file system?

text: This is my usecase: Traverse a filesystem, gauge its entire size and then upload it to Dropbox. Looks quite easy and is quite easy. Now if I do it using celery and spawn a thread for each folder(With sub files), then it becomes an easier process to gather all the data and gauge the size and then upload it to dropbox. But I feel I'm doing something wrong here. If I implement this on a server, I'm surely overloading it by spawning a thread for each folder that is out there. Hence, what algorithms should I use to make this a faster process? Both as a data retrieval and data uploading. Links/References would help.


title: Setting up a development environment in the cloud?

text: I'm interested in transitioning my development environment onto the cloud. I currently use VirtualBox with Vagrant to manage separate virtual machines for each individual project. What would be the optimal setup for hosting these virtual machines in the cloud? Given than I have nearly a dozen VMs, setting up separate EC2 instance for each one is not economical. A cheaper option might be to snag a low-end VPS from one of the many cheap VPS providers out there. The downside, aside from reliability, is that I don't need all my VMs available to me at all times. For example, VMs that I use as my staging environments only need to be on a few times a week at best. As an alternative, I've thought about running VirtualBox and Vagrant on a powerful box with enough memory to support multiple machines running simultaneously. Is this a smart setup, or are there caveats I have not considered? As a side note to the aforementioned option, is there an alternative to VirtualBox that would be a wiser choice?


title: Assigning a local id to a user

text: I am creating a soap service where users will be able to interact with each other. They will have a contact list where people can be added. One of the security measures(others are in place, too) is to have a local ID assigned to a contact. To make the process clear, imagine the following scenario: $UserA prompts $UserB to be added to $UserA's contact list. $UserB accepts and $UserA receives a local ID to use as UserID referring to the contact. The database contains a table called USER_MAP(LocalID,UserID). Two questions: 1) Do you think this is a valid approach when dealing with user ids security? If not, why? 2) If you deem it valid, can you suggest a formula to generate said IDs? At the moment, the idea for the formula is: ($UserA_ID+$UserB_ID)*($UserA_RegDate+$UserB_RegDate) Consider RegDates as being in "number of days since the 0 date value". Each user might have 1..N local ids depending on how many users are willing to add. A local ID is local to the user but global in the user space, i.e. for every interaction between users the same local id is used. To make it clearer: if $UserA requests to see $UserB profile, he will be passing the local user id which will be mapped at the server level to the correct id. Just to make it clear: future does not mean "in a long time from now, maybe, who knows", rather means : "it is planned, I want to do it, I want to make sure I have my pieces ready and THEN I will do it" :) Thus, it's not a "maybe" rather just a matter of WHEN. Apparently someone has issues understanding the logic behind the approach of a local id. A couple ideas that can help you understand why it's a good idea(in my opinion):   * If your ID is local instead of global, you have _only_ access to your own resources/contacts. Useful for instance to avoid programmatically getting access to a profile you wouldn't be allowed to see. This with third parties _may_ be a problem, especially in case of unfair uses   * If your ID is local, you can use it as a shortcut for local data instead of having to go to the original account. The contact list could, for instance, hold some of the original data which isn't going to change.   * If you have a local id it's much easier to "cut the wire", because all you have to do is deleting one or two records. Say that a user wants to delete a contact. All I will have to do is to remove _at best_ two records, all the other data stays there untouched and simply filtered out by the queries. Better now? Thank you for your time!


title: What use is a non-zeroing weak reference?

text: When reading about the various options for working with things like ARC / GC, I often come across explicit wording about which weak references are zeroing (ie, your reference becomes nil/null/0 when the object is collected) and which non-zeroing (you get a dangling pointer). This leads me to ask: What possible use could there be for a non-zeroing weak pointer? You can't use it for anything if you're not sure whether it's any good, can you? And how would you check its validity without risking a core dump / segfault? Addendum: I understand they're useful in reference-counted environments, and you may want to use them when writing library code that may be used therein, but I can't see a good reason for them with a smart-enough ARC-alike or relocating collector. What good is a reference that can't be relied on?


title: Why is Java 7's new file API usage still so scarce?

text: I don't even know whether this is the correct StackExchange site to ask such a question but here it is... I principally lurk on StackOverflow; and I am frankly flabbergasted by the number of questions on this site with regards to file handling still using the old file API. But I am even more appalled by the number of answers _still_ giving a solution using this API without even asking if the OP uses Java 7+, which has been out since basically the dawn of 2012. Why? Because there is simply no comparison. To give a few examples:   * the new API gives meaningful exceptions: `AccessDeniedException`, `NotDirectoryException`, `FileAlreadyExistsException`, `AtomicMoveNotSupportedException`, etc etc;   * common file operations, such as deletion, creation, renaming, etc throw an exception instead of returning a boolean;   * the new filesystem API allows you to access basically anything over a `FileSystem`; Oracle's JDK provides `FileSystem` access to ZIP files (therefore jars, wars, ears as well), Google provides an in-memory filesystem and I have even cooked up a `FileSystem` over FTP;   * with the new API, you can query and set "real world" file attributes, such as mtime, atime, ctime, owner, group, ACLs, etc etc;   * when dealing with text files, `Files` doesn't give you room for error since it requires that you specify a `Charset`, unlike all other `Reader`s accepting `File`s as arguments;   * the new API has support for symlinks and so called "hard links" (which are really links to the filesystem);   * filename existence correctly relies on the current character encoding. So, why does this API see so little usage?


title: How much time do software developers have to spend outside of work learning new material?

text: I am considering going back to college to get a computer science degree so that I can become a software developer. (I'm only 23, by the way.) The main reason that I am reluctant to study CS is that I have read that because technology changes so fast software developers have to spend a lot of time learning new material. For example, somebody on this website stated that everything college students learn will be obsolete by the time they graduate. Somebody else stated that half of everything a computer scientist knows will be obsolete in 18-24 months. Anyway, how much time outside of work do software developers have to spend learning new technology? I would appreciate any advice.


title: How do I manage a very large set of rules and magic numbers in my program?

text: I'm somewhat new to programming (I'm a mechanical engineer by trade), and I'm developing a small program during my downtime that generates a (solidworks) part based on input from various people from around the plant. Based on only a few inputs (6 to be exact), I need to make hundreds of API calls that can take up to a dozen parameters each; all generated by a set of rules I've gathered after interviewing everyone that handles the part. The rules and parameters section of my code is 250 lines and growing. So, what is the best way to keep my code readable and manageable? How do I compartmentalize all my magic numbers, all the rules, algorithms, and procedural parts of the code? How do I deal with a very verbose and granular API? My main goal is to be able to hand someone my source and have them understand what I was doing, without my input.


title: Why speaks basic http authentication always of a username

text: In RFC 2617 HTTP Authentication: Basic and Digest Access Authentication they speak always of username and password for the authentication. Why should I choose to take a username as identifier for a website? Usernames are often hard to choose a not existing one or one which is unique. But everyone getting an account somewhere has an email which is unique. Why does the RFC not speak of something abstract like a unique string identifier? That would make much more sense to me where everyone logs into his account with his email... When someone starts with security/authentication the first thing he will think reading the RFC 2617 that he can not do basic auth because I want email + password. What am I missing here?


title: What are some important considerations when developing a DBaaS (DataBase as a Service)

text: I'm interested in creating a Database as a Service. I want users of the service to be able to do a few seemingly not very simple things. Sign up and be given access to a JSON datastore that they can easily query from a RESTful API. Now I've implemented RESTful account management with Eve in python, so a user can sign up and be granted access to a single global collection, with write access and read access to their own items. Now the beauty / simplicity of Eve seems to be conflicting with my use-case, for `POST` / `PUT` to be enabled on an endpoint there needs to be a schema defined up front. To get around this I've just created a simple item with a string datatype that allows persistence of the entire JSON object. But this means that the user would lose the ability to query for objects they've stored and would have to retrieve all their objects, parse them and then query them application side. Which doesn't seem much like a service users would want to adopt.


title: Developing a dynamic language

text: I have created several hand written compilers for very simple languages but now I want to try my hand at developing a dynamic language, similar to a simplified Python or Ruby. However, it was easy for me to wrap my head around how compilers work. Primitive compilers just translate. But I can't do this if the language is dynamic. I have to write an interpreter or VM that keeps track of information at runtime and puts a lot more work on me. In short, are there any resources I should check out considering I know how compilers work but want to migrate to creating an interpreter? There are a few VMs out there for dynamic languages, but I have no problem with rolling my own. This is all just for my personal experience. **EDIT:** I am seeking information on how to go from a compiler to an interpreter. If I have already made a compiler for language X but now what to write an interpreter, what needs to be done and are there any resources that go over the process? I do not want broad or abstract resources that go over how compilers or virtual machines work. I have plenty of textbooks on the subject. All of the resources I found online either assume you have 0 experience and thus start you off with lexical or syntactic analysis or they are extremely abstract. I have a working compiler, but I now want to turn this into an interpreter and add dynamic features to the language. I could not find resources on this process, it may be too limited in scope, or resources on the "back end" of an interpreter without being too theoretical which is why I posted here.


title: Community-built, open source best practices

text: Are there currently any best practices for community-built open source projects? First, this is not a criticism only an observation: open source code comes with nearly no commenting. There's an open source project that I want to debug, but the lack of commenting intimidates me into setting aside less time since I'll have to spend hours catching up. In my novice opinion, it seems that development times would drop if the new programmer to contribute could easily go back and see how everything works on arrival. I understand that this probably isn't done now because everyone's working for free and have lives & bills, so I would never dare criticize someone working for "me" as an open source user for free. I'm just saying it might be simply overlooked in the haste to put out code, and it may be surprisingly more efficient to put out less code but more comments. I am a novice and have no way to confirm this. Please inform me if I am wrong. I've also found this, which seems to be a great outline for when one controls the program oneself, but I wonder if there might be anything missing for an open source project with disparate contributors. Is there a standard for community-built open source projects? If so, where?


title: Does it make sense to make an Android version of my application?

text: I am a teenage hobbyist in high school, and I mostly release my software as open source; therefore I have little experience actually selling software, let alone in a specific area -- Android phones. Now, I have received requests from several users of one of my applications (basically, an advanced calculator) to create an Android version of it. It is written in C, but I saw the Android NDK and it looks like I could port it _relatively_ easily; also, I believe it would make a lot of sense to have such an app on a phone. I do not have an Android phone myself, and so the incentive is simply potential revenue from the app. However, I have several questions that I am not able to answer myself. So, first, do you think it makes sense at all? Would such an app generate enough revenue to compensate for the porting time? More generally, how much revenue can one expect from an Android app (just looking for a rough approximation, I really have no clue about this)? Secondly, is such porting feasible without actually having an Android phone (I might get access to some for final testing, but I won't have it full-time), justing using the emulator? And last, I have read the standard Google words that publishing is super-easy, etc. Is that actually true? For example, is it necessary to put in substantial advertising work to make the project a success? Thanks a lot!


title: Securely sending data from shared hosted PHP script to local MSSQL

text: I'm trying to add data from a webhook (from a web cart) to a local Microsoft SQL Server. It seems like the best route for me is to use a PHP script to listen for new data (POST as json), parse it, then query to add to MSSQL. I'm not familiar with security concerning the connection between the PHP script (which would sit on a shared-host website) and the local MSSQL database. I would just keep the PHP script running on the same localhost (have Apache running on Windows), but the URI for the webhook needs to be publicly accessible. Alternately, I assume that I could just schedule a script from the localhost to check periodically for updates through the web carts API, though the webhooks seem to be more fool-proof for an amateur programmer like myself. What steps can I take to ensure security when using a PHP on a remote, shared- host to connect to MSSQL on my local machine?


title: Efficient Java Programmer

text: There's been a buzz in my local tech community about being an 'Efficient Java Programmer' can someone explain to me what is an Efficient Java Programmer? what is their difference between average java programmers? how can you be an Efficient Java Programmer? (I am still in college, I want to get acustomed to doing the proper practices when it comes to programming) and how can you tell someone is an efficient java programmer?


title: What can one do when "lead by example" doesn't work?

text: I have been working for a big company (8000+ employees) for almost 2 years now, and was hired just after I finished my study course. Everyone here has to deal daily with legacy code which is often very badly designed and full of hacks. At first, I kept a low profile, trying not to criticize things too much. But the situation, as it stands, has become very difficult to live with and it seems no one is willing to improve/replace the tools we use. To be more explicit we have:   * An obsolete source control tool (Visual SourceSafe)   * Plain old makefiles which only support full rebuild   * `.def` files which must be maintained manually and separately for all existing architectures   * monolithic headers files and projects with very few different files (but each has around 3000 lines of code, which sometimes takes care of very different tasks)   * no use of the "new" languages facilities (well `std::string` is not that new but nobody except me uses it) I decided, a few months ago to do something about it, by designing a new compilation environment. I could get incremental builds to work reliably, faster compilation times, better structured projects, automatic `.def` files generation. I even created a bridge from/to Git to/from Visual SourceSafe. I showed my achievements to several collegues and our boss but it was like nobody cared. They were all like "Well... people are used to do it that way now. Why would we change things ?" The changes I suggested were designed so that we could have a soft transition from the old system to the new one. Each improvement could be applied separately and safely. I even tried to get some of my coworkers involved in the changes. But so far, no success. Have you already faced a similar situation ? What can one do when "lead by example" doesn't work ?


title: How baby are your baby-steps in TDD?

text: Today we were training TDD and found the following point of misunderstanding. The task is for the input "1,2" return sum of numbers which is 3. What I have written (in C#) was:               numbers = input.Split(',');     return int.Parse(numbers[0]) + int.Parse(numbers[1]); //task said we have two numbers and input is correct      But other guys preferred to do it other way. First, for input "1,2" they made added the following code:               if (input == "1,2")        return 3;      Then they introduced one more test for input "4,5" and changed implementation:               if (input == "1,2")        return 3;     else if (input == "4,5")        return 9;      And after that they said "Okay, now we see the pattern" and implemented what I initially did. I think the second approach better fits the TDD definition but... should we be so strict about it? For me it is okay to skip trivial baby steps and combine them into "twinsteps" if I am sure enough that I won't skip anything. Am I wrong? **Update.** I have made a mistake by not clarifing it was not the first test. There already were some tests so "return 3" actually wasn't the simplest piece of code to satisfy the requirement.


title: What can REST API do that a API using HTTP URL query strings cannot do?

text: I'm learning about REST and had the chance to build a basic REST API. After doing so, most of the material I read was internalized and I now have a better understanding of it. However, I do not see any real difference yet as to the **tangible** benefits of using REST over the old way I was doing things, which was simple URL query strings. It seems they both do the exact same things. But with REST, it's cleaner, and standardized. I thought REST had additional technical benefits. If they do, what are they? Or is REST simply that - an agreed way to implement and API?


title: Can TCP/IP Sequence and Acknowledgement numbers be controlled?

text: Normally TCP/IP Sequence and Acknowledge numbers are 32 bit. However, I need a way to shorten them to be 24 bit (it's an experiment in deep inspection firewalls). Question: Is it possible to shorten the bit resolution of the Seq/Ack numbers in windows without the knowledge of the application? (which in this case is IIS) I want to use those top 8 bits to store some session information.


title: Is it best to use "get" as a prefix for getters?

text: if I had a boolean (property) `shouldAutoLogin` is it better to name the getter `getShouldAutoLogin` or just `shouldAutoLogin` so that it reads more like English? ex :               if(shouldAutoLogin){         ...     }      or               if(getShouldAutoLogin){         ...     }


title: Customer buys software for function it cannot do and then complains. How to resolve?

text: I have come across this several times when selling a prepackaged solution. Customer buys the package, which clearly sets out that it can do XYZ, but the customer wanted it to do ABC. The customer then emails for support. I inform the customer that the product was never designed for the purpose they had in mind (integrating it with another product). The customer asks for a refund as they cannot use the product. This is where I'm in two minds. First, the product is fully functioning and they have now obtained the source code (PHP script). How am I to know they aren't going to use it anyway and still want a refund? Second, I do feel bad for the customer. If they're being honest, and most are, then they cannot use the product and therefore "wasted" the money in their eyes. But, that wasn't my fault. Up until now I've refunded the money if requested, but now I'm comparing what I do with how bigger companies deal with this kind of situation. What would they do? Maybe because they're bigger, they don't care about a few refunds every now and then, but to a one man band like me, every sale is needed! What is the best way to deal with this kind of situation?


title: Enhancing the level of my C/C++ code

text: I have been programming for 3-4 years now and feel I can no longer be called a beginner, but I read some questions on this site and think WTF are they talking about? I feel the same way when I pick up programming books nowadays. I have read several beginning programming books, some on C/C++ and others on gaming. I have written some more complex things such as very basic AI, serial and TCP/IP interface. I plan on becoming a game programmer, but I have recently become somewhat interested in embedded systems after having the chance to work on them (the serial interface). I have found it very difficult to find materials to continue my learning after completing the introduction and beginner books as the are no intermediate C++ books I can find. What advice would you give to grow and enhance my knowledge and skills? Specific resources would be greatly appreciated.


title: Is Entity Framework Code First a bit meaningless/useless in production and what is a good EF strategy for production?

text: I have been programming recently with Entity Framework 4.1 Code First and am loving it for development, but with only an end plan and a rapidly changing feature list, I am constantly modifying the Class/Database to meet the applications needs. In development, there is no live data and I can easily just delete the entire database so it is recreated with the new schema however, obviously, when live - this is very bad! The only solutions I can see are to either drop the metadata table and manually keep the database in sync or basically drop and reseed. I personally prefer the first method as I think it will be a lot easier to add a column/table than to recreate and migrate data, but, unless I have missed something, this is completely moving away from Code First. So the question really is, is Code First just about the initial development and what is a good strategy for managing EF for a production environment?


title: Understanding and memorizing git rebase parameters

text: So far the most confusing portion of git is rebasing onto another branch. Specifically, it's the command line arguments that are confusing. Each time I want to rebase a small piece of one branch onto the tip of another, I have to review the git rebase documentation and it takes me about 5-10 minutes to understand what each of the 3 main arguments should be. `git rebase <upstream> <branch> --onto <newbase>` What is a good rule of thumb to help me memorize what each of these 3 parameters should be set to, given any kind of rebase onto another branch? Bear in mind I have gone over the git-rebase documentation again, and again, and again, and again (and again), but it's always difficult to understand (like a boring scientific white-paper or something). So at this point I feel I need to involve other people to help me grasp it. My goal is that I should never have to review the documentation for these basic parameters. I haven't been able to memorize them so far, and I've done a ton of rebases already. So it's a bit unusual that I've been able to memorize every other command and its parameters so far, but not rebase with `--onto`.


title: ChunkDB to handle high traffic JSON web service? Alternatives?

text: I am designing a high volume web service which will rely on a central database containing objects of a single JSON type. Currently I am considering using ChunkDB to store the objects and retrieve the objects using views (RESTful API). Some of the views may be complex. The amount of data stored in the database will be limited as objects will 'expire'. Is a sensible approach to the problem? What are the other options?


title: Why make the login page to a single page application a separate page?

text: I am wondering why it seems to be popular to have the login page of a SPA be a separate page that is not page of the SPA (as in loaded and send data through ajax requests)? I only thing I can think of is security but I can't think a specific security reason. I mean the only thing that come to mind is that if your login page in part of the SPA, it sends the username/password through ajax which can be seen by such tools like firebug or web inspector however even if you send it as a normal POST request, there are other tools that can easily capture this data (like fiddler, httpscoop, etc...). Is there something I am missing?


title: Contract / Project / Line-Item hierarchy design considerations

text: We currently have an application that allows users to create a `Contract`. A contract can have 1 or more `Project`. A project can have 0 or more sub- projects (which can have their own sub-projects, and so on) as well as 1 or more `Line`. Lines can have any number of sub-lines (which can have their own sub-lines, and so on). Currently, our design contains circular references, and I'd like to get away from that. Currently, it looks a bit like this:               public class Contract     {         public List<Project> Projects { get; set; }             }          public class Project     {         public Contract OwningContract { get; set; }         public Project ParentProject { get; set; }         public List<Project> SubProjects { get; set; }         public List<Line> Lines { get; set; }     }          public class Line     {         public Project OwningProject { get; set; }         public List ParentLine { get; set; }         public List<Line> SubLines { get; set; }     }      We're using the M-V-VM "pattern" and use these Models (and their associated view models) to populate a large "edit" screen where users can modify their contracts and the properties on all of the objects. Where things start to get confusing for me is when we add, for example, a `Cost` property to the `Line`. The issue is reflecting at the highest level (the contract) changes made to the lowest level. Looking for some thoughts as to how to change this design to remove the circular references. One thought I had was that the contract would have a `Dictionary<Guid, Project>` which would contain ALL projects (regardless of their level in hierarchy). The `Project` would then have a Guid property called "Parent" which could be used to search the contract's dictionary for the parent object. THe same logic could be applied at the `Line` level. Thanks! Any help is appreciated.


title: REST API rule about tunneling

text: Just read this in the REST API Rulebook: **GET and POST must not be used to tunnel other request methods**. > Tunneling refers to **any abuse** of HTTP that masks or misrepresents a > message’s intent and undermines the protocol’s transparency. A REST API must > not compromise its design by misusing HTTP’s request methods in an effort to > **accommodate clients with limited HTTP vocabulary**. Always make proper use > of the HTTP methods as specified by the rules in this section. [highlights > by me] But then a lot of frameworks use _tunneling_ to expose REST interfaces via HTML forms, since `<form>` knows only about `GET` and `POST`. My most recent example is a `MethodRewriteMiddleware` for flask (submitted by the author of the framework): http://flask.pocoo.org/snippets/38/. Any ways to comply to the "Rule" without hacks or add-ons in web frameworks?


title: MVC or Extract Service Layer

text: we have an application that is built with .Net MVC. We are now tasked with exposing API's to third parties. Members on our team want to just continue down our current path and just use more controllers so we can reuse the backend of our current application. Logic tells me we need to create a seperate service layer when more clients are going to be accessing it, but .Net MVC seems to take care of all of this. Is it really acceptable architecture to use controllers in a stand alone application to expose API's and what would be the potential gains of extracting the service layer out?


title: Good pattern(s) for pointing to mutable state

text: I asked this question once here, but believe the question was unclear. However I'm having a hard time extracting the general problem from my specific case. **UPDATE:** I've answered my own question below. Read on if you like reading stuff. Maybe is educational, maybe not :) I'm writing a music sequencer. Some existing components are:   * Sequence -- A collection of SequenceEvents (notes, meter, tempo, etc.)   * Sequencer -- Manages playback timing   * ScoreView -- Renders a sequence    * NeckView -- Shows playback on guitar neck   * GUI -- Manages smaller controls including clock displays of current play position Right now, all these components are very loosely coupled, using pub/sub to send and respond to events. The exception is that the Sequencer holds a reference to a Sequence, and publishes events when the logical "playhead" moves or when sequence events are encountered. Sequence queries need to be fast during live playback, so having a single component manage such queries is important. Some planned features require that multiple components show data related to the current playhead position, as well as a "step region", which is a time slice larger than a single time position, e.g. a measure. The question that arises for me is how to best represent "playhead" and "step region". I don't like the idea that each component would maintain duplicate state of these time positions and associated sequence events. Even having each component maintain references to "playhead" and "step region" objects feels like a DRY violation. However simply consuming transient events doesn't work well. Consider this example:   1. The Sequencer advances to measure 3, beat 1, and dispatches (publishes) an event.   2. ScoreView handles this event, moving its playhead display.   3. Sequencer queries its Sequence for event data at 3:1.0, finds a 3 note chord, dispatches 3 note events.   4. Synth handles these events, playing the notes.   5. NeckView handles these events, animating the notes. So far, all works well. But...   6. The user edits the score, adding a 4th note at 3:1.0   7. Sequence dispatches a sequenceEventAdded event. **How does the NeckView know that the added note is at the "current" playhead time?** Or how does it know that the added note was not at the current playhead but within the current step region, also displayed? This is one example illustrating the problem I'm more broadly trying to solve. Having multiple components maintain their own "playhead" and "step region" data seems like redundant responsibilities and state. But doing this all with transient events starts to feel like too many event types, not a great fit either. My best attempt to genericize this is to ask, what are good ways to represent shared mutable state? The "playhead" and "step region" both represent slices of time in a Sequence, but within those time slices, sequence events could be added/removed and observing components need to know this. Every way I look at this feels wrong to me. Another thought is to have actual objects for a Playhead and StepRegion. Each comprises time point(s) and a subset of sequence events from the Sequence. Each could listen to the Sequence for added/removed events and re-publish these. However this approach means that multiple components now have references to a Playhead and StepRegion, which feels like a duplication of responsibilities. But if only the Sequencer holds these objects (which manages timing and logically does have a current playback position), then how do other components know to update when notes are added/removed within these time regions (as opposed to other time regions of the Sequence)? The more I try to ask this question the dumber it sounds, but I wouldn't ask if the answer were obvious to me! Here are some multiple choice solutions:   1. **Sequence dispatches _playhead_ and _stepRegion_ events**. If sequence data changes for either of these time slices, it dispatches a new _playhead_ and _stepRegion_ event, each containing the current corresponding sequence data. Observing components like NeckView can treat these events as idempotent and remain stateless regarding timing.   2. **Add _Playhead_ and _StepRegion_ classes. Multiple components can hold references to these and listen to added/removed events from these instances**. This involves a fair amount of new Objects during playback, probably not a big GC concern, but smells bad.   3. **Playhead and StepRegion are singletons**. This is worse version of #2, and requires these objects maintain references to the Sequence as well as observe events from the Sequencer and re-publish events from both. Testing becomes problematic.   4. **Sequence's added/removed events contain a reference to the Sequence object**. While this seems like a sane and a common approach, it invites multiple components to do potentially expensive querying (redundantly) on the sequence as often as every tick during real-time playback. This is one reason only Sequencer directly manages a Sequence.    5. **All observing components maintain their own time points for playhead, stepRegionStart, stepRegionEnd**. Any sequenceEventAdded/Removed events can be handled or ignored accordingly. This means redundant state, but that state can completely be updated via events.  This is a long question. Any thoughts?


title: Is Learning C++ Through The Qt Framework Really Learning C++

text: The problem I have, is that most of the C++ books I read spend almost forever on syntax and the basics of the language, e.g. `for` and loops `while`, arrays, lists, pointers, etc. But they never seem to build anything that is simple enough to use for learning, yet practical enough to get you to understand the philosophy and power of the language. Then I stumbled upon QT which is an amazing library! But working through the demos they have, it seems like I am now in the reverse dilemma. I feel like the rich man's son driving round in a sports car subsidized by the father. Like I could build fantastic software, but have no clue what's going on under the hood. As an example of my dilemma take the task of building a simple web browser. In pure C++, I wouldn't even know where to start, yet with the Qt library it can be done within a few lines on code. I am not complaining about this. I am just wondering how to fill the knowledge void between the basic structure of the language and the high level interface that the Qt framework provides?


title: Question about initial interview for job

text: So I feel kind of stupid having to ask this but tomorrow I have a phone interview with a good company. Phone interviews themselves not a big deal for me, but having to tell them my salary expectations is. The position that I'm applying for is a mid-level software engineer, I fit all of the requirements (I'm not overly qualified by any means), and I want to be sure I'm not asking for an amount that would be absurd or too little. Now, assuming I get a second interview and have to complete some sort of puzzle/code/work, they may pay me +/- whatever I asked for based upon their evaluation of my work. What I'd like to know, is what is a good amount to ask for? Or am I completely wrong with my assumptions? Either way some advice would be much appreciated!


title: How to become a web developer from scratch without a degree?

text: > **Possible Duplicate:**   >  Best approach to learning web programming I am extremely interested in web development though I know very little about code. I did not read computer sciences in my college/university. Now I find myself very determined to learn the server side development and want to have a career in the field, where should I start from? I have got almost an year of free time and can work very hard, guide me please, thank you.


title: What's the benefit of having a private repository for personal projects?

text: So I just created my first GitHub repository and started to wonder if there would be any reason why somebody shouldn't post their code. I don't mean the obvious, such as code that is IP of somebody else or any other possible legal situation; I'm talking about a newbie posting their own, albeit terrible, code. I've heard several times on this site that one of the things that a some of the hiring managers do is check out the person on Github (or similar site), so what if the code is lacking? Would the position desired—for example, if I'm going after a junior developer position instead of a senior developer position—matter?


title: documentation of typescript code

text: my question is rather short: How do I document typescript code properly? I found out that for projects becoming bigger and bigger, it is important to look at a function and immediately know parameters, what it returns and side-effects etc. It is tiring to have just a bunch of comments before a function, most of the time these 'blocks' even look differently in style. What I am looking for is a documentation tool like javadoc or doxygen for typescript. Is there anything out there? Or is it possible to 'abuse' a documentation tool and get it to work with typescript?


title: When do I bite the bullet and hire a developer?

text: I have an awesome URL, I've had it since the mid 90's, and up until around 2002 I was having an awesome time writing music reviews and features into static pages and adding their URL to static index pages and everything was just great. Then things got complicated really fast, and for one reason or another I handed the site over to a very talented friend who turned it into a db based site run by cf. Now, here I am around twelve years later putting it all back together using mysql, php and css on a need-to-learn basis and even though I'm sooo close to where I want it to be I realize, erm, it should have been written using mysqli etc etc ad infinitum. So I'm wondering at what point do I just give in and hire a developer to take over, how much does it even cost, and how do I know I'm working with someone who is better than I am?