Joel Spolsky said in one of his famous posts: > The single worst strategic mistake that any software company can make: > rewrite the code from scratch. Chad Fowler wrote: > You’ve seen the videos, the weblog posts and the hype, and you’ve decided > you’re going to re-implement your product in Rails (or Java, or .NET, or > Erlang, etc.). > > Beware. This is a longer, harder, more failure-prone path than you expect. Have you ever been involved in a BIG Rewrite?   I'm interested in your experience about this tragic topic, and in particular, in any big rewrite that was completed succesfully (if any).


Accessing SAP R/3 from Java

What do I have to do to write a Java Interface for SAP R/3. I do not have experience with SAP, and they are very slow in their answers, so I just ask here for your experience with them. Can anyone create software that uses SAP for free? Do we have to license the Java Connector? Do we have to become SAP partners? How much is it? Thanks for all information you have.


What is a good strategy to develop apps that run in console and as API?

I develop quite often scripts that are primary used as a console application but later they are used in other scripts, webservices and other things where it is very convenient, to just import the script and call methods directly rather than using a Process and parsing stdout. The question is now, what is a good design strategy to develop such scripts? I have an example here in python:               def main():        # do stuff        print("Found several results here:")        for foo in bar:            print("result: %s" % foo)               if __name__ == "__main__"():         main()      this one could be easily rewritten to something like this:               def main():        result = some_function()        print("Found several results here:")        for foo in result:            print("result: %s" % foo)               def some_function():        # do stuff        return bar               if __name__ == "__main__"():         main()      But in most of my cases this is not so easy. But how to deal with this problem when the program does quite a lot of output, like different analyses or several steps or the return value of an API function would be something like a list of dict of list of tuples (or even more complicated structures)? Would it be good to encapsulate every step into a single method and run them one after another? What design patterns can be used to write good progamms that can be easily reused as APIs?


Defining property and find substitution for copy function of python in cython

I want to cythonize a code in python to speed up the code. In the following you can see my attempt to make my python class understandable for cython:               import numpy as np     cimport numpy as np     ctypedef np.double_t DTYPE_T     cpdef double std_G,v_c     std_G=4.3e-9 # Newton's const   in Mpc (km/s)^2 M_sol^{-1}     v_c = 299792.458 #km/s          cdef extern from "math.h":         double log(double) nogil         double sqrt(double) nogil               cdef extern from "gsl/gsl_math.h":         ctypedef struct gsl_function:             double (* function) (double x, void * params)             void * params          cdef extern from "gsl/gsl_integration.h":         ctypedef struct gsl_integration_workspace         gsl_integration_workspace *  gsl_integration_workspace_alloc(size_t n)         void  gsl_integration_workspace_free(gsl_integration_workspace * w)         int  gsl_integration_qags(const gsl_function * f, double a, double b, double epsabs, double epsrel, size_t limit, gsl_integration_workspace * workspace, double *result, double *abserr)          cdef double do_callback(double x, void* params):           return (<ComovingDistMemoization>params).eval(x)                cdef class ComovingDistMemoization(object):          cdef list _memotable          cdef cosmolgy          def __cinit__(self, cosmology, memotable = None):                   if memotable is None:                 self._memotable = []                   self._memotable = memotable              self.cosmology = cosmology          def __call__(self, double z):                      if z in self._memotable:                 return self._memotable[z]                 def eval(z):                      return 1./sqrt(self.cosmology.hubble2(z))             cdef gsl_integration_workspace* w =gsl_integration_workspace_alloc(1000)             cdef gsl_function F                              F.function = &do_callback              F.params = <void*>self              cdef double result = 3, error = 5             cdef double y, err, dist             gsl_integration_qags (&F, 0, z, 0, 1e-7, 1000, w, &result, &error)              y, err = result, error                   gsl_integration_workspace_free(w)                   dist = self.cosmology.v_c * y  #to get proper units, ie to put in the hubble length                  self._memotable[z] = dist                  return dist               cdef class cosmology(object):         cdef comovingdist         cdef public double omega_m, omega_l, h, w, omega_r, G, v_c         cdef double H0, hubble_length         def __init__(self, omega_m = 0.3, omega_l = 0.7, h = 0.7, w = -1, omega_r = 0., G = std_G):                  self.omega_m = omega_m             self.omega_l = omega_l             self.omega_r = omega_r             self.h = h             self.w = w             self.G = G             self.v_c = v_c                  self.comovingdist = ComovingDistMemoization(self)         def __copy__(self):                  return cosmology(omega_m = self.omega_m, omega_l = self.omega_l, h = self.h, w = self.w, omega_r = self.omega_r, G = self.G)              property H0:            def __get__(self):                return 100*self.h  #km/s/MPC              def hubble2(self, double z):             cdef double inv_a             inv_a = 1.+z             return (self.omega_r*inv_a**4 + self.omega_m*inv_a**3 + \                       self.omega_l*(inv_a**(3*(1+self.w))) + (1 - self.omega_m - self.omega_l - self.omega_r)*inv_a**2)*self.H0**2              property hubble_length:             def __get__(self):                 return self.v_c / self.H0              def rho_crit(self, double z):             return 3.*self.hubble2(z)/(8*np.pi*self.G)                   def angulardist(self, double z, double z2 = None):                 if z2 is None:                 return self.comovingdist(z) / (1+z)                  return (self.comovingdist(z2) - self.comovingdist(z)) / (1+z2)      However one of the places that raises error and I couldn't find so far any substitution and my investigation just reached to this point that the `__copy__(self)` function is not supported by cython. I have read that with `pickle.Pickler`, it is possible to provide a substitution for an **instance** of a class but I don't know how it should produce a copy of a class inside the class?? Update: Is it a right way to replace `__copy__` with the following piece of code:               def __reduce__(self):         return (self.__class__, (), self.__getstate__())     def __getstate__(self):         return (self.omega_m, self.omega_l, self.omega_r, self.h, self.w, self.G, self.v_c)     def __setstate__(self, data):         (self.omega_m, self.omega_l, self.omega_r, self.h, self.w, self.G, self.v_c) = data      My second question is about `property`, have I defined the property in cython or I also need to have a `__set__` function as well? My last question, at this point the code get compiled without any error message but when I call an instance of `cosmology` class in python all them return zero. I am wondering whether the wayI have called for instance `cosmology` class in `ComovingDistMemoization` class and vice versa caused the problem and can not pass info between them ?


confusion between SVN and code backup by month/date/time whenever i make major or important update to the code

I am working on two different project simultaneously where whenever the changes are made we use   1. Tortoise SVN for project A   2. Backed up by folder for Project B (this is done by me on my system) I find SVN good for maintaining the latest code server machine and update it whenever necessary.   For Project A, I happen to make alot of changes to the project A and I am advice not to commit the changes again and again but just a major change all at once.   But since in not alone on project A I tend to make code backs by folder every time I make an important change so I can go back and return if some conflict occurs. But what should I do in case of the project B?   where most I am on the project (as of now).   Should it be SVN or folder backups? The reason I do folder backups for the project B is that   sometimes the build given to the client fails/buggy so instead of making them wait for it to fix   I just go and open the project and compile the last working build and give the executable so they can carry on their work and not wait for me to fix it (may take long). I am working with Delphi on both the projects.


MVC content management framework with an admin panel

I've lately been developing my own MVC content management system using PHP and, at least in my mind, am a little stuck with the system design. I believe this would apply to building a content management system with an existing MVC framework as well. This is going to be a little difficult to explain, so sorry in advance for the lengthy dilemma. **A little intro to the system:** Currently my routes look a little like this (stored as JSON):               {         "/admin/:controller/:action/:params":"",         "/admin/:controller/:params":"AdminController",         "/admin":"AdminController",         "/:page?/:subpage?":"IndexController"     }      The routes are the keys, the default controllers are the values. If there isn't a default controller the router falls through to the next rule. I've done this to separate the front end of the site from the admin panel. The controllers are all in one directory for the time being, although this is destined to change. They either return a template that's been populated with data from their respective model or simply modify the request they were instantiated with. **The problem:** My problem is with deciding how to implement separate controllers that concern the same model for the front end and the back end in a modular way. For example, I have a page in the admin panel that allows an administrator to enter some private information that's intended only to be accessible on the front end with a username and password. Imagine this is handled by an `InfoController` in the back end, for editing the private information, matched by the route `/admin/info`. What if I wanted to create a route for the front end, for accessing the private information, with the same name as in the admin panel (`/info`)? The problem makes more sense in context with the solutions I've considered, I think. **Solutions I've considered:**   1. My first thought was to append all admin-related controllers with `Admin` \- so `AdminInfoController` and `InfoController` \- but I'm interested in eventually having a modular system where all the routes, controllers and views (and CSS/JavaScript if needed) pertaining to the `Info` model would be in their own directory structure (something like `/modules/info`).    2. With the desire for modularity in mind, I thought about matching routes a bit like `/:module/:controller/:action`, but this would then imply that the admin panel is itself a module, which would need access to all the modules the front end can use. Would that make sense?   3. The design I've thought about the most is to have the admin and front end as two distinguished, core concepts of the framework. They would share modules that contain controllers and views for both. Ultimately I'm looking for input on the best approach here, any alternatives, and whether I'm totally over-thinking this. It feels a bit like I've driven myself crazy with the pursuit of my ideal system design that keeps with the MVC pattern (is it even the right thing for a system like this?). Thanks for reading, I hope it made sense.


How do you track what you and your team are working on day-to-day?

I'm struggling with how to keep track of what myself and people on my team actually do each day. I get a good broad picture by going over completed cards each week and stand-ups help a bit, but I feel like I don't have a good handle on the day-to-day workings of my team. Cards will stay in progress for days on end without an update at the daily stand-up, and some engineers are my team aren't the most communicative. I've thought about implementing some sort of daily record that everyone fills out (via a mailing list or a shared google doc) but this seems fairly cumbersome and manual. Monitoring GitHub activity does an ok job but can be a little bit overwhelming with how many emails it sends out everyday. I've thought about trying to build a digest system for it, but don't have the time to spare. What strategies have you implemented to stay on top of what your team is doing everyday so that you can measure work on "in progress" tasks?


What is meant by an HTML5 application?

Since HTML5 is still only a markup language, what is meant when people say "HTML5 application"? Please explain.


How to avoid duplication between my issue tracker and the project specification documents?

I used to work for a professional consulting firm, and we worked under many different contract terms. When we could get a time & materials project, we ran it with SCRUM and tracked the backlog in our issue tracker system. Most of the time, however, we had to deliver under a fixed price contract. This required a specifications document as an appendix to the contract. So we always ended up batch importing work-items (or worse, manually entering) from the spec. Change orders took a lot of time to make sure everything was in sync, especially towards the end of the project. Is there a methodology or software tool out there **that keeps this whole process DRY**? I've done some searching and I'm apparently not using the right terms. Most of my professional network doesn't do fixed price work. I'd be open to:   1. Switching my bug tracker or buying plugins (currently using FogBugz).    2. Following a different development methodology    3. Writing software to manage the specifications and update the bug tracker and specification document (but this sounds like it will be a lot of work for dubious benefit) Lastly, is this really worth solving? It cost us quite a bit on some projects, but on other projects it didn't end up affecting us.


Can I share data between two users in an ASP.NET Application?

I have an issue with `Roles.IsUserInRole` function. It take hell amount of time to just check if the logged-in user is in particular role(typ 3-9 sec). I searched to find a solution and arrived on this but I am not sure If I have fully grasped it. What I got from the above, A new derived class is created. Inside that class, there is a list which retrieves all user at once. The next time you check `IsUserInRole`, you do not use the actual IsUserInRole method but rather use the one you overrode in your class. Is this the correct description? Am I on track? **My question is, can data be share between two different users in ASP.NET application?** If yes, will the shared data exist only if there is at least one user logged in. If all users logs out, that shared data is destroyed? My point is this data will be created only one time whenever a user logs in. For all subsequent users they can use this data and check their roles against the list? I need a detailed answer. My application has users and different roles. We are using ASP.NET roles.


What is history and concept of code annotation?

C# and Java has code attribute and code annotation. I don't know about other languages, but I know the code annotation feature is used to expand language itself. I knew what it is, but I want to know how it developed over time. I want to know its history. How it demanded and how it implemented. Is this possible to implement this in kind of concept on LISP, Smalltalk or C++? And is there a general term to call the concept of annotation?


How important is index size when searching?

My company has recently began using Apache Solr to search its data. As we learn how to use it we have gone down the path of indexing multiple fields to get the results we need. Most of these are either N-Grammed or Edge-N-Grammed (N-grammed, but only from the edge; for starts-with searching). Gramming by nature takes up a lot of space, which takes more time to search. Space is cheap, but time is less so. Index time is not too important, since a delta-import (only get the changes since last index) is extremely quick and you only pay a penalty on the first import. What we've not been able to determine is what effect the index size has on query times. Obviously a larger index takes longer to search, but the time added by n-gramming a field is difficult to predict. How do you determine whether a field is worth gramming? Can you predict how much longer a query will take when you gram a field?


How can we avoid creating duplicate or conflicting functionality when working on an agile team?

I'm working in a team where each member is working on an user story. How can we avoid creating duplicate or conflicting functionality? For example, if my user story requires the creation of class A and my team member needs the same functionality and creates a similar class (maybe with a slightly different name), how should we plan our work so that we both move smoothly?


Best practices when creating/modeling databases?

I learned at the University some steps to model a database:   1. Model the problem using the _Extended Entity-Relationship Model_.   2. Extract the functional dependencies    3. Apply some algorithms to normalize the database ( _3NF_ or _Boyce-Codd_ )   4. Create the database I'm studying **Computer Science** and since I received that course I'm wondering if I always need to do those steps when creating a ~~complex~~ database for an specified problem. For example, do **PHP** / **.NET** / .. programmers always do that? or there are some tools to simplify that process, maybe using another way of represent the problem instead of the _EERM_?


Do people who get paid to write code but score low on the "programmer competency matrix" have an ethical duty to find a different kind of job?

People advise me to "find a job doing something that you are good at", but the truth is that I don't believe I am good with anything other than just writing code. I don't think that I can design or structure a program though. Don't get me wrong, I'm not the kind of programmer who can't write a fizz buzz program; I'm more like the kind of programmer who can't do much besides getting the job done. It's not that I have a "do the bare minimum" attitude; it's that I'm painfully aware of my limitations as a programmer. For example, implementing a quick sort algorithm is something that I could do only by relying on rote memorization (that is, if I ever find the motivation to spend a good chunk of my day trying to commit the entire algorithm to memory and not just go like "umm, I see, that makes sense, I can see the logic..."). When it comes to structuring and designing an application I feel I'm just as helpless. Since I am unable to see the right answer at the start I just make a judgement call which nine times out of ten I later regret. I still manage to obtain job promotions and praise from my coworkers, so others don't necessarily share my opinions. Objectively speaking though, I simply have neither the learning ability nor the sheer brain power to realistically aspire to be anything more than a 'slightly above average' programmer. I wonder whether I actually have an ethical duty to make room for more talented people and find myself another kind of job, even if I'm fairly confident that I would not find another role I am better qualified for. My question then is "Do average programmers have a place on a team?"


How to update a row in database without ID?

I've got a table with the following structure :               Col1 | Col2  | Col3     A    | B     | C     A    | C     | B     E    | D     | C      The primary key is (Col1,Col2,Col3). I get the data in another project and display it in view with a grid. When the user edit a row in the grid, for example : A,B,C -> A,B,E, I get (A,B,E) and try to update the database. But I don't know which row must be updated if I don't have the original (A,B,C). What's the proper way to resolve this issue ? Should I create a temporary ID on my second project ? I don't think create an specific ID in the database is a good idea.


Why are shortcuts like x += y considered good practice?

I have no idea what these are actually called, but I see them all the time. The Python implementation is something like: `x += 5` as a shorthand notation for `x = x + 5`. But why is this considered good practice? I've run across it in nearly every book or programming tutorial I've read for Python, C, R so on and so forth. I get that it's convenient, saving 3 keystrokes including spaces. But they always seem to trip me up when I'm reading code, and at least to my mind, make it _less_ readable, not more. Am I missing some clear and obvious reason these are used all over the place?


How to avoid distractions during programming and keep up to date?

People always need concentration during work tasks, but i feel programming requires even a higher level. In general my biggest problem is getting distracted by my articles feeds, but i also give it a lot importance to keeping up to date.   1. What are recommended habits or tips to avoid distraction during long programming sessions?   2. How to keep up to date with technologies without investing a big amount of time reading and browsing?  Thanks in advanced.


How do you stay focused at work?

Sometimes, the things I have to do for my job are interesting and engaging. Sometimes, they aren't. Occasionally, they _really_ aren't. Do you have any particular strategies or tricks for dealing with those dull stretches when your brain would rather be doing anything other than what you're supposed to be doing, particularly when the Internet and its boundless opportunities for interesting Slack beckon?


Design patterns and multiple programming languages

I am referring here to the design patterns found in the GOF book. First, how I see it, there are a few peculiarities to design pattern and knowing multiple languages, for example in Java you really need a singleton but in Python you can do without it you write a module, I saw somewhere a wiki trying to write all GOF patterns for JavaScript and all the entries were empty, I guess because it might be a daunting task to do that adaptation. If there is someone who is using design patterns and is programming multiple languages supporting the OOP paradigm and can give me a hint on how should I approach design patterns. An approach that might help me in all languages I use(Java, JavaScript, Python, Ruby): Can I write good application without knowing exactly the GOF design patterns or I might need just some of them which might be crucial and if yes which one, are there alternatives to GOF for specific languages, and should a programmer or a team make their own design patterns set?


What is the purpose of Console in Sublime text editor?

I want to know what purpose does console solve in sublime text 2. This is invoked by pressing Ctrl+Shift+` Is this a kind of debugger, or It just helps you to install packages.


Understanding binary numbers in terms of real world objects

When I represent a number in the decimal system, I have an intuitive knowledge of what it amounts to. For example take the number '10': I understand that it means 10 apples or 10 people... i.e I can count in the real world. But as soon as the number is converted to any other system, this understanding no longer applies. For example 10 when converted to binary will be 1010...now what does this represent? Is there a way to understand this number 1010 in terms of counting objects in the real world?


Joomla Secondary Users

## Background I have a joomla based application. My customers sign up and they register as a user on the site. My customers (primary customers) then have their own space on the site that they can then setup their own customers (secondary customer). ## Question/Problem The problem I am having is that I need to tag each secondary customer to a primary customer. I thought about just creating a new component and having a separate table that includes all the secondary customers. The problem is that I then lose out on all the authentication, session handling and login/logout that the core joomla _users component offers. I then thought about just having all the users in the core _users table and add the primary customer associated with each secondary customer to a field in a profile plugin. This would work for the most part, but this means that primary customers cannot create a secondary customer with a user name that already exists in the _users table. I didn't think this would be an issue, but several of my primary customers (currently only test users) have been confused by the site telling them a username is not available, since they can only see the names of their own secondary customers. Any ideas on some architectural changes I could make to solve this?


Architecting persistence (and other internal systems). Interfaces, composition, pure inheritance or centralization?

Suppose that you need to implement persistence, I think that you're generally limited to four options (correct me if I'm wrong, please) Each persistant class:   1. Should implement an interface (IPersistent)   2. Contains a 'persist-me' object that is a specialized object (or class) that's made only to be used with the class that contains it.   3. Inherit from Persistent (a base class) Or you can create a gigantic class (or package) called Database and make your persistence logic there. What are the advantages and problems that can come from each of one? In a small (5kloc) and algorithmically (or organisationally) simple app what is probably the best option?


Why does Java define homogeneous methods in Matcher and Pattern classes

I wonder why java defines homogeneous methods in two distinct classes: java.util.regex.Pattern and java.util.regex.Matcher. For example `split` method defined in `Pattern` class and `replaceAll` method defined in `Matcher` class. I think these two methods are homogeneous, why are they not defined in the same class? Have I understood it wrong? By "homogenous", I mean: `split` and `replaceAll` methods are utilities for String, why not defined in a class?


Architecture advice for converting biz app from old school to new school?

I've got a WinForms business application that evolved over the past few years. It's forms over data with a number custom UI experiences taylored to the business, so I don't think it's a candidate to port to something like SharePoint or re-write in LightSwitch (at least not without significant investment). When I started it in 2009 I was new to this type of development (coming from more low level programming and my RDBMS knowledge was just slightly greater than what I got from school). Thus, when I was confronted with a business model that operates on a strict monthly accounting cycle, I made the unfortunate decision to create a separate database for each accounting period. Also, when I started I knew DataSets, then I learned Linq2Sql, then I learned EntityFramework. The screens are a mix and match of those. Now, after a few years developing this thing by myself I've finally got a small team. Ultimately, I want a web front end (for remote access to more straight up screens with grids of data) _and_ a thick client (for the highly customized interfaces). **My question is:** can you offer me some broad strokes architecture advice that will help me formulate a battle plan to convert over to a single database and lay the foundations for my future goals at the same time? Here's a screen shot showing how an older screen uses DataSets and a newer screen uses EF (I'm thinking this might make it more real for someone reading the question - I'm willing to add any amount of detail if someone is willing to help). ![enter image description here](http://i.stack.imgur.com/q2vPb.png)


Is it my responsibility to code for errors on a completely separate website and domain when redirecting or doing a single sign on?

If my application is responsible for redirecting/doing a single sign on to a destination managed by a third party, in general, where should I draw the line for error handling during this process? If an error happens on the other application's end, is it reasonable for my stakeholder to expect the application I am working with to share responsibility for handling these scenarios? Notes:   * I am going to keep solutions limited to those that entail only one request--I am familiar with the "do an xmlhttprequest and see how that fares before doing anything else" approach.    * I am speaking in terms of an enterprise-level application with fairly decent customer traffic.


How do I structure code and builds for continuous delivery of multiple applications in a small team?

**Background:** 3-5 developers supporting (and building new) internal applications for a non- software company. We use TFS although I don't think that matters much for my question. I want to be able to develop a deployment pipeline and adopt continuous integration / deployment techniques. Here's what our source tree looks like right now. We use a single TFS Team Project.               $/MAIN/src/     $/MAIN/src/ApplicationA/VSSOlution.sln     $/MAIN/src/ApplicationA/ApplicationAProject1.csproj     $/MAIN/src/ApplicationA/ApplicationAProject2.csproj     $/MAIN/src/ApplicationB/...     $/MAIN/src/ApplicationC     $/MAIN/src/SharedInfrastructureA     $/MAIN/src/SharedInfrastructureB      **My Goal (a pretty typical promotion pipeline)**   1. When a code change is made to a given application I want to be able to build that application and auto-deploy that change to a DEV server.      * I may also need to build dependencies on Shared Infrastructure Components.     * I often also have some database scripts or changes as well   2. If developer testing passes I want to have an manually triggered but automated deploy of that build on a STAGING server where end-users will review new functionality.   3. Once it's approved by end users I want to a manually triggered auto-deploy to production **Question:** How can I best adopt continuous deployment techniques in a multi-application environment? A lot of the advice I see is more single-application-specific, how is that best applied to multiple applications?   * For step 1, do I simply setup a separate Team Build for each application?   * What's the best approach to accomplishing steps 2 and 3 of promoting latest build to new environments?   * I've seen this work well with web apps but what about database changes


To write or not to write: Frameworks

Today some friends and I started discussing frameworks.. Some of us strongly believe that in 99.9% of cases, writing a new framework is a bad idea. We believe that probably some of the millions of frameworks out there should fit our problem, and if not, some hack, API, or configuration should be enough. If not, we think that contributing to some framework, suggest features or something like that should be the best solution. The 0.1% is when none of the frameworks fit to our case. But, some of us say that it is better to have an "internal corporate framework" (for example), because it's faster to fix issues, creates a 100% fit with the app, because of the "learning" factor (when you improve your skills building a framework), etc. I think that to go out coding frameworks like there's no tomorrow is not the right way. I've seen a lot of small teams building their own framework just to spread the word: "we built our own framework, we rule, bro". Generally, the framework is crap, without any documentation, and only works for their own applications. Opinions are opinions, devs are devs, without the intention to start any kind of flame war, I ask: What do you think about that? What parameters you consider when building a framework? What do you think about all this?


HTML5/Javascript + Web Services

If developing web applications using **ASP.NET MVC** or **Ruby on Rails** make the application use the **MVC design pattern** , then if I build my application using only **HTML5/Javascript + backend webservices** (like WCF rest), then which design pattern will my application follow?


What level of detail to use in an interface members descriptions?

I am extracting interfaces from some classes in .NET, and I am not completely sure about what level of detail of description to use for some of the interface members (properties, methods). An example:               interface ISomeInterface     {         /// <summary>         /// Checks if the object is checked out.         /// </summary>         /// <returns>         /// Returns true if the object is checked out, or if the object locking is not enabled,         /// otherwise returns false.         /// </returns>         bool IsObjectCheckedOut();     }          class SomeImplementation : ISomeInterface     {         public bool IsObjectCheckedOut()         {             // An implementation of the method that returns true if the object is checked out,             // or if the object locking is not enabled         }     }      The part in question is the `<returns>...</returns>` section of the `IsObjectCheckedOut` description in the interface. Is it ok to include such a detail about return value in the interface itself, as the code that will work with the interface should know exactly what that method will do? All the current implementations of the method will do just that. But is it ok to limit the possible other/future implementations by description this way? Or should this not be included in the interface description, as there is no way to actually ensure that other/future implementations will do exactly this? Is it better to be as general as possible regarding the interface in such circumstances? I am currently inclined to the latter option.


Is there a design pattern for chained observers?

Several times, I've found myself in a situation where I want to add functionality to an existing `Observer`-`Observable` relationship. For example, let's say I have an `Observable` class called `PriceFeed`, instances of which are created by a variety of `PriceSources`. `Observers` on this are notified whenever the underlying `PriceSource` updates the `PriceFeed` with a new price. Now I want to add a feature that allows a (temporary) override to be set on the `PriceFeed`. The `PriceSource` should still update prices on the `PriceFeed`, but for as long as the override is set, whenever a consumer asks `PriceFeed` for it's current value, it should get the override. The way I did this was to introduce a new `OverrideablePriceFeed` that is itself both an `Observer` and an `Observable`, and that decorates the actual `PriceFeed`. It's implementation of `.getPrice()` is straight from Chain of Responsibility, but how about the handling of Observable events? When an override is set or cleared, it should issue it's own event to `Observers`, as well as forwarding events from the underlying `PriceFeed`. I think of this as some kind of a chained observer, and was curious if there's a more definitive description of a similar pattern.


Can lack of "bit parity" between web server and DB server impact performance?

I had a meeting with a software vendor today about their recommended infrastructure for deploying a particular application. The application needs two servers: an app server for server web pages (.NET, Windows), and a database (SQL Server). The vendor claimed that these two servers had to have "bit parity". What they meant by this is that if the app server was 32 bit the SQL Server should be 32 bit, or if the app is 64 bit the SQL Server is 64 bit. Otherwise performance will be negatively impacted. This seems ludicrous to me. The servers are independent and only communicate over a network. Network protocols have nothing to do with the "bit-ness" of the processor on either server. Am I in the wrong? Is there a reason where a mismatch actually could negatively impact performance? NOTE: I know that certain apps might run faster or slower in 32 bit vs. 64 bit. But the vendor was saying that the _mismatch_ between web server and DB server causes a problem. This is the statement I'm questioning.


Strategy to find bottleneck in a network

Our enterprise is having some problem when the number of incoming request goes beyond a certain amount. To make things simpler, we have N websites that uses, amongst other, a local web service. This service is hosted by IIS, and it's a .NET 4.0 (C#) application executed in a farm. It's REST-oriented, built around OpenRasta. As already mentioned, by stress testing it with JMeter, we've found that beyond a certain amount of request the service's performance drop. Anyway, this service is, amongst other, a client itself of other 3 distinct web services and also a client for a DB server, so it's not very clear what _really_ is the culprit of this abrupt decay. In turn, these 3 other web services are installed in our farm too, and client of other DB servers (and services, possibly, that are out of my team control). What strategy do you suggest to try to locate where the bottleneck(s) are? Do you have any high-level suggestions?


How can I implement Paxos to develop a project for consensus in distributed systems?

I have to implement Paxos algorithm, to experiment on consensus in an asynchronous distributed system. Following is a pdf related to Paxos: http://www.cs.utexas.edu/users/lorenzo/corsi/cs380d/past/03F/notes/paxos- simple.pdf I am confused from where can i start my implementation? I am a Java programmer but my teacher suggested me to use Parsec (http://pcl.cs.ucla.edu/projects/parsec/) , which needs me to code in C. But another problem is, Parsec does not support GUI based implementation. I would like to see my implementation with a GUI. Is there any Java based simulation language for discrete-event simulation where i can implement Paxos algorithm for consensus? If no, then is there any other GUI based simulation language in C to implement Paxos?


Arguments for conforming to PSR-2

I am trying to convince the lead developer of an open-source project I'm contributing to, to conform to the PSR standards (PSR-2 in particular) created by the PHP Framework Interop Group. He is willing to adopt PSR-0 and PSR-1, but he is opposed to PSR-2. His argument is that PSR-2 is too inconsistent: opening braces for classes and methods MUST go on the next line, but opening braces for control structures MUST go on the same line. I believe that the difference between classes / methods at one side and control structures at the other is not an inconsistency, in fact they are different things. I also believe that consistency between different projects is far more important than treating classes / methods and control structures like they are the same, and that consistancy between projects should outweigh personal preferences... but I can't convince him. Are there any more arguments I can use to try to convince him to use PSR-2, instead of a seperate, yet-another coding standard?


Multiple conditions in a function using PSR

I'm trying use the PSR conventions in all my projects, but today I view some code of my co-worker and I disagree.               if ($cond == 1 AND $cond == 2) {         // to-do     }      For me, the correct is:               if (($cond == 1) AND ($cond == 2)) {         // to-do     }      **What is the correct use of the PSR?**


Is it better to blindly match the project requirements or to match the spirit of the project requirements

You know what they're asking for. You know what they really want. However, technically the way they wrote it is with a litmus test of requirements that don't match what they want because they don't understand what they're asking for. Should it be a part of our job to match the spirit of the requirements, or match ridiculous requirements with this gut feeling that the requirements will change once they see the final result? I feel it's more ethical to determine what the user really wants, and find a solution with requirements as a guideline, but often I find others lose patience too much and just wants to give them what they technically ask for.


What's a good approach to adding debug code to your application when you want more info about what's going wrong?

When our application doesn't work the way we expect it to (e.g. throws exceptions etc.), I usually insert a lot of debug code at certain points in the application in order to get a better overview of what exactly is going on, what the values for certain objects are, to better trace where this error is triggered from. Then I send a new installer to the user(s) that are having the problem and if the problem is triggered again I look at the logs and see what they say. But I don't want all this debug code to be in the production code, since this would create some really big debug files with information that is not always relevant. The other problem is that our code base changes, and the next time, the same debug code might have to go in different parts of the application. **Questions** Is there a way to merge this debug code within the production code only when needed and have it appear at the correct points within the application? Can it be done with a version control system like git so that all would be needed is a `git merge`? P.S. The application I'm talking about now is .NET, written in C#.


What would you do if your client required you not to use object-oriented programming?

I am writing a program to simulate the activity of ants in a grid (PDF). The ant can move around, pick up things and drop things. The problem is while the action of the ants and the positions of each ant can be tracked by class attributes easily (and we can easily create many instances of such ants) my client said that since he has a background in functional programming he would like the simulation to be made using functional programming. To be clear, the original words from the client is "no class" only, but not "functional programming". So I assume he doesn't mean functional programming and I can do it imperatively. Additionally, I have no prior experience in functional programming. However, I think it's beneficial to focus on this question being particularly about a functional programming requirement than just simply "do it imperatively." How would you handle this situation? Would you try to persuade your client that using object-oriented programming is much cleaner, try to follow what he required and give him poor-quality code, or do something else?


Updating an Entity through a Service

I'm separating my software into three main layers (maybe _tiers_ would be a better term):   * Presentation ('Views')   * Business logic ('Services' and 'Repositories')   * Data access ('Entities' (e.g. ActiveRecords)) ## What do I have now? In Presentation, I use read-only access to Entities, returned from Repositories or Services, to display data.               $banks = $banksRegistryService->getBanksRepository()->getBanksByCity( $city );          $banksViewModel = new PaginatedList( $banks ); // some way to display banks;                                                    // example, not real code      I find this approach quite efficient in terms of performance and code maintanability and still safe as long as all write operations (create, update, delete) are preformed through a `Service`:               namespace Service\BankRegistry;          use Service\AbstractDatabaseService;     use Service\IBankRegistryService;     use Model\BankRegistry\Bank;          class Service         extends AbstractDatabaseService         implements IBankRegistryService     {         /**          * Registers a new Bank          *          * @param string $name                  Bank's name          * @param string $bik                   Bank's Identification Code          * @param string $correspondent_account Bank's correspondent account          *          * @return Bank          */         public function registerBank( $name, $bik, $correspondent_account )         {             $bank = new Bank();                  $bank                 -> setName( $name )                 -> setBik( $bik )                 -> setCorrespondentAccount( $correspondent_account );                       if( null === $this->getBanksRepository()->getDefaultBank() )                 $this->setDefaultBank( $bank );                       $this->getEntityManager()->persist( $bank );                  return $bank;         }                   /**          * Makes the $bank system's default bank          *          * @param Bank $bank          * @return IBankRegistryService          */         public function setDefaultBank( Bank $bank )         {             $default_bank = $this->getBanksRepository()->getDefaultBank();                    if( null !== $default_bank )                 $default_bank->setDefault( false );                  $bank->setDefault( true );                  return $this;         }     }      ## Where am I stuck? I'm struggling about **how to update** certain fields in `Bank` Entity. **Bad solution #1** : Making a series of setters in `Service` for each setter in `Bank`; - seems to be quite reduntant, increases `Service` interface **complexity** and proportionally decreases it's **simplicity** \- something to avoid if you care about code maitainability. I try to follow **KISS** and **DRY** principles. **Bad solution #2** : Modifying `Bank` directly through it's native setters; - really bad. If you'll ever need to move modification into the `Service`, it will be pain. Business logic should remain in Business logic layer. **Plus** , there are plans on logging all of the actions and maybe even involve user permissions (perhaps, through decorators) in future, so **all modifications should be made only through the`Service`**. **Possible good solution** : Creating an `updateBank( Bank $bank, $array_of_fields_to_update)` method; - makes the interface as simple as possible, but there is a problem: one should **not** try to manually set `isDefault` flag on a Bank, this operation should be performed through `setDefaultBank` method. It gets even worse when you have **relations** that you don't want to be directly modified. Of course, you can just limit the fields that can be modified by this method, but **how do you tell method's user** what they can and cannot modify? Exceptions?


Best Upper Bound & Best Lower Bound of an Algorithm

I am studying for a final exam and I came past a question I had on an earlier test. The questions asks us to find the minimum value in an unsorted array of integers. We must provide the best upper bound and the best lower bound that you can for the problem in the worst case. First, in such an example, the upper and lower bound are the same (hence, we can talk in terms of Big-Theta). In the worst case, we would have to go through the whole list as the minimum value would be at the end of the list. Therefore, the answer is Big-Theta(n). Is this a correct & good explanation?


Dissection of Google indexing services

There are more than a few questions that hop into mind when someone thinks about Google's indexing services. Jeff Atwood wrote about them at The Elephant in the Room: Google Monoculture and Trouble In the House of Google. I have two questions:   * How does google index dynamic websites? This site has dynamic pages, `QUESTIONS`, `TAGS`, `USERS`, `BADGES`, `UNANSWERED`, `ASK QUESTION`. The content of these pages is dynamically generated, therefore we access the dynamic content and not the physical files on the server. But how does Google shows every question of the site or other dynamic websites?   * What does Google index and keep on its servers? Does it copy the complete page into its server or just the title, meta tags and body?


What is the supposed productivity gain of dynamic typing?

I often heard the claim that dynamically typed languages are more productive than statically typed languages. What are the reasons for this claim? Isn't it just tooling with modern concepts like convention over configuration, the use of functional programming, advanced programming models and use of consistent abstractions? Admittedly there is less clutter because the (for instance in Java) often redundant type declarations are not needed, but you can also omit most type declarations in statically typed languages that use type inference, without losing the other advantages of static typing. And all of this is available for modern statically typed languages like Scala as well. So: what is there to say for productivity with dynamic typing that really is an advantage of the type model itself? Clarification: I'm more interested in big / medium sized projects than in quick hacks. :-)


Most efficient way for snapshotting Windows (no VM)

As the software I'm writing is using instrument I/O, I cannot use virtual machines to test my software in different configurations. Therefore I'm looking for the best way to make snapshots at different states, and restore them quickly for tests. What tools do you use? Right now I see:   * Windows system restore   * Clonezilla (not in love with it, sometimes failed for me)   * Acronis TrueImage What are your advice?


Does inserting/removing random characters in a string count as cryptography?

I'm making an iOS game. All developers need to determine whether their app uses cryptography or not. My game saves files in the Documents folder. They are .plist files representing dictionaries. They are encoded in base 64. From what I gather, encoding is not encrypting. So we're fine there. However, the _values_ inside the dictionary (after decoding) are a bit tricky. Suppose that your score is `250`. In the dictionary the value is a string like:               @2@5@0@      So for the game to read your score, it removes the `@` characters (and when saving the game, it puts them back). That's just an example. Does _that_ count as cryptography? **NOTE** : I'm not asking about Apple's policies. I mentioned it for context.


How to promote an open-source project?

First of all, I apologize if this is the wrong section of network to post this question. If it is, please feel free to move it to more appropriate location... Question: I would like to hear your ideas regarding the ways of open source projects being started and run. I have an open-source content management system project and here some questions arise: How should I act? Shall I come up with a viable pre-alpha edition with working front- and back-ends first and then announce the project publicly? Or shall I announce it right away from the scratch? As a developer I know that one should use versioning system like Git or SVN, which I do, no problems there. And the merit of unit-testing is also something to remember, which, to be frank, I am not into at all... Project management - I am a beginner in that, at best. Coding techniques and experiences such as Agile development is something I want to explore... In short, any ideas for a developer who is new to open-source world, is most welcome.


Where Can I List My Opensource Project?

> **Possible Duplicate:**   >  How can I get the word out about a new (open-source) library I've > developed? I have hosted my latest project, a JVM-based MIDI processor/API called Mjdj MIDI Morph, on Github (here and here). Now I need to bring some interest to it, even if it's negative interest (so I can improve it). I've looked up open source list on Google and end up with such things as this page on Wikipedia, which makes it quite clear that they don't want your project if it's new. Where should I list my project? Short of adwords and talking it up in forums and trade shows, where should I submit my URLs?


I released open source code that is useable to other programmers. How do I let them know about it?

I have a tiny project (<1k but let's say its <5k of lines). I made it open source and put it on github. I did this once before and I didn't get a single download nor fork but that was very specific and this tiny project is very useable to other programmers. It's open source (let's say LGPL, GPL, public domain or somewhere in between these). What can I do other than let it rot on my computer/online while only I use it? I'll keep this as generic as possible and won't link my stuff.


How to make my open source project known?

I have a simple project, which enable to record the voice and execute associated commands. I think it can be an interesting and useful project. I don't know how to make it known. I already wrote an article and I published it on hackernews but it wasn't very popular. What can I do to make my project known?


How can I get the word out about a new (open-source) library I've developed?

I'm finishing up a personal project in which I've implemented a library that I expect others may want to use. Without going into too much detail, the library provides a cross-platform interface for parsing a particular type of file, where none had existed before (at least in this language). The project was fun and rewarding in itself, but I think it would be a shame if it were never considered by other developers due to ignorance. How can I appropriately spread the word about this library? My current plan is to:   * Host a webpage with source, documentation, usage, and/or samples   * Respond to SO questions asking the question "where is this tool?"   * Contact a few key members of the related field and give them a heads up Do you think these steps are reasonable? What else might you do yourself?


Getting attention for my open sourced project

> **Possible Duplicate:**   >  How to promote an open-source project? I've done quite a lot of work in my spare time on a project that was mostly for my own learning experience and I'm quite pleased with the results. I've used github as a source control management, so the code is already public in a sense. The code in question is a library that is quite specialized in it's application, and pretty well commented and understandable. It would probably be a good resource for students learning about the algorithms being used. What I'm really looking for is the best way to see if there is any audience for what I've done. It's no big deal if there isn't but if there are I'd like people to know about my code, and find it if they are searching for something similar. How to go about this task in the best way? I do have a blog and I intend to introduce the code there, but the audience is so far quite small - mostly co- workers and friends. I'm also unsure about going to specialized sites and advertise, especially as I'm not really part of a community around these types of libraries. Any thoughts and ideas would be greatly appreciated! Thank you for reading. **Edit:** I'm not sure if I should post a link to the project in question on github, or refrain. It's not my intention for this question to come off as advertising. Also, it's amazing how I always find good links _after_ I posted my question. http://producingoss.com/ seems like a good fit.


Gremlin -- do I have to know Java/Groovy

This is the excerpt from the project's Github page. > _Gremlin provides graph traversal related syntactic sugar to Groovy. Groovy > provides dynamic language syntactic sugar to Java. Realize that anything you > can do in Java or Groovy can be done in Gremlin._ The documentation keeps referring to Groovy & Java. I need to learn it but I am not a member of Java family -- and will likely never be. Can I still learn Gremlin? Can someone point me to some docs/articles that explain Gremlin without assuming Groovy or Java acquaintance?


Do You Have To Know CIL To Make A Compiler for .NET?

Assume one wants to create a simple .NET language, or slightly more difficult, a compiler for an existing .NET language. Do you absolutely **need** to be familiar with the CIL (Common Intermediate Language) to implement a compiler? And do you have to translate the syntax of your language to CIL by hand? Or is there another (more preferable) way? If not, what is the best way to learn CIL and especially to learn how to translate High-Level code to CIL?


What are some examples of "wartiness" making a programming language more useful?

From the accepted answer to "Why is Lisp useful?": >  5\. Wartiness. The real world is messy. Pragmatic coding winds up having to > either use or invent messy constructs. Common Lisp has sufficient wartiness > that it can get stuff done. This thought has occurred to me, too. I'm currently developing an application whose backend I chose to write in Haskell, and whose frontend is in PHP. My experience has been that dealing with messy code in PHP is _much_ easier than dealing with messy code in Haskell. However, it's my own code, and my PHP code probably isn't all that bad. A simple example of "wartiness" is PHP's `==` (equality) operator. You know, the type of equality where `'' == 0` is true. Since I'm wary of `==`, I often choose to use PHP's `===` (strict equality) operator instead:               $is_admin = ($gid === 24 || $gid === 25);      However, the above usage turned out to be wrong. The `$gid` value came from the database, and is still a string. This time, the strict equality operator bit me, and I would have saved myself a few minutes by simply saying:               $is_admin = ($gid == 24 || $gid == 25);      Consider another interesting identity:               php> var_dump('0012345' == '12345');     bool(true)      What the heck?! `==` on two strings isn't even string comparison! However, consider if the user is given an ID card that says `0012345`, but the database ID is simply `12345`. Users may have trouble logging in to your application if you chose to use `===`. Sure, you'll get a bug report, and you'll be able to make your application correct rather than relying on this obscure feature. But it'll take more time. I'd rather spend that time outside. It's a really nice day. By contrast, here's an example of wartiness that is _not_ helpful in most cases:               js> parseInt(031);     25      What are some more concrete examples where "wartiness" helps you Get Things Done? Please explain why; don't just list features Haskell doesn't have. Another way of putting it: what are some warty language features to be aware of, and how can we use them to save time?


When (and when not) to use Wordpress?

For the sake of simplicity, my question is focused specifically on Wordpress instead of focusing on all Content Management Systems including Joomla, Drupal, Concrete5, or you-name-it. Wordpress is becoming ever more popular. You can extend it's feature set with widely available plugins or you can simply design your own plugins if you know a little bit about programming. There are more and more "big" (read well- known, famous or credible) websites that are built using Wordpress. For some examples, take a look at this link. Abraham Maslow once said, "It is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail." I see this tendency within the community of Wordpress developers, and while I value their knowledge and advice on what can be done using Wordpress, I'm afraid that asking them my question about "when to use Wordpress" will only be met with a blank stare that says "is there a time you would not use Wordpress?" This fact is very visible when you do a google search for "when to use wordpress". The situation does improve slightly if you search for "when not to use wordpress". So my question is, in this year 2011, what criteria should best help a web developer determine whether or not to use Wordpress for a given project? **Edit1:**   After some more searching I found this excellent post on this topic: http://wordpress.stackexchange.com/questions/10594/when-should-we-not- recommend-a-client-use-wordpress


Mixing jQuery with JavaScript

I just asked this question at SO about some bugginess I am experiencing with jQuery and IE8, and someone commented that he was appalled that I would mix JavaScript with jQuery (he has since deleted his comment for some reason). This person had a high reputation, relative to mine (3000+), so I don't want to ignore his criticism. I'm still relatively new to web development, and I mostly work alone, so I wasn't aware that this could be a problem. Why should mixing the two be avoided?


svn - when will I see conflicts?

I am just starting a new position and using **svn** rather than **git** (my favorite). With **svn** if there are any conflicts will I see them after an svn update or after an (attempt) to svn commit? In other words will an **svn update** merge remote changes into my current (uncommited) working copy? I want to be sure not to mess up before my first **svn commit** if things are not good as I am new to this system! :) Obviously I have also made a manual copy of my new code in case I run into any issues :) fyi, I am on Ubuntu 11.10


How can I ensure a method is called only once when using a API?

In general, if I am using an API whose methods have side-effects that I only want to occur once, how can I guarantee that my own application only calls them once even if an error occurs before it can register a response? For example, if I am calling a payment processing API once each month for a subscription service, how can I ensure that I don't double-bill if I create a new transaction and the application suffers a fatal error before I get the response from that? It seems like cooperation with the API would be a solution:               t = Transaction.new(user, price, etc);     if(t.persistToLocalDatabase()){ t.beginRemoteProcessing(); }      Is there a way to solve this for the case where I have no control over the API and it begins processing on transaction creation?


Is this a good design in C++?

Is it a good idea to replace getters and setters with a single function returning a reference? For example, instead of this,               class Person {       std::string name;     public:       std::string GetName() { return this->name; }       void SetName(std::string& toSet) { this->name = toSet; }      };      Is this a good idea,               class Person {       std::string name;     public:       std::string& Name() { return this->name; }     };     ...     ...     Person p;     p.Name() = "Joe"; // Write.      std::string local = p.Name(); // Read.      Does the second code have some problem?      But in C#, methods return object by reference. For example,               class Person     {         string name;         public Person(string _name) { this.name = _name;  }         public string GetName()         {             return this.name;         }         public void SetName(string _name)         {             this.name = _name;         }     };          class Company     {         Person manager;         public Company()         {             this.manager = new Person("Mr. K");         }              // The Person object is returned by reference.         // This is equivalent to "Person& GetManager()" in C++.         public Person GetManager()          {             return this.manager;         }     };     ...     ...     Company comp = new Company();          // Equivalent to,     // Person& p = comp.GetManager();     Person p = comp.GetManager(); // p is a reference to comp.manager     p.SetName("Mr. L");  // This statement changes comp.manager.name          Console.WriteLine(comp.GetManager().GetName()); // Prints "Mr. L"      In the above code, `comp.manager.name` wouldn't have changed if the method `GetManager()` returned `Person` by value. So, this code isn't dependent on return value optimization.   Isn't this code a violation of encapsulation?


How to test my knowledge?

I am a senior in high school planning on majoring in Computer Science in college. I have been programming for a number of years. However, I have no idea how I stack up to professionals. What would be a way for me to measure my skills in specific languages? I currently use Java, C#, Ruby, and C.


Creating database connections - Do it once or for each query?

At the moment I create a database connection when my web page is first loaded. I then process the page and run any queries against that conection. Is this the best way to do it or should I be creating a database connection each time I run a query? p.s It makes more sense to me to create 1 connection and use it but I don't know if this can cause any other issues. I am using C# (ASP.NET) with MSSQL.


Keeping database connection

Say you are developing a desktop application that extensively uses a database, should you have one handle for the database that the entire app references? Or should you open a connection when you need data, get the data, and then close the connection when data isn't necessary.


Giving apprentices appreciation of SOLID principles

Experienced developers typically have an appreciation of the SOLID (or other) principles - why we have them, how they help, ways of adhering to them etc. This may be as a result of having written poor code in the past, then written good code (where good is adhering to SOLID principles) and seen the tremendous difference it makes, or otherwise had the time and experience to see their value. **How can we begin to instil an appreciation of these things in to apprentice developers?** Currently, at work, I have a group of apprentice developers straight of out college (UK, 18+), with no CS or real programming background. The company has a decent training programme for them to run through, but I feel it lacks the induction to writing high quality code that we would eventually like for them to produce. My current approach to teaching them about these things is to flag it up in code reviews when I see it. For example, when I see a class (or function) which has more than a single responsibility, I do my best to explain the single responsibility principle (why we have it, how it helps), show them where the multiple responsibilities in their code lay, then talk to them about how they might separate that out. However, that approach doesn't seem to be sticking. I'm still seeing plenty instances of exactly the same thing I flagged up in code review. **Are there better ways of explaining and giving appreciation of the SOLID principles? Or is this simply something which comes with time and experience?**


Traffic splitter on a single server for 50+ krps

I am building a "splitter" for web traffic: a web server that will receive an HTTP request, forward it to two backend servers, choose the best response (for which it needs to parse all of them) and return it to the original requestor. (Just to clarify: it is not a proxy with several backends; each request is forwarded to all backends, and then only one response is returned.) It will need to handle at least 50 thousand requests per second (or 50+ krps) on a single server. Together with a colleague we have built several versions of the splitter. Here are the results:   * Node.js (`http` library): goes up to 6.9 thousand requests per second (6.9 krps).   * Go (`net/http` library): up to 12 krps.   * Erlang (`misultin` and `lhttpc` libraries): up to 7.3 krps.   * Clojure (`http-kit`): 13 krps. None of them are even close to the requirement. According to e.g. the single query of the Web Framework Benchmarks by TechEmpower, which might be roughly equivalent to the splitter, there is room for improvement. The big question is, what should we try next? **Technical details:** The server should handle at least 50 krps on a single server, standard hardware. The requests are POST messages with JSON-encoded bodies of about 1~3 KB, and the responses have similar size. Each request does not need to be parsed, but it can be passed along as is; in the response, at least one specific JSON field needs to be parsed. Each request has a very strict timeout that is between 80 and 450 ms, depending on the URL; if any backend takes longer than that, the server should forget about it and use the remaining backend. If no valid responses are received in time, the server will respond with a 204 No content. **Testing details:** For simplicity, let us say that all requests are all coming from an HAProxy server in front of it, so an Apache `ab` or `wrk` load tester is appropriate. It will run on Amazon EC2, so it should use multiple cores efficiently. For reference let us say it is a c3.2xlarge instance. Both backend servers should reside on a different machine than the splitter (possibly two separate servers, if needed), and ideally the load tester should also be on another machine. It is important to ensure that neither the load tester nor the backends are the bottlenecks here, which is as simple as load testing one of the backends directly and verifying that it gives much better results than the splitter. Results for `wrk` testing the servers returning a constant string:   * Node.js (`http` library): 43 krps.   * Go (`net/http` library): 73 krps.   * Erlang (`misultin` and `lhttpc` libraries): 59 krps.   * Clojure (`http-kit`): I don't have the number, but > 20 krps. Some days ago I asked a question about a splitter-like service in Go, and the answer there allowed me to go up to 6 krps. Further optimizations increased this number to about 12k, although I am not sure that the results will hold in the general case. For instance: I was returning a constant response and not parsing the JSON responses. I am not really sure if our results are reasonable, or if we should be getting much better results with the frameworks we have tried. According to the Web Framework Benchmarks, C++ (with CPoll based C++ server pages) and Java (multiple frameworks) are kings of the game when it comes to rps; but given the effort required to set up, build and test the services in each new framework we want to be sure that we are not getting into any dead ends here. The benchmark above is not really equivalent to our problem; and it is hard to get rps numbers for this kind of proxy-like traffic. I should clarify that it _should_ be possibly to reach the goal, since HAProxy can forward 33 krps with a single core; using the 8 cores in a c3.2xlarge instance, and with anything remotely resembling linearity, it should be within the realms of possibility to reach 50 krps doing two forwards of each request. Writing a multicore web server in C is not in our plans except as a last option, though. This question has been interpreted as too broad on StackOverflow and here by eager editors. So I will reformulate with a clear, straightforward question: Have you built or read about anything similar, with peak performance numbers? (For instance a proxy server for HTTP traffic, even though it would only forward each request to one backend.) Please detail in what language, with what library or framework, and how many requests per second were obtained with a single server.


ASP.NET MVC create a draft without persisting to DB

I have a requirement to allow users to suggest updates to their profiles on a site I'm working. They would be able to view their profile details, then click on and "edit" button, which would basically make a copy of all their data contained in a handful of one-to-many related DB tables. They can then add or remove items and update various text fields before saving the draft. Upon saving, an administrator would have to approve this change before the new data is actually published onto the live site. I currently have an identical set of tables for live data and drafts (and history, but that's not important). My difficulty is that the client doesn't want an actual draft entry created in the drafts db structure until the user has hit "save". A user would be able to perform CRUD operations against all the data, including uploading new images, but I am not allowed to touch the DB unless they're ready to commit these updates. My great problem is that I have no idea how to begin developing what seems to the client to be a very simple thing, even though it's technically quite challenging. I also can't seem to make the client understand that hitting the "Cancel" button next to the save button would remove the entry plus all its related data from the DB, making the problem moot in my humble opinion. So, the question is such: is there a way to phrase my objection in such a way that the client can understand what I'm getting at. Or failing that, what would be a good way of developing such a session-stored object?


Keywords for defining constructs in programming languages

I'm designing a language conceptually similar to Go. In Go, for example, the keyword `func` is used for defining functions:               func abs (a int) uint { ... }      Same for defining types. However, I was thinking of a grammar that doesn't consider these keywords. For example:               abs (a int => uint) { ... }      Or, for structures:               Tree {size int; age int}      What's wrong with such a syntax? Are there some potential problems that could be encountered? For example, I thought that if there was a construct that would use the same grammar as a struct, such as an interface, it would be vague (is this a struct or an interface)?


Creating a compiler in .net

I have read about compiler construction some concepts. What is understood is that   1. You need a lexer that divides your program statements into tokens.   2. You need to check and identify tokens into known types.   3. You have to create a grammar and check if your tokens fit between the grammar defination.   4. You have to create a AST syntax tree . I am stuck at the parser and AST step , I am trying to create a simple language compiler. How can I create a parser and AST for simple statements like var a = 10 * 20; ... etc.


Ongoing confusion about ivars and properties in objective C

After almost 8 months being in ios programming, I am again confused about the right approach. Maybe it is not the language but some OOP principle I am confused about. I don't know.. I was trying C# a few years back. There were fields (private variables, private data in an object), there were getters and setters (methods which exposed something to the world), and properties which was THE exposed thing. I liked the elegance of the solution, for example there could be a class that would have a property called `DailyRevenue`...a float...but there was no private variable called `dailyRevenue`, there was only a field - an array of single transaction revenues... and the getter for `DailyRevenue` property calculated the revenue transparently. If somehow the internals of daily revenue calculation would change, it would not affect somebody who consumed my `DailyRevenue` property in any way, since he would be shielded from getter implementation. I understood that sometimes there was, and sometimes there wasn't a 1-1 relationship between fields and properties. Depending on the requirements. It seemed ok in my opinion. And that properties are THE way to access the data in object. I know the difference betweeen private, protected, and public keyword. Now lets get to Objective-C. On what factor should I base my decision about making something only an ivar or making it as a property? Is the mental model the same as I describe above? I know that ivars are "protected" by default, not "private" as in C#.. But thats ok I think, no big deal for my present level of understanding the whole iOS development. The point is ivars are not accessible from outside (given I don't make them public.. but I won't). The thing that clouds my clear understanding is that I can have `IBOutlets` from ivars. **Why am I seeing internal object data in the UI?** * _Why is it ok?_ * On the other hand, if I make an `IBOutlet` from property, and I do not make it readonly, anybody can change it. **Is this ok too?** Let's say I have a `ParseManager` object. This object would use a built in `Foundation` framework class called `NSXMLParser`. Obviously my `ParseManager` will utilize this `NSXMLParser`'s capabilities but will also do some additional work. Now my question is, **who should initialize this`NSXMLParser` object and in which way** should I make a reference to it from the `ParseManager` object, when there is a need to parse something. **A) the`ParseManager`** - **1)** in its default init method (possible here ivar - or - ivar+ppty) - **2)** with lazyloading in getter (required a ppty here) **B) Some other object** \- who will pass a reference to `NSXMLParser` object to the `ParseManager` object. - **1)** in some custom initializer (`initWithParser:(NSXMLPArser *)parser`) when creating the `ParseManager` object.. A1 - the problem is, we create a parser and waste memory while it is not yet needed. However, we can be sure that all methods that are part of `ParserManager` object, can use the ivar safely, since it exists. A2 - the problem is, the `NSXMLParser` is exposed to outside world, although it could be read-only. Would we want a parser to be exposed in some scenario? B1 - this could maybe be useful when we would want to use more types of parsers.. I don't know... I understand that architectural requirements and language is not the same. But clearly the two are in relation. How to get out of that mess of my? Please bear with me, I wasn't able to come up with a single ultimate question. And secondly, it's better to not scare me with some superadvanced newspeak that talks about some crazy internals (what the compiler does) and edge cases.


What are best practices when switching between projects/coming back to projects frequently?

The nature of my job is that I have to switch back and forth between projects every few weeks. I find that one of the biggest impediments to my productivity is the ramp-up time to getting all the relevant pieces of code "back in my head" again after not seeing it for a period. This happens to a smaller and larger extent for briefer breaks / longer breaks. Obviously, good design, documentation, commenting, and physical structure all help with this (not to mention switching between projects as infrequently as possible). But I'm wondering if there are practices/tools that I may be missing out on. What are your specific practices for improving on this?


Notify client about changes in database in java

I've been searching around for the answer to this question, but haven't been able to find a solution. I am working on a distributed client-server system that uses TCP. The program's functions is to transfer money to an from the server, but also between the clients, a sort of MobilePay. When one client wishes to transfer money to another client, that client will need to accept the transfer before it is succeeded (one of the systems requirements). So, my problem is, i would like the client to get notified (preferably through a message dialog) whenever a transfer is ready to get accepted. All the payments/transfers is stored in a SQL table. I would like the client to get notified when there is a pending payment/transfer in his/hers name, that is, when a new row (with the clients name as receiver) in the transfer table is added, in stead of the client needing to actively see if there is any pending payments (as it is now) Can anybody help my how to get around this problem Thanks in advance Best regards


Is it bad interview practice to have candidates write a linked-list implementation?

Reading this site and SO I've seen many stories of interview questions and answers saying a candidate had to implement a linked list from scratch. Usually this is a "gimme" exercise for programming role candidates like writing FizzBuzz. The idea is that if the candidate can't do this, they can't program and should be rejected almost immediately. However, I can't help but think this could be a poor practice for the following reasons:   * Modern higher level languages like C# and Python natively use lists extensively; writing your own linked list object would be only required under unusual circumstances and even then probably ill-advised.    * Lower level languages like C++ have standard libraries with iterators/list containers and objects.    * In light of the first two points, coders can go years without even thinking about implementing a list (linked, doubly-linked, etc) themselves. Some may not even really see such things since college days.   * Computing power also isn't the factor it was years ago, so efficiency via pointers isn't the issue it used to be (in general).    * A simple web search of something like "linked list example" would bring up plenty of code examples that could just be memorized and spat back out, not really indicating the true competence of the applicant.  I should say that using a linked list to lead to **open-ended** questions/discussions of candidates' problem solving/critical thinking abilities is mostly likely a really good interview practice. Any way an interviewer can really see what an applicant is like and how they think is massively beneficial. I think this binary approach of "no linked list code, no job" for programmers working on a desktop or web application is a bit outdated. It could also be quite harmful; a candidate who can't remember how to properly work with the head of a list could be an otherwise excellent coder and co-worker and be lost in the mix. Thoughts? **EDIT** : There are many (good) comments suggesting that whether this is a good or bad question to ask depends on the context of the job. I strongly agree, so let me rephrase this question: Implementing a linked-list is a common interview question for a wide range of coding jobs, similar to questions like FizzBuzz or writing a recursive function for calculating factorials. Does this question have enough utility to be used commonly for evaluating programming candidates across the board? Or should considered a bad question to ask except for "Senior Developer, Embedded Linked Lists Team" positions?


How to go about bring up the topic of bad programming practices with colleague

> **Possible Duplicate:**   >  How do I approach a coworker about his or her code quality? My development colleague is producing numerous blocks of code which I am a bit concerned doesn't really make for easy reading and potential issues in the future. I've tried giving little tips along the way without blantantly saying what I think but his technique never seems to change. I wouldn't normally be worried however we never identified any specific programming standards at the beginning of our project and it's now really starting to effect me a bit as I have to go through his code and try and debug it. A small snippet of just a small part of the code is as such.               foreach(DistributionRecord record in _manager.Distributions)     {         foreach (Engine.Model.DistributionModel.LossFromAtmosphericConditionsEnum NLossAt                         in Enum.GetValues(typeof(Engine.Model.DistributionModel.LossFromAtmosphericStructureEnum)))                         if (record.NlossAt.ContainsKey(NLossAt))                             if (record.NlossAt[NLossAt].ContainsKey(DistributionModel.LossFromAtmosphericConditionsEnum.Atvolat))                                 _indirect[GetIndirectSourceEnumFromEnterpriseType(record)] += record.NlossAt[NLossAt][DistributionModel.LossFromAtmosphericConditionsEnum.Atvolat]                                     * _manager.Scenario.Management.EmissionFactors.EmissionFactorIndirectBackgroundVolatisation;                          foreach (Engine.Model.DistributionModel.LossOffEnum lossOff in Enum.GetValues(typeof(Engine.Model.DistributionModel.LossOffEnum)))                         if (enterprise.NlossOff.ContainsKey(lossOff))                             if (enterprise.NlossOff[lossOff].ContainsKey(DistributionModel.LossTypesEnum.lossleach))                                 _indirect[GetIndirectSourceEnumFromEnterpriseType(record)] += record.NlossOff[lossOff][DistributionModel.LossTypesEnum.lossleach][NutrientEnum.N].Value                                     * _manager.Scenario.Management.EmissionFactors.EmissionFactorN2OIndirectBackgroundLeach;     }      I've talked to the boss and without blatantly saying it explained my concerns etc I don't know what else to do. Not sure if this is appropriate for this forum but any advice would be appreciated basically on how I can tackle this with my colleague. Or perhaps I'm just being unrealistic and gotta get with the real world in that this is just how some people write code and it's ok?


How to code review without offending other developers

I work on a team that does frequent code reviews. But it seems like more of a formality than anything. No one really points out problems in the code for fear of offending other developers. The few times I've tried to ask for changes were met with very defensive and reluctant attitudes. This is of course not good. Not only are we spending the time to code review, but we're getting literally zero value from it. Is this an issue that needs to be addressed by individual developers, or are there techniques for suggesting changes without stepping on other people's toes?


Starting Up Code Review Process Where there Previously Was None?

Any tips for a group needing to start code reviews? We have no real software engineering processes currently. I have been working as software engineer for 7 years and have never seen any real processes implemented at the various places I have worked, though many books espouse all kinds of engineering methodologies. The management supports the idea of enabling new processes, though there is some resistance from the senior engineer who has over 20 years of software engineering experience. We are a set of two programmers, with no software engineering manager. We report direct to the managing director of the Company. But we work on numerous software projects. The real reason why we have to begin performing code reviews is because of PA-DSS requirements. Therefore, I am pushing for us to do code reviews all around - not just on the payment application software.


How can I tactfully suggest improvements to others' badly designed code during review?

I'm a great believer in clean code and code craftsmanship, though I'm currently at a job where this isn't regarded as a top priority. I sometimes find myself in a situation where a peer's code is _riddled_ with messy design and very little concern for future maintenance, though it's functional and contains little to no bugs. How do you go about suggesting improvements in a code review when you believe there is so much that needs changing, and there's a deadline coming up? Keep in mind that suggesting the improvements be made _after_ the deadline may mean they'll be de-prioritized altogether as new features and bug-fixes come in.


How do you make people accept code review?

All programmers have their style of programming. But some of the styles are let’s say... let’s not say. So you have code review to try to impose certain rules for good design and good programming techniques. But most of the programmers don’t like code review. They don’t like other people criticizing their work. _Who do they think they are to consider themselves better than me and tell me that this is bad design, this could be done in another way. It works right? What is the problem?_ This is something they might say (or think but not say which is just as bad if not worse). So how do you make people accept code review without starting a war? How can you convince them this is a good thing; that will only improve their programming skills and avoid a lot of work later to fix and patch a zillion times a thing that hey... "it works"? People will tell you how to make code review (peer-programming, formal inspections etc) what to look for in a code review, studies have been made to show the number of defects that can be discovered before the software hits production etc. But how do you convince programmers to accept a code review?


Fixing a bug while working on a different part of the code base

This happened at least once to me. I'm working on some part of the code base and find a small bug in a different part, and the bug stops me from completing what I'm currently trying to do. Fixing the bug could be as simple as changing a single statement. What do you do in that situation?   1. Fix the bug and commit it together with your current work   2. Save your current work elsewhere, fix the bug in a separate commit, then continue your work [1]   3. Continue what you're supposed to do, commit the code (even if it ~~breaks the build~~ fails some tests), then fix the bug (and ~~the build~~ make tests pass) in a separate commit [1] In practice, this would mean: clone the original repository elsewhere, fix the bug, commit/push the changes, pull the commit to the repository you're working on, merge the changes, and continue your work. **Edit:** I changed number three to reflect what I really meant.


How to deal with someone who dislikes the idea of code reviews?

Obviously, if management buy into spending time with code reviews, then everyone has to do it. But there are always those guys (or gals) who resist with every ounce of their being. How do you effectively manage dealing with this scenario when dealing with it as the peer reviewer?


What to do if a team member delivers bad quality code?

I work as a kind of mixture of a Scrum Master and a team lead. In my team I have the problem that one of the members delivers bad quality. The code he produces is difficult to understand, difficult to maintain by anybody else than the guy himself. The solutions are more a "hack" (if not a botch) than a conceptual or elaborated work. And what is worst: he doesn't see it. He thinks he is a quite good programmer, when all the other team members are constantly complaining about his code - when he's not there (which is not so difficult since the guy works remote most of the time). They all avoid to tell him what they think about his work because they don't want to offend or demotivate him. What should I do?   * Try to tell him what the others think in 1-to-1 meeting? But I don't find it right to say "the others are complaining" when the others are not there and don't bring up their examples.    * Set up a team meeting and encourage the other members to tell what they think? But this feels like a tribunal to me. (And all against one is not fair.)   * Something else?


How to integrate code reviews to a team

I work in a team that keeps growing. However, there are no code reviews and I see this as a problem every day. There are people with really limited skills committing code to our repository that I believe should not commit. I'm not the team leader nor am I in a management position. I already proposed code reviews about 6 months ago and there was no feedback received. Nor were there any code reviews. I know code reviews would benefit everyone including the more experienced. Has anyone had any experience trying to integrate code reviews in a team? What did you propose and how did you do it?


How to do structured code reviews

We need to do pre-check-in code reviews. We are using Visual Studio and TFS. The built in code review functionality, is a bit odd to me. If I "reject" a check-in and comments what needs work, the review goes away. When the developer then makes the changes, he requests a new review, and I start all over again. Now, let's just say there are 10 files in this check-in. Maybe 7 of them were originally fine. Now, I have to review them again, as we are doing a brand new review. OR, I can track myself, what I have done. I can also, ONLY compare code with the original version, not the one from the reject review. So, my questions are:   1. what do you guys do?    2. What are your experiences with pre-checkin code reviews?


What does a code review look like?

I'm writing a code review process document for our team; we've never had a formal process in place although we do do some code review. I've found lots of articles talking about how important code review is, but I have one question in particular that I haven't found the answer to on the web... is the programmer part of the code review? In other words, should a code review be 2 people sitting together, going over what's in the code, or should it be 1 person looking at another person's code? Most often, our projects are done by a team of 2 people, so before it is sent to QA, should those 2 people just sit together and go over the entire project, including what each of them have written? Or, should they just both look at each other's code? I can see advantages to each. Finally, what happens with issues found during code review? Are they noted, and then sent back to the programmer? Or should the reviewer note them and then just fix them? Or is it ever ok to make a change and not even tell the programmer specifically what you found?


What feedback is or is not appropriate for a code review?

I am interested in hearing some guidelines as to what feedback is or is not appropriate for a code review. My team has a very unstructured review process and I am trying to suggest some ways to improve it. I am no expert so I hope to hear from you experts out there!   1. Should code review comments be limited to actual problems with the code?   2. Are criticisms about other LOC in the file appropriate even if those lines are not being modified? i.e., criticism of pre-existing code?   3. What about suggestions of different ways to solve the same problem? Should I suggest a new way only when a case can be made for it being better? How do I draw the line between contributing ideas but not sounding like a know-it-all?   4. In matters which are purely a difference of opinion, who should get the 'final say'? The author, the person who knows the code base the best, the person with the highest title or someone else?   5. Any other advice for ensuring the code reviews serve their purpose without unnecessarily blocking the developer's progress? Please, if you could, provide reasoning along with any answers. It will help this junior developer be able to really understand the best way to approach a code review.


Fixing bugs in other peoples code

I'm working with another programmer and we are always having issues with refactoring or changing each others code. Recently I had to fix a bug, but I pushed the changes before notifying him. He was very upset about it. Should I have talked to him about it before the push? This is a hobby project btw. What is the best way to change other peoples code when we don't have a project manager or coding standard?


How to make code-review feel less like a way to *shift* the responsibility?

Sometimes it seems to me that people ask for code-reviews just so they would be able to say "Xyz reviewed my code!"(1) when something broke. Question, is that ever the case? (Or is it just my imagination) If it is, how do I handle this? (1): What s/he really meant: It's Xyz's fault or something along those lines.


Getting coders to do code review

I am running a project where I pay developers to contribute to my semi open source project. My problem is that it is easy to hire developers, but it is very difficult to get anyone to do code reviewing. I have repeatedly attempted to get the senior developers to review the code of the junior developers. I have attempted to pay them more, give them higher status etc. But they just seem to want to code instead of reviewing code. Now I am considering forcing all developers that want to code, to also review code, but I have a feeling that it is a bad idea. My question is, therefore, how can I motivate capable people to review the code of others? How is this done in successful open source projects like Linux, PostgreSQL, LibreOffice etc.


What's the most effective way to perform code reviews?

I've never found the ideal way to perform code reviews and yet often my customers require them. Each customer seems to do them in a different way and I've never felt satisfied in any of them. What has been the most effective way for you to perform code reviews? For example:   * Is one person regarded as the gatekeeper for quality and reviews the code, or do the team own the standard?    * Do you do review code as a team exercise using a projector?   * Is it done in person, via email or using a tool?    * Do you eschew reviews and use things like pair programming and collective code ownership to ensure code quality?


How can I deal with a team member who duplicates code?

One of our team member duplicates code. Code duplication causes confusion among my team members reading his code, it causes bugs down the line when the duplicated segment is fixed in one location and not the others and it bloats the size of his code-base. I have discussed with him not to duplicate code. But he show excuses that it will delay our projects deadline if he refactors all the places where he made code duplication. How better can I deal with him?


How should code reviews be Carried Out?

My previous question has to do with how to advance code reviews among the developers. Here I am interested in how a code review session should be carried out, so that both the reviewer and reviewed are feeling comfortable with it. I have done some code reviews before and the experience has been very unpleasant. My previous manager would come to us --on an ad hoc basis-- and tell us to explain our code to him. Since he wasn't very familiar with the code base, whenever he would ask me to explain my code, I'd find myself spending a huge amount of time explaining the most basic structure of my code. As a result, each review would last much too long, and the process would leave both of us exhausted. Once I was done explaining my work, he would continue by raising issues with it. Most of the issues he raised were cosmetic in nature ( e.g, don't use `region` for this code block, change the variable name from `xxx` to `yyy` even though the later makes even less sense, and so on). After trying this process for few rounds, we found the review session didn't derive much benefits for either of us, and we stopped. How would you go about making each code review a natural, enjoyable, thought stimulating, bug-fixing and mutual-learning experience? Also, how frequently you do your code reviews - as soon as the code is checked in? Do you allocate a fixed time every week to do this? What are the guidelines that you follow during your code reviews? Finally, the motivation: What I do want my team to get out of the code review? Answer: I want my team members to be able to cover each other's work. That's the primary motivation. Second motivation: I want all the code to be easy to read/ modify/ extended, so that new features can be added easily.