How to deal with requirements and use cases in this kind of situation?

Recently I've started to work with object oriented analysis and design and it seemed very interesting to me as a way to get work done better. But I'm still in doubt with one kind of situation. If this is not the correct site to ask about it, sorry for that. Well, if I have to design a system that allows one user to register customers, sell products and so on, we have someone that will operate the system, in the sense that actor is kind of obvious for some of the use cases - the actor we will consider on the use case "Register New Customer" is simply the responsible for that action in the company of the customer that is purchasing the software. Now, there are sometimes that this doesn't happen. I'll give an example: I've developed once a system to manage templates for websites in PHP. In that time, I didn't develop it within an object oriented context, but I was thinking on bring this system into object orientation to practice object oriented analysis and design. The point is that the system is very simple: "it takes some configurations written in a xml file, takes a URL and maps it to a file". The point is that there's no interaction between the users of the websites and the system. The only thing that happens is that the user requests a URL and the system selects one html file that matches this URL in some way, and embed this html into a template specified in the xml. In cases like that, the only functional requirements I can think of are:   * The system must allow the user to specify the folders of templates into an xml file;   * The system must get the information of directories from the xml file;   * The system must load one specific file corresponding to the requested url inside one template file;   * The system must allow the replacement of placeholders into the template by values specified on code; The problem is: for instance, although I thought of them as functional requirements, all of them has to do directly with how the code must be made. Only the third one really fits what I understood of functional requirement. Also the use cases are a little complicated, every action is took by the system itself. The only use case could be "Request Page" with actor being "Site Visitor" and this would imply that the scenario would be just "The user inputs the url into the browser window and the system loads the page." So, in cases like that, when we are dealing with code will simply be reused into some other code (this is an example, it's just a bunch of code that a developer can use to load pages independent of a template), how should we deal with requirement analysis, use cases and so on? As I've said, the PHP system I wrote is just an example, I'm really asking in general. Could someone give some hints or reference (some article, tutorial, something like that), that shows how to deal with this? Thanks very much in advance!


subclass QAbstractTableModel - reuse as much code as possible

in my PyQt application I am heavily using the model/view approach. For every model I create, I do the following:               class myModel(QtCore.QAbstractTableModel):         def __init__(self, parent = None):             QtCore.QAbstractTableModel.__init__(self, parent)             self.lst = [[]] #initialize                  #populate lst with custom data             #self.lst = ....              def rowCount(self, parent = QtCore.QModelIndex()):             return len(self.lst)              def columnCount(self, parent = QtCore.QModelIndex()):             return len(self.lst[0])              def data(self, role = QtCore.Qt.DisplayRole):             row = index.row()             col = index.column()             if role == QtCore.Qt.DisplayRole:                 return self.lst[row][col].getContent()                  if role == QtCore.Qt.BackgroundRole:                 return self.lst[row][col].getColor()                  if role == QtCore.Qt.FontRole:                 return self.lst[row][col].getFont()                  if role == QtCore.Qt.DecorationRole:                 return self.lst[row][col].getIcon()                  if role == QtCore.Qt.TextAlignmentRole:                 return self.lst[row][col].getAlignment()                  if role == QtCore.Qt.UserRole:                 return self.lst[row][col]      In other words, the `columnCount()`, the `rowCount()` and the `data()` method looks always the same. After a few models, the typing get's really annoying and I am asking myself If I can get rid of this repeditive typing? I know that I could create a base class, where I put the `rowCount()`, `columnCount()` and `data()`method and inherit from that class, but is this the best/cleanest solution or is there a concept in Python which suits better?


How do you maximise the knowledge that you gain from a programming book?

Not because I care how long it takes someone to read a book, but more because I'm interested in how people get the knowledge from a book (or I guess other sources) into their brains in the best, most efficient way. Personally I take a multi-pass approach (from my answer to the original question):   1. Skim through contents, dip in and read anything with an interesting looking heading and finally gawp at any nice diagrams and illustrations. I won't take much in at this stage, but it gives me a mental view of the book (an hour or so at most)   2. First pass through the book, generally I'll read the opening chapters thoroughly for a book that is either very heavy going or introduces something completely new. For books that cover a subject I already know about I'll skim or skip bits that seem trivial. The remainder of the book I'll go through reasonably quickly but not so quickly that I'm just page flipping. (about a week)   3. Not all books that I read make it this far, but if I find a book interesting or useful enough I'll then study it properly. I will go through the book at a slower pace and do some or all of the examples, try out code, etc. I will often skip entire chapters here unless the book is really good (1-3 weeks depending on the book).   4. Finally when I've finished reading it and am reading other books I will often dip into it again and again to cross-reference, compare, look things up, browse, etc - so many of my favourite books don't just end up gathering dust on the bookshelf. I rarely take notes when reading (although I may do some planning on paper if I'm working through something like a code sample). I've also considered starting to use a personal kanban for organising my progress, but have never quite got around to using that technique. Mindmaps are another thing I like the idea of but rarely do. What other methods to people have? How successful do you find them? Are there any commonly recommended techniques that you feel are a waste of time?


Specifying options "hard coded", in an interpreted language

In a language like Python or JavaScript (NodeJS), is there anything wrong with defining "the configuration file" as a file which essentially hard-codes the configuration settings? For example: options.py:               OUTPUT_DIRECTORY = 'out'     LOGLEVEL = 'debug'      options.js:               outputDirectory = 'out';     logLevel = 'debug';      Does this count as "hard-coding" options? When would it be inappropriate to expect a user to configure software this way? Is there any benefit to using a traditional configuration format (eg, ini file) which is parsed at run-time?


SQL API instead of a REST API?

What are the pros and cons of exposing an SQL API instead of a REST API? Let's assume that this would be a private API – the API developer and user are on the same team. Probably the biggest problem would be security and validation. I can see two possible approaches:   1. Defining a set of allowed SQL query templates.   2. Doing some clever analysis of every incoming SQL query.


Authentication at my web site using other credentials

Suppose there are 2 web site: `example.com` I don't own and `example2.com` I own. I want to extend the functionality of `example.com` somehow. `example.com` doesn't have any API. I want the users of `example.com` to be able to login at `example2.com` using their logins and passwords of `example.com`. However, since `example.com` doesn't have any API, it is not easy to do, perhaps, it is even impossible. No doubt, no one would agree to enter their credentials of `example.com` at `example2.com` due to many obvious reasons. So, is there any way to authenticate the users of `example.com` at `example2.com` **(or somewhere else)** using their original credentials?


Why is quantity in software still written as "1 result(s)"?

Lately, I've been noticing that a lot of software, be it a website, a client application, or a video game, often write a representation of quantity as follows: "1 result(s)". Now, I can understand why they would do that 20 years ago. But these days, shouldn't we have enough processing power and memory to be able to say "1 result" and "2 results"? Is there some sort of special reason why it's still done this way? Now before you tell me to Google it, I would. But the thing is, I have no idea what search terms to use. So even some suggested search terms would be welcome.


Great Programmer Productivity - Accounting for 10,000 fold difference?

"A great lathe operator commands several times the wage of an average lathe operator, but a great writer of software code is worth 10,000 times the price of an average software writer." - Bill Gates Say there's a "great" software engineer and an "average" software engineer on the same team. How can you account for one engineer being 10,000 times more productive? I can't quite fathom this, given they're both taking on their share of features, bugs and investigations, and consistently deliver with quality. Would my description possibly justify them to be above "average"? "great"? In a corporation like Microsoft, what % of software engineers are "average"? What % "great"?


Big-O for nested loop

I am reading this post on Big-O   It says that the following code is O(n^2):               bool ContainsDuplicates(String[] strings)     {         for(int i = 0; i < strings.Length; i++)         {             for(int j = 0; j < strings.Length; j++)             {                 if(i == j) // Don't compare with self                 {                     continue;                 }                      if(strings[i] == strings[j])                 {                     return true;                 }             }         }         return false;     }      But I can not understand why.   The inner loop does something constant.   So it is summation of 1....N of a constant. i.e. constant number O(1).   The outer loop is summation over the O(1).   So I would imagine it is n*O(1). I think I am misunderstanding something here.   I do not think that all nested loops mean O(n^2), right?


Has anyone done CSDP certification?

I was looking at some certifications that can potentially enhance my knowledge and market value as a Software Engineer. IEEE's Certified Software Development Professional (CSDP) caught my attention. When I looked on the net for any user experiences with it I couldn't find anything substantial. Doesn't seem too popular. And I certainly havent heard of anyone in my organization or friends circle who have done it. I would like to know from community members if anyone has done this certification and their experiences with the same. Was the certification useful in terms of knowledge. Did it add weight to your resume (not deadweight!)?


How to compute barycentric coordinates in a systematic and efficient way?

As part of a ray tracer implementation, I need to compute the barycentric coordinates in a triangle in 3D in order to decide if a ray hits the triangle or not. In theory this could be done by simply solving a few linear equations. But due to the fact that the vertices of a triangle could have the same x, y or z coordinates, some of the coefficients in the equations would be 0, and this caused numerical error in my initial implementations. So, is there a systematic approach to find the barycentric coordinates in a more efficient way? Or I have no choice but to brutally check each possibility one by one?


How to check for vulnerabilities in web application

I have developed a web application using zend framework, mysql, and other client side technologies like javascript, jquery ajax, kendo grid, and so on. I have completed development and have done several rounds of testing to make sure the functional part is correct. Now I would like to check for the vulnerabilities in my application - vulnerabilities such as                          * sql injection                 * ajax vulnerabilities                * others       which I don't know of. I would like to ask you guys how to check this and make the application secure. What methods should I use to secure my application?


ASP.NET Dynamic Data

I'd like to know what people think of ASP.NET Dynamic Data. I see the project type in visual studio and have found very little about it mention on blogs and in books. I created a site using it and it is great the way it wires up the CRUD pages, but i don't understand how to modify the the pages without modifying the template that all the pages use. Do you think it will be abandoned in future versions of visual studio? I'm wondering if it's worth the effort of learning this type of application. personally i think i'd like something simpler....create the CRUD for us, but make them on seperate pages, without the whole template system.


Have you ever been really badly burned by VSS?

I have heard lots of anecdotal evidence that using VSS is a horrible idea because sooner or later, it will just lose/corrupt/delete all of your work. (I am even guilty of using such evidence as one of the motivating factors to switch to SVN a while back). However, though I really prefer Update/Commit to Checkout/Checkin, it is horrible over SVN and there isn't good branching support, I have never actually had a catastrophic VSS experience. Has VSS ever ruined your project/job/sanity? Old version or new? Is there truth behind the stories?


"Release Early Release Often" for Android and iPhone Apps

I wanted to know the experiences others have about doing the Agile way of "Release Early, Release Often" with iPhone and Android Apps. Its not a problem with webapps as the update happens at the server and user does not have to do anything specific for updates It may not be a big problem with Android, as the approval process is smooth compared to iPhone app store. Can someone share the experiences/suggestions/examples they've for releasing early and often to Android and iPhone markets?


Is this a good Visual Studio solution structure for a domain driven design RESTful web service?

I am building a .NET 4.5 C# Web API RESTful solution and I would like someone to tell me if my project solution is correct and/or wise(-enough?) for a solution designed using Domain Driven Design, please. The solution has been split into 6 projects:   * /Base (Not referenced by anything) The web project and forms the interface between the solution and the outside world. Contains the Web API controllers. Contains almost no logic beyond gathering values from request objects and asking the BizApi layer for work.   * /Biz.Api (Referenced by Base]) Provides the domain services and allows the /Base interface project to have access to the domain business logic objects in the /Biz.Domain project.   * /Biz.Domain (Referenced by Biz.Api) Provides the domain classes for the Biz.Api layer. These provide methods to manipulate the data of the business in memory.   * /Dal.Db (Referenced by Biz.Api) The database repository layer. Accesses the databases and maps returned data into internal DTO's defined in the /Interfaces layer.   * /Dal.Services (Referenced by Biz.Api) Provides a proxy layer to external dependencies like web services and maps their returned data to internal DTOs defined in the /Interfaces project.   * /Interfaces (Referenced by most projects above) Contains the DTO classes for passing data around the solution and the C# interfaces to define contracts for things like IoC.


Will apple approve app which internally uses library developed by Google?

I am using `GDataXML` library developed by Google as part of their Objective-C client library. As its Google’s XML processing library and I heard that Apple don't allow to use any third party libraries in app, will they allow this one?. (I am using this library because many iOS geeks suggest to use this one!!). Thanks in advance. :)


Wrap all external calls with flag to fight against recursion and double-entry?

Producing predictable output for each possible input is the responsibility of each module. For example (in C#):               class Logger     {         public ITextWriter Writer { get; set; }              private uint counter;              /// <summary>         /// Writes message in special format and returns the number of total messages written         /// </summary>         public uint Debug(string message)         {             if (message == null) throw new ArgumentNullException("message");                  if (Writer == null) throw new InvalidOperationException("Writer not set");                  Writer.Write(string.Format("{0:HHmmss}: [DEBUG] {1}", DateTime.Now, message));                  return ++counter;         }     }      `Logger` module is quite verbose, but it's output - exception, call to a depedency and returned value - is predictable and obvious for each argument and state. But one possible use-case bothers me. What if `Writer` was set to some weird implementation which somehow calls the `Logger.Debug` method on that same object? First possible consequence is stackoverflow due to infinite recursion. Second - unpredictable output and possible bugs. It's obvious that such situation must be controlled somehow. If we want predictable output for our logger, it should control double-entries:                   // ...         private bool enter;              public uint Debug(string message)         {             if (message == null) throw new ArgumentNullException("message");                  if (Writer == null) throw new InvalidOperationException("Writer not set");                  if (enter) throw new InvalidOperationException("Double-entry");                  enter = true;                  Writer.Write(string.Format("{0:HHmmss}: [DEBUG] {1}", DateTime.Now, message));                  enter = false;                  return ++counter;         }         // ...      And it seems that every external call (a call not to it's own components) must be wrapped with such flags. That looks crazy! Is it how good code written? Or is it normal to beleive that your system has no circular calls? Am I missing something important? Please, advise. **UPDATE** It's even worse, guys:                   // ...              private bool enter;              public uint Debug(string message)         {             if (message == null) throw new ArgumentNullException("message");                  if (Writer == null) throw new InvalidOperationException("Writer not set");                  if (enter) throw new InvalidOperationException("Double-entry");                  try             {                 enter = true;                      Writer.Write(string.Format("{0:HHmmss}: [DEBUG] {1}", DateTime.Now, message));             }             finally             {                 enter = false;             }                  return ++counter;         }         // ...      I beleive that catching an exception is on duty of higher-level module (the one which created them all), so exceptions must follow their way. But the state after unsuccessfull call must remain correct. Exception is not the end of the world, and modules possibly can be re-used.


Expected error handling

Let's say I have a social media website. On this website, users can upload several pieces of information about themselves, including their phone number. To implement this, I have a class called `PhoneNumber` that represents the users phone number. But phone numbers are optional. I have this `PhoneNumber` class which is supposed to guarantee access to a users phone number, but it can't. How do I handle this? My current approach is to, whenever there's a problem, assign a value to an `error` variable inside `PhoneNumber` that represents the problem in question (this could be an exception, a string, or an error code, it's irrelevant for this question). I also added a method to `PhoneNumber` called `isPhoneNumberAvailable()` that should be called before any of the accessors are used. If one of the accessors is called and the user hasn't added their phone number, I throw an `IllegalStateException`. But this doesn't seem like a good solution. I'm not sure why, I'm too new at this to explain it, but it seems like this could cause me some problems down the road. Note that this question is language agnostic, the existence of an `IllegalStateException` in Java is purely coincidental. EDIT: The solution is improving the model. I have guaranteed access to something I can't guarantee access to, which is bad design. My other problem was with the use of an `error` variable in class scope but that's beyond the scope of this question. See my follow up question here.


ArgoUML - Learning

So I just got a copy of ArgoUML. I originally thought I'd be able to just play around with it to learn it, but it's turning out to be extremely difficult. I searched online for tutorials and videos but came up with nothing useful. The help file for ArgoUML is very incomplete as well. Does anybody know of any online resources to help me learn ArgoUML (and UML in general, I guess)? Thanks!


How to limit users of a service to a specific program

I have built an android game - I would like to add a "high score" leaderboard to it, such that people can show off how high they managed to score. How should I design it so that people can't "hack" it by decompiling it and sending a fake score? I don't believe android has a TPM module yet for most devices, so I can't store a password there (even if I could, how could I insert it there without it being detected in transmission?). I could obfuscate the code, but that isn't going to prevent hacking, only deter it. I will be using a secured connection, so I shouldn't have any network-sniffing issues. I am not sure if it would be better to post it under android or security instead of here, but I think this is the correct place since I am asking for a design.


Are error variables an anti-pattern or good design?

In order to handle several possible errors that shouldn't halt execution, I have an `error` variable that clients can check and use to throw exceptions. Is this an Anti-Pattern? Is there a better way to handle this? For an example of this in action you can see PHP's mysqli API. Assume that visibility problems (accessors, public and private scope, is the variable in a class or global?) are handled correctly.


Using Memcached: is it good practice to update the cache when updating the database?

This question is about best practices in architecture. ### Our Current Architecture I have a PHP class that accesses MySQL for user info. Let's call it `User`. `User` is accessed many times, so we have implemented layers of caching to reduce load. The first layer is what we call the "per request" cache. After the data has been retrieved from MySQL, we store the data in a private property of `User`. Any subsequent requests for the data returns the property instead of re- requesting the data from MySQL. Since the web request lives and dies on a per-request basis, this cache only prevents the application from accessing MySQL more than once in a single request. Our second layer is Memcached. When the private property is empty, we first check Memcached for the data. If Memcached is empty we query MySQL for the data, update Memcached, and update the private property of `User`. ### The Question Our application is a game, and sometimes it is imperative that some data be as up-to-date as possible. In the span of about five minutes, a read request for the user data may happen 10 or 11 times; then an update may occur. Subsequent read requests need to be up to date or game mechanics fail. So, what we've done is implement a piece of code that is executed when a database update happens. This code sets the key in Memcached with the updated data, so all subsequent requests to Memcached are up to date. Is this optimal? Are there any performance concerns or other "gotchas" we should be aware of when trying to maintain a sort of "living cache" like this?


Simple Design for Singleton function in java for Kernel

I understand that Singelton helps to instantiate only one class AT A TIME. I try to learn how to Design for Singleton function in java. I want to know it better to understand Kernel. So I try to do this following, but I like to know if it's the only way to come up with private constructor.               public class Singleton {         private static Singleton instance = null;              private Singleton() {   }              public static synchronized Singleton getInstance() {             if (instance == null) {                         instance = new Singleton ();             }             return instance;         }     }


Unicode license

The Unicode Terms of use state that any software that uses their data files (or a modification of it) should carry the Unicode license references. It seems to me that most Unicode libraries have functions to check if a character is a digit, a letter, a symbol, etc. ans so will contain a modification of the Unicode Data Files (usually in the form of tables). Does that mean the license applies and all applications that use such Unicode libraries should carry the license? I've checked around, and it appears very few Unicode software do carry the license, though arguable most of those that didn't carry the license were from companies that were members of the Unicode consortium (do they get license exemption?). Some (e.g. Mozilla) are only "Liaison Members", and while their software do not carry the license (AFAICT), they do obviously rely on data derived from those data files. Is Mozilla in breach of the license? Should we carry the license in all apps that include any form of advanced Unicode support? (i.e. are bound to rely on the Unicode data files) Or is there some form of broad exemption? (since very very few software out there carries the license). **edit:** I've forwarded this question to the Unicode staff, I'll post the reply here when/if I get one


Formatting SQL Based on an AST

I am working on my .NET open source project for generating SQL... Initially, I wrote the project so it spit out exactly one SQL format... ugly. I started using this project in the real world and decided it would be nice if I could generate pretty SQL in debug mode and ugly SQL in release mode. My first go involved a lot of if/else loops within my command generation code. It quickly got to be too much to handle. So, I started looking for another approach that would allow me to plug-in different formatting strategies. I also looked at other SQL formatting libraries but most were specific to one dialect. Right now, I am playing with the idea of generating a tree of tokens, similar to an abstract syntax tree (AST) that a compiler works with. I was hoping to navigate the tree and generate text based on where I am in the tree. Now that I've built these trees, I'm not sure how to write the code to visit these nodes. I feel like I'm going backwards. Instead of parsing SQL, generating an AST and spitting out SQL objects, I am allowing someone to build SQL objects, then generate an AST and spitting out SQL. When someone uses my library to build a SELECT statement, they specify the values to select, the tables to select from, filters, ordering, etc. But once I have generated an AST... I have less information than I originally started with! Only by asking "Is the next token the keyword FROM?" can I get a picture of where I'm at. I have to write a bunch of if/elif/else statements to figure out what comes next. At least when I had the SQL objects I could use polymorphism to avoid nasty branching. So, perhaps I missed a day in compiler theory or perhaps it's because I'm trying to go backwards. But, for whatever reason, my next step is really unclear to me. I think the AST route was in the right direction even if it does mean losing information. I was able to write a really stupid formatter that puts spaces between every token for now. It's really when it comes to getting fancy that I'm overwhelmed. If anyone has some good resources for going backwards, it would probably be really helpful.


Compiler Linking: How to handle circular references?

I'm currently writing a compiler for a new language and I'm struggling with the linking aspect of new Types when there exists a circular reference. I've created a dependency tree so that I can compile the Types in the order of their dependencies which seemed to have fixed my problem... that is until I hit circular references like an example below (posted in c#):               public class A     {       public A() {  var b = new B(); }     }          public class B     {       public B() { var a = new A(); }     }      My limitation is that I can only create 1 Type at a time, and in the case of circular references, either A needs to be created first, or B needs to be created first, both of which poses the problem that I can't create either unless it's dependencies are first created! How do compilers overcome this?


How to keep track effectively of cache keys to invalidate them accordingly?

In an ordinary application, the same information may be retrieved from the database in several ways. If all those ways implement caching, you need to invalidate all those cache entries when updating an entry in the database. Some pairing between updates and selects is easy to do. Let's take an example of a product 123 in the category 9 with a price of $12.50. If you select a product by ID:               select [...] from [Shop].[Product] where [ProductId] = 123      caching it with a key `Product<Id:123>`, it's not so difficult to invalidate this cache entry after updating a price of a product identified by its ID:               update [Shop].[Product] set [Price] = 14.99 where [ProductId] = 123      Things become more difficult when you have also to remember to invalidate the cache with the key `MostExpensive<CategoryId:9>` corresponding to the query:               select max([Price]) from [Shop].[Product] where [CategoryId] = 9      What is an effective way to keep track of cache entries? How to find, during development or code review, what entries must be invalidated when one or another piece of data is changed?


Can someone explain in simple terms what is the disruptor pattern?

I would like if you could explain to me in a simple way how does the disruptor patter work. This concept has been elusive to me as of know. Perhaps with your help I could comprehend it.


Genetic Algorithm new generation exponentially increasing

I'm programming Genetic Algorithm in C++ and after searching all kind of ways of doing GA'a operators (selection, crossover, mutation) I came up with a doubt. Let's say I have an initial population of 500. My selection will consist in getting the top 20% of 500(based on best fitness). So I get 100 individuals to mate. When I do the crossover I'll get 2 children where both together have 50% of surviving. So far so good. I start the mutation, and everything's ok.. Now when I start choosing the Next generation, I see that I have a big number of children (in this case, 4950 if you wanna know). Now the thing is, every time I run GA, if I send all the children to the next generation, the number of individuals per generation will increase exponentially. So there must be a way of choosing the children to fulfill a new generation without getting out of this range of the initial population. What I'm asking here is if there is anyway of choosing the children to fill the new generations **OR** should I choose somehow (and maybe reduce) the parents to mate so I don't get so many children in the end.


Ruby Koans: depth and usefulness?

Several people have suggested Ruby Koans to me over just following a book, and this seems like a much better prospect. As there is no question regarding the entirety of Ruby Koans, what do SO users think about it? Is it mostly just syntax, or can one learn much more from solving them? :)


Examples of concurrent iterating scenarios needed

I'm trying to wrap my head around different concurrency solutions to several threads iterating over the same collection but I'm having difficulty coming up with good realistic (but preferably easy to model) scenarios to code against. I'm looking for realistic scenarios for:   1. A scenario where several threads can iterate over a collection simultaneously and lock each item as it comes to it and do some modification, item's can't be visible in a partially updated state   2. A scenario where different threads try to iterate over a collection but only one at a time should be allowed to   3. A scenario where several threads might iterate over a collection for reading, but only one thread might iterate for writing Any other nice concurrency iterating scenarios you might come up with are welcome as well :) thanks!


How to Code Faster (Without Sacrificing Quality)

I've been a professional coder for a several years. The comments about my code have generally been the same: writes great code, well-tested, but _could be faster_. So **how do I become a faster coder,** without sacrificing quality? For the sake of this question, I'm going to limit the scope to C#, since that's primarily what I code (for fun) -- or Java, which is similar enough in many ways that matter. Things that I'm already doing:   * Write the minimal solution that will get the job done   * Write a slew of automated tests (prevents regressions)   * Write (and use) reusable libraries for all kinds of things   * Use well-known technologies where they work well (eg. Hibernate)   * Use design patterns where they fit into place (eg. Singleton) These are all great, but I don't feel like my speed is increasing over time. I _do_ care, because if I can do something to increase my productivity (even by 10%), that's 10% faster than my competitors. (Not that I have any.) Besides which, I've consistently gotten this feeback from my managers -- whether it was small-scale Flash development or enterprise Java/C++ development. **Edit:** There seem to be a lot of questions about what I mean by fast, and how I know I'm slow. Let me clarify with some more details. I worked in small and medium-sized teams (5-50 people) in various companies over various projects and various technologies (Flash, ASP.NET, Java, C++). The observation of my managers (which they told me directly) is that I'm "slow." Part of this is because a significant number of my peers sacrificed quality for speed; they wrote code that was buggy, hard to read, hard to maintain, and difficult to write automated tests for. My code generally is well-documented, readable, and testable. At Oracle, I would consistently solve bugs slower than other team-members. I know this, because I would get comments to that effect; this means that other (yes, more senior and experienced) developers could do my work in less time than it took me, at nearly the same quality (readability, maintainability, and testability). Why? What am I missing? How can I get better at this? My end goal is simple: if I can make product X in 40 hours today, and I can improve myself somehow so that I can create the same product at 20, 30, or even 38 hours tomorrow, that's what I want to know -- how do I get there? What process can I use to continually improve? I had thought it was about reusing code, but that's not enough, it seems.


Why most job offerings are for a <language here> developer, rather than a developer in general?

**In an ideal world:** In an excellent article Don't Call Yourself A Programmer, And Other Career Advice, Patrick McKenzie explains, among other things, that language doesn't matter:   * A developer is a person who solves problems, in general. A developer is not a person who writes code in a specific language.   * Businesses don't care about the languages you know. If they need to hire a developer for a project written in a specific language, and they have a candidate who is highly experienced but never wrote a line of code in this language, he would still be hired. According to my experience both as a developer and as a person who had to hire other developers, the observation is very similar:   * The N years experience in Java or N years experience in C# doesn't matter. **What matters is that the candidate knows how to solve problems, knows the difference between spaghetti code and clean code with well-thought architecture, etc.**   * I don't care about the languages you used before. **For a C# project, I'll rather hire a professional developer who spent his life writing Java, Python and Ruby on Rails code** rather than a beginner who knows only C#, and knows it badly.   * **The knowledge and the experience you gain using one language is mostly reusable in any other language.** An experienced developer who used Ruby on Rails for web development and spent the rest of his career writing Java desktop applications using Oracle fits perfectly well for an ASP.NET MVC project using Microsoft SQL Server. Because **this person already knows everything she need for this job** , aside a few specific things and syntax differences. On the other hand, a person who have done just a few ASP.NET MVC small websites doesn't fit at all, because she may not completely understand the MVC architecture, may know know what is SQL profiling, and may lack some other essential knowledge. Don't tell me that I'm unable to fix a small problem with a PHP website which uses CodeIgniter just because I never used CodeIgniter before. **In practice:** In practice, when I search for freelance jobs and when I see the job offerings in general, they are very language-specific. Some would search for a PHP developer with two years experience in Magento. Others will be searching for a person with VB.NET experience of at least three years, and if you send them a resumé mentioning that you've done C# development for six years, but with no mention of VB.NET, they will not bother to answer. If they ask for a person with an experience with Firebird, they will not listen about your ten years experience with Oracle. Why there is such difference between the theory and what Patrick McKenzie and I describe as being common sense, and the real world of job offerings?


What web oriented language would work best with binary data?

I want to create a service where people can upload files. However, since file storage costs money, I want to compress the files so they take less space. I would want to write my own compression algorithm, however, PHP doesn't have good ways to handle binary data (which is needed for many compression algorithms). So I wondered, what would be a better language to create such a website in? I have knowledge of PHP (and Javascript, HTML and CSS) but no experience with other things like Ruby, Perl, Python, and other web development languages.


Modern implementation of Spring Remoting or EJB3

Im working on a "what is possible with the latest and greatest" prototype. One major issue that has been a big thorn in the side of myself and my AS/400 admin is when the existing system spins up, there are 35 individual applications, that each connect to 8 databases, and run a connection pool of 5 connections per. for you math wizards out there, thats 1400 individual database connections to the server on startup and over the course of a typical day maybe 40 are ever used. What I would like to do in this prototype is move all database functions to a central library (api). From that point, I would like to deploy this API individually and have the 35 applications simply open service classes remotely and pass objects back and forth. end result being the applications no longer have to create database connections, they simply call remote methods and we can tune the central api accordingly to handle the load. Back in the day, EJB3 would have been the way to go. the integration with security policies is nice, but i always had performance issues with it. Spring remoting running hessian looks promising, seeing im using spring everywhere else. but it has been YEARS since i have had to do anything like this so i was wondering what you guys suggest to use to accomplish this. thanks


prism and multiple screens

OK - I am studying Prism a little because of a "free weekend" offer on Pluralsight. As this is proving too complex for me, I went to the Prism book and looked at the forward, and this is what it said: > What comes after “Hello, World?” > > WPF and Silverlight developers are blessed with an abundance of excellent > books... There’s no lack of tutorials on Model-View-ViewModel ... But they > stop short of the guidance you need to deliver a non-trivial application in > full. > > Your first screen goes well. You add a second screen and a third. Because > you started your solution with the built-in “Navigation Application > Template,” adding new screens feels like hanging shirts on a closet rod. You > are on a roll. Until the harsh reality of real application requirements sets > in. > > As it happens, your application has 30 screens not three. There’s no room on > that closet rod for 30 screens. Some screens are modal pop-ups; you don’t > navigate to a pop-up. Screens become interdependent such that user activity > in one screen triggers changes that propagate throughout the UI. Some > screens are optional; others are visible only to authorized users. Some > screens are permanent, while other screens can be opened and closed at will. > You discover that navigating back to a previously displayed screen creates a > new instance. That’s not what you expected and, to your horror, the prior > instance is gone along with the user’s unsaved changes. Now the issue is, I don't relate to this description. I've never been a UI programmer, but same as everyone else I'm using Windows apps such as MS- Office, and web sites such as Amazon, Facebook and StackExchange. And I look at these and I don't see many "so many screens" issues! Indeed, the only applications having many windows I can think of is Visual Studio. Maybe also Visio, a little. But take Word - You have a ribbon and a main window. Or take Facebook: You have those lists on the left (Favorites, Lists, Groups etc.), the status middle, the adds and then the Contacts sidebar. But it's only one page. Of course, I understand that in enterprise scenarios there are dashboad applications where multiple segments of the screen are updated from multiple non-related services. This I dig. But other scenarios? So - What am I missing? What is the "multiple screens" monster Pirsm is supposed to be the silver bullet solution for? Shoud I invest in studying Prism in addition to learning WPF or ASP.NET MVC?


How can I handle clock hands using doubles that suffers at most O(log n) corrupt bits at nth frame of display?

I presently have a clock app that calculates from scratch at every iteration. This means O(1) corrupt bits in my doubles and heavy object creation and deletion as well. I am wary of running indefinite calculations with doubles or any other floats because O(n) corrupt bits normally accompany every step. I would like to know if there is an alternate way (in an iOS app) to transform and position clock hands with O(1), or maybe O(log n), corrupt bits after n steps. In particular, I was wondering what the corruption would be for "At each step, rotate each hand back to the zero position, meaning an affine rotation transformation of -1 * the last rotation the hand received, and then rotate forward by the new angle the hand should have at this step." In Objective-C's floating point arithmetic, is it ever not the case (excluding exceptions like a value indicating a number is corrupt) that x - x != 0.0 exactly? The cases I've seen illustrating floating point corruption bits include Python saying that 1.1 + 1.1 + 1.1 - 3.3 != 0.0; I haven't seen textbook examples of the form x - x != 0.0. This is not exactly the question of whether a raster image transformed by angle x and then by angle -x is its original self; it may be that the preceding suggestion would work fine for O(1) error on angles but usual corruption in the image drawn and transformed. What is the minimum "corruption complexity", meaning fewest corrupt bits at end of n calculations, for rendering a clock? Are there O(1) or O(log n) approaches? Thanks,


Is there a tool to generate multi-goal procedural instructions?

**As a user:** When I have good instructions to follow I'm sure I could do just about anything. With poor instructions I end up frustrated, wasting time and probably giving up. The type of instruction I see most is the procedure. I use multiple operating systems with different tools, so the type of procedure I usually see I call multi-goal procedures. Please let me know if there is a more correct or better term for these! I'm sure you have encountered multi-goal procedures like this before:               How to install MegaWidget for Linux      1. Download and install foo library      2. Read note below about foo      3. Download bar source      4. Compile and install bar      5. Download MegaWidget source      6. Compile and install MegaWidget          Windows installation      1. Follow steps 1, 2 and 3 above      2. Download yet_another_cross_platform_build_system and install it      3. Edit the configuration file for bar and change X to Y      4. See step 4 above. Make sure to use yet_another_cross_platform_build_system though.      5. See step 5 above.          Windows 64bit installation      Follow the 32bit Windows instructions, but you also have to install Super64Library before you install bar.          About foo:      The foo library exists only to cause you pain and suffering.          Report from users:       MegaWidget doesn't work with Super64Library version 3.x. Use version 2.x instead.      (See here for a real example of what I want to avoid) I see this all the time. Instructions that reference other instructions or items outside of the procedure. Required information that isn't referenced where it's needed. Procedures that don't end at the target/goal. ARGH! In my contrived example the Linux procedure is clear enough but the Windows instructions are progressively awful. As a user I want ONE clear procedure to accomplish my goal. If I wanted to follow the Windows 64bit instructions then they should look like this:               How to install MegaWidget for Windows 64bit      1. Download and install foo library.         NOTE: The foo library exists only to cause you pain and suffering.      2. Download and install the Super64Library         NOTE: You need Super64Library 2.x, not the newer 3.x version.      3. Download yet_another_cross_platform_build_system and install it      4. Download bar source      5. Edit the configuration file for bar and change X to Y      6. Use yet_another_cross_platform_build_system to compile and install bar      7. Download MegaWidget source.      8. Use yet_another_cross_platform_build_system to compile and install MegaWidget      The procedure that will lead me to the desired goal has everything contained within that procedure. * * * **TL;DR** : Most mutli-goal procedures are rubbish and hard to follow. **As a developer:** I am guilty of writing crap like this too. I no longer want to be someone who provides terrible instructions to my users. However writing, updating and maintaining mutil-goal procedures in a flat text file is difficult and prone to error. I need a tool that can generate the procedures for me. Perhaps I could create a flowchart like this... ![Gliffy mockup](http://i.stack.imgur.com/STemz.png) ... and the tool would export the complete procedures for the three goals. **Does such a thing exist?**


Which language features are considered harmful?

Please, **explain why** and list which languages have the (mis)feature implemented As far you know. Post what you consider a harmful feature, not what you dislike.


Hash function for progressive changes

I am looking for a hashing algorithm that works like this. I start with a text file, and compute its hash. Now I know that I will remove one character at, say, position 67 and this character is a "m", and I would like to compute the new hash without reapplying the hash function to the full text, but instead using the hash of the full text and the knowledge that I removed 'm' from position 67. If I readd the "m" in the same place, I will again recompute with the same methodology and get the same initial hash. What is the technical name for such hash functions, so that I can search some pointers around? a CRC is not what I need I guess, because (afaik) a CRC works on a stream addition, not on arbitrary changes throughout the initial data.


Does giving a developer a slower development machine result in faster/more efficient code?

Suppose I give my developers a screaming fast machine. WPF-based VS2010 loads very quickly. The developer then creates a WPF or WPF/e application that runs fine on his box, but much slower in the real world. This question has two parts... 1) If I give a developer a slower machine, does that mean that the resulting code may be faster or more efficient? 2) What can I do to give my developers a fast IDE experience, while giving 'typical' runtime experiences? **Update:** For the record, I'm preparing my even-handed response to management. This isn't my idea, and you folks are helping me correct the misguided requests of my client. Thanks for giving me more ammunition, and references to where and when to approach this. I've +1'ed valid use cases such as:   \- specific server side programming optimizations   \- test labs   \- the possibly buying a better server instead of top of the line graphics cards


Technology/Techniques to prevent offensive images on a website

I am planing to build a website which one of its main features is the usage of pictures. I was wondering what existing techniques are used to prevent offensive pictures (i.e pornography) to get loaded by users. i.e What does Facebook or Pinterest use? As well I would like to know what your recommendations would be to control offensive pictures to get uploaded to the site (OpenSource tools maybe..) Taking into consideration this is a personal project and will be developed with a very small budget. Thank you


Print the next smallest from 2^i * 5^j where i,j >= 0

I was asked this question during a technical phone screening recently and didn't do well. The question is included verbatim below. > Generate `{2^i * 5^j | i,j >= 0}` sorted collection. Continuously print the > next smallest value. > > Example: `{ 1, 2, 4, 5, 8, 10...}` "Next smallest" makes me think a min-heap is involved, but I didn't really know where to go from there and no assistance was provided by the interviewer. Does anyone have advice on how to solve such a problem?


Calling same method on different object - Recursion?

I have an object that contains a reference to another object of the same type. Example in PHP:               class A {         protected $child;         public function __construct(A $child = null) {             $this->child = $child;         }              public function go() {             if($this->child) {                 $this->child->go();             }         }     }          $a = new A(new A());     $a->go();      Is the `go` method considered a recursive method? I can see it both ways myself, and I'm not sure if there is a 'correct' answer or not, but I assume that there is.


What are considered the definitive references for bootstrapping one's client-side expertise?

I'm a server-side junkie, and by that I mean I spend time writing code that's not visible to anyone. I'm interested in rounding out my skillset and becoming more self-sufficient with writing full-stack webapps. But, I find it difficult to work with the the sort of 'organicity' of client- side html tech. I know there is no substitute for time and experience, but if an experienced client-side dev was starting over from scratch, what would he read/do? EDIT: an example of an answer that I'd give for server-side: > Learn the best practices of the language you're working in, eg. for java, > read 'effective java'. Learn fundamentals of algorithms, application design > concepts that are useful in any language, two good sources are 'design > patterns', 'SICP'. I'm not looking for: 'Learn CSS, HTML and Javascript.' I am looking for something like: > Intent, rationale, concepts of X are well-explained in Y. Framework Z is a > good example and the source-code is enlightening and well-documented.


Messages from UI or from subs?

I am designing a small application that is really justa gui for a command line using vb.net. Question 1. Should messages(msgbox) to the user come from the UI or should messages come from subs and functions that the UI calls. Question 2. Should subs and functions throw new exceptions to the UI or should they be containd in the sub/function Question 3. Should if statements be used at the UI level or should users input be passed to subs and functions for if statement processing ?


Best way to clear balances between payers and payees

Say some 20 people go to a shop and everyone buys something. When it comes to paying, 5 of them pay the complete amount of 10,000$ split unequally between them. Since everyone bought different things they all owe different amounts to the payers. Now there are multiple ways the payers can clear the balances with the payees precisely 20 to the power 20. My question is on what technical basis should the payers and payees contact each other for clearance? All the solutions can not be equally good, or are they? One of the ways of clearing would be to find payers and payees with equal amount so that they can cancel out each other thus reducing the total number of transfers. **UPDATE:**   1. People can transfer arbitrary amounts to anyone.   2. Minimizing total number of transfers is the main goal.    3. A payee can not pay an amount greater that what he owes and become secondary payer.   4. The output should be a list of suggested transfers. A suggested transfer would look like this `{FromUser: a, ToUser: b, ClearanceAmount: 100}`   5. The payers don't know who holds their debt.   6. The payees debt can be split across multiple payers.   7. The payees knows how much each payer paid from the total amount.


Do we learn better with video or text or is it personal preference?

I am constantly looking for new ways to learn and obviously in this quest it's important to understand how we learn best. As programmers and developers, do we learn best with videos or actually reading text or does it depend on the person in question? Thanks! ~Daniel


Program unable to write data (read-only file) and losing it -- a bug or a feature?

I found, that some very famous app (I'm not disclosing name intentionally) has a "problem", when writing meta-data of a file and the file turns out to be read-only. Program doesn't handle that too gracefully. It does not check, whether a file is read only upon _opening_ meta data dialog box. Thus, it allows the user to fill out (quite long) form, enter quite large amount of data without even checking if it will be able to save it. It only checks, if the file is read-only, when _saving_ meta-data (attempting to do so). And if it finds that the file is actually read-only, it only displays a warning to a user and... **closes the dialog box** , thus causing user to lose data. For me, this is an obvious bug, that it is beyond any discussion. Since creator of that program, is my e-friend, I've immediately contacted him, writing (as usual) " _Hey, just spotted another bug in your program_ ". His reply simply shocked me, as he claimed and started to convince me, that **this is not a bug, it can be only treated as an additional feature, that user _may_ want** (talking about my proposition to add some warning, that file is read- only and thus writing meta-data is impossible). He even went as far (I think) as writing: > read-only file is a user problem, not a bug in a program It was Saturday, a working and tiring day for me. I thought to myself, that maybe there isn't enough hot coffee in my blood system, so I contacted some of the developers, that I've been working with on a various projects. All the replies were the same: " _A certain bug, nothing to discuss further_ ". I replied to that app's author and my friend, giving him a dumbest example I could come with: > Imagine yourself, that you are writing something in Word, save the document, > Word tells you, that it can't write file, because it is read-only and... > closes the document, losing everything you wrote since last save. Would you > called that an extra feature and no data loss? (...) > > And you call it a feature and my problem? I know many people ready to > crucify you for such feature! :) In the reply to that, I heard, that the comparison is not very good, because I don't write in meta-data so many text like in a Word document, so the "loss" is irrelevant. I'm **completely lost** , with both hands down! As I said, for me this is a certain bug beyond any discussion. But maybe I slept over some radical revolution in the way, how we define a bug, so maybe someone would kindly enlighten me about that. Who of us two is right, and if it is program's author -- then why?


Has there been research into programming linguistics?

Programming languages are formal languages, but unlike many formalisms, they also have certain inherent _meaning_ defined by their operational semantics, or, in the case of markup languages, presentation semantics. And programming languages, though indeed formal, are very similar to natural languages, in terms of the communication they allow. While the development of programming languages is artificial, the natural- language processes of evolution, borrowing, intermixing, and mutation all have fairly clear artificial counterparts. So I'm wondering: has there ever been any large-scale, in-depth research into the evolution and behaviour of programming languages _from a linguist's perspective_ ?


Most underestimated programming tool

We have many great tools which helps a lot when programming, such as good programmers text editors, IDEs, debuggers, version control systems etc. Some of the tools are more or less "must have" tools for getting the job done (e.g. compilers). There are still always tools which do help a lot, but still don't get so much attention, for various reasons, for instance, when they were released, they were ahead of their time and now are more or less forgotten. What type of programming tool do you think is _the_ most underestimated one? Motivate your answer.


What's the difference between a "control" and an "element"?

In web development, you often hear the terms "element" and "control". The term "element" is often associated with HTML, and you hear the term "control" most often in Asp.NET development... but the w3c refers to controls in the Forms in HTML documents recommendation, blurring the lines a little. What is a control and what is an element? How are they the same and how are they different? Is one a generalization of the other?


C# experience for students

Where is it possible to get a real experience with C# and .net programming? Open source teams usually don't want to deal with newbies, making projects with other students is problematic too, because of the lack of volunteers. So, what's the solution for this problem?


Micro-optimizing - BAD vs Game Development

In game development there is a lot of C/C++, in business applications C#. I have seen C/C++ devs express concern over how a single line of code translates to assembly. In .NET some go into IL, rarely. In C#, "micro-optimizing" is frowned upon, rare and usually a waste of time. This does not appear to be the case in game development. What specifically creates this inconsistency? Do games constantly push the limits of hardware? If yes, as hardware improves should we expect higher level languages to take-over the gaming industry? _I'm not looking for a debate on the feasibility of C# as a game dev lang. I know it's been done to some degree. Focus on Micro-optimization. Specifically, the difference between Game Dev vs Applications dev._ **UPDATE**   By Game I mean modern, largescale development. E.G. MMORPG's, Xbox, PS3, Wii...


How to avoid excessive method overloading?

We have quite a lot of places in the source code of our application , where one class has many methods with same names and different parameters. Those methods always have all the parameters of a 'previous' method plus one more. It's a result of long evolution (legacy code) and this thinking (I believe): " _There is a method M that does thing A. I need to do A + B. OK, I know ... I will add a new parameter to M, create a new method for that, move code from M to the new method with one more parameter, do the A + B over there and call the new method from M with a default value of the new parameter._ " Here is an example (in Java-like-language):               class DocumentHome {            (...)            public Document createDocument(String name) {         // just calls another method with default value of its parameter         return createDocument(name, -1);       }            public Document createDocument(String name, int minPagesCount) {         // just calls another method with default value of its parameter         return createDocument(name, minPagesCount, false);       }            public Document createDocument(String name, int minPagesCount, boolean firstPageBlank) {         // just calls another method with default value of its parameter         return createDocument(name, minPagesCount, false, "");       }            public Document createDocument(String name, int minPagesCount, boolean firstPageBlank, String title) {         // here the real work gets done         (...)       }            (...)     }      I feel like this is wrong. Not only that we can't keep adding new parameters like this forever, but the code hard to extend/change because of all the dependencies between methods. Here are few ways how to do this better:   1. Introduce a parameter object:              class DocumentCreationParams {            String name;       int minPagesCount;       boolean firstPageBlank;       String title;            (...)     }          class DokumentHome {            public Document createDocument(DocumentCreationParams p) {         // here the real work gets done         (...)       }     }        2. Set the parameters to the `DocumentHome` object before we call `createDocument()`                @In       DocumentHome dh = null;            (...)            dh.setName(...);       dh.setMinPagesCount(...);       dh.setFirstPageBlank(...);            Document newDocument = dh.createDocument();        3. Separate the work into different methods and call them as needed:                @In       DocumentHome dh = null;            Document newDocument = dh.createDocument();       dh.changeName(newDocument, "name");       dh.addFirstBlankPage(newDocument);       dh.changeMinPagesCount(new Document, 10);      **My questions:**   1. Is the described problem really a problem?   2. What do you think about suggested solutions? Which one would you prefer (based on your experience)?   3. Can you think of any other solution?


What do we call the process of changing hard-coded codes into soft-coded codes?

Is there a specific term to call the process of modifying hard-coded codes into soft-coded codes? I have to report what I am doing to the Project manager, shall I just put "modifying hard-coded codes into soft-coded codes"? Example of "hard-coded codes"               int random(){     return 42;     }      Example of "soft-coded codes"               int random(){     return Random.nextInt();     }      hard coded codes might fulfill requirements for a set of inputs, but it is not flexible. EDIT: Accepted as Code Refactoring.


Ensure that each class has only one responsibility, why?

According to Microsoft documentation, the Wikipedia SOLID principe article, or most IT architects we must ensure that each class has only one responsibility. I would like to know why, because if everybody seems to agree with this rule nobody seems to agree about the reasons of this rule. Some cite better maintenance, some say it provides easy testing or makes the class more robust, or security. What is correct and what does it actually mean? Why does it make maintenance better, testing easier or the code more robust?


XML Documentation for IoC Classes

I'm working on an application that uses Inversion of Control to achieve loose coupling between the Data Access and Business Layers. Having an ILoanApplicationRepository and a LoanApplicationRepository, where should I store the XML Comments that document the class members? on the interface or on the concrete class? should I do it on both?


Are there any real benifits to a DAO layer?

When I first started using Hibernate I heard about all the joy of using a DAO layer. Initially it made sense for my problem: I was going to experiment with Hibernate and later experiment with NoSQL and/or XML for experience. It made sense at the time Before I go any farther I want to say that my current DAO layer isn't a "true" dao layer. Its more of a bunch of data objects backed by interfaces and a "Controller" that generates new objects, queries, and cleans up when the application exits. Now though I'm picking up Spring the DAO layer is starting to make less and less sense. NoSQL is neat and all, but I'm really starting to question if its worth it. I'm not even sure if my data is fit for NoSQL, it works quite well in a relational database. The horrible XML storage seems like a hurdle I'll cross later. Besides there's a huge of code I would need to support for other storage options: My custom "Controller" + a zillion Spring interfaces to implement + other stuff that I'm missing. What's preventing me though from just ripping it out and merging the core and hibernate dao modules is that there's a few other projects that have a DAO layer (a real one) with only Spring and Hibernate. That means that they have all the interfaces, all the abstract classes, all the complexity with only those two frameworks. Since I'm just starting out in Spring+Hibernate world I'm hesitant to go against what others are doing with so little experience. **Question:** Are their other advantages that I'm missing with having a DAO layer? And why would other projects have a DAO layer when their only using one database?


How can I learn about Distributed Software Systems as efficiently as possible?

I'm trying to learn cloud-computing, especially the idea of distributed operations (Grid Computing?) for a project I'm working on. We'll need to perform distributed fault-tolerant operations over a very large data set, which we will also be responsible for storing and maintaining in an optimized way. If I'm trying to learn from books or white-papers, what types of things should I look out for and focus on to help me gain this knowledge as efficiently and effectively as possible?


What is the benefit of writing to a temp location, And then copying it to the intended destination?

I am writing an application that works with satellite images, and my boss asked me to look at some of the commercial applications, and see how they behave. I found a strange behavior and then as I was looking, I found it in other standard applications as well. These programs first write to the temp folder, and then copy it to the intended destination. Example: 7zip first extracts to the temp folder, and then copies the extracted data to the location that you had asked it to extract the data to. I see several problems with this approach:   1. The temp folder might not have enough space, while the intended location might have that much space.   2. If it is a large file, it can take a non-negligible amount of time for the copy operation. I thought about it a lot, but I couldn't see one single positive point to doing this. Am I missing something, or is there a real benefit to doing this?


Domain Lookup API

I am looking to incorporate a domain name lookup facility in my website to make sure if a domain is available or not. The only api I could find on the net is http://www.domaintools.com/api/docs/domain-search/ . But this is paid. Is there any other api available which might be cheaper / free. I am working with php, jquery Thanking you


What to do with .git folder and data in Xcode?

I am using Hg for my development. Recently, I upgraded to Lion and Xcode 4.2 and I have created a Xcode project in my source tree. The Xcode by default uses Git and created .git folder in the project folder. Being able to do versioning in Xcode is a plus but it is sort of redundant with both Git and Hg. The problem is, should I check in the .git (folder and files) in the Xcode project folder or not? Or should I just switch off Git in Xcode and delete .git folder? Thanks.


Why should one avoid cross-team (circular) merges in multiple-team version control?

![a cross-stream, or cross-team merge](http://i.stack.imgur.com/OIZ4a.png) Please excuse the artwork, I know it looks like an elongated imperial shuttle, but it's the way I visualise a multiple team (or multiple stream) version control strategy. The central core, is the trunk (or master) repository. If there were lots more streams you can imagine more planes projecting out from the trunk, in which various branching and merging is taking place within those streams (the thinner lines). The red line shows * _A_ *lice from accounting wanting to take a piece of code that * _B_ *ob from the backups team has only just forged (she needs it urgently for some reason that I can't think of). Actually, it's not like a one line change that she can just do herself. Instead you can consider that accounting are heavily blocked and need a large change set from Backups to continue. Now as I understand it, this is against best-practice, and the changes required should go through the trunk, and Alice should pick them up that way, rather than take the short cut illustrated (a version control wormhole). However, although I have seen this stated in various places, I have never seen some deep, lengthy and well-justified reasons why a cross-stream (or circular?) merge is something not to allow. The only thing I can think of is that I guess it can lead to greater manual conflict resolution. So questions are:   * Why is allowing a cross-stream merge bad? (I need some well-defined reasons to convince my various-minded colleagues why it shouldn't be done)   * Are there any justifiable reasons to go against best-practice?   * What if Alice's team is reaching a release deadline, can there be an exception?


Versioning millions of files with distributed SCM

I'm looking into the feasibility of using off-the-shelf distributed SCMs such as Git or Mercurial to manage millions of XML files. Each file would be a commercial transaction, such as a purchase order, that would be updated perhaps 10 times during the lifecycle of the transaction until it is "done" and changes no more. And by "manage", I mean that the SCM would be used to not just version the files, but also to replicate them to other machines for redundancy and transfer of IP. Lets suppose, for the sake of example, that a goal is to provide good performance if it was handling the volume of orders that Amazon.com claimed to have at its peak in December 2010: about 150,000 orders per minute. We're expecting the system to be distributed over many servers in order to get reasonable performance. We're also planning to use solid-state drives exclusively. There is a reason why we don't want to use an RDBMS for primary storage, but it's a bit beyond the scope of this question. Does anyone have first-hand experience with the performance of distributed SCMs under such a load, and what strategies were used? Open-source preferred, since the final product is to be FOSS, too.


How can I start shipping code?

I have just started learning how to program using LPTHW, and as my skill level develops I would like to start shipping code whether or not it's ready to be shipped, just to get into the habit of always shipping code, and not having the fear of shipping code. Is there are a beginner friendly guide to shipping code?


Who invented the otpauth:// URI scheme?

It seems really simple, but who invented the commonly-used `otpauth://` scheme (used by Google Authenticator and other TOTP soft tokens by scanning QR codes)? When?


Why Does a Developer Need a "Native" Internet Access?

## Setup We have a situation where developers connect to their development boxes via Citrix terminals (that are installed on their laptops), which brings them into a Gnome session (e.g. Linux), where they do all the coding. ## Problem Until now developers had Internet Access from those Citrix environments + installed Firefox browser. Starting right now the Internet Access [from that environment] is taken away. Developers still however have the access via their IE9 browser (strictly IE9) from their laptops. This of course makes the whole development process a lot less productive. At the same time, it is _extremely_ difficult to come up with a solid explanation, reasons on why the productivity suffers from switching environments (on the same laptop) in order to use the Internet. ## Question I'm turning to SO community to help us find those reasons that can convince decision makers to give Internet Access back to developers [from the system they develop on].


How to use Redis properly on big object

I have a relatively big object that is the wrapper of a HashMap that has 200 K entries. This HashMap wrapper, after being serialized, would take 67 Megabytes. Because this big object is the result of an expensive parsing from disk, I would like to store that in an in-memory database (read Redis). My first approach is to serialize this object into a byte sequence, store that as a single entry of a big value in Redis. When I need I would read that entry, deserialize it into the original big object to pass around in my Java program. But it would take 30 seconds just to convert the byte array into the original big object. I consider it slow. What do you recommend to speed up this ? Here is the code to convert byte into object               public static <T> T deserialize(byte[] bytes, Class<T> clz)     {         try {                ByteArrayInputStream bos = new ByteArrayInputStream(bytes);                ObjectINputStream in = new ObjectInputStream(bos);                return clz.cast(in.readObject());            } catch (Exception e)                e.printStrackTrace();                return null;     }


Can I “just” create my own media type for a proprietary web/application communication

I read this question but it doesn't fully answer mine. In the linked question, the OP asks what he must do to have his custom media type registered. I do not need that. All I'm asking is, that if I am correct in assuming that, technically, all I have to do to create a custom media type is to, well.. just use it in my communication? Basically, what I want to do is that my website offers a download of a file, described as `application/x-my-custom-thing`. On the client, the user has files ending with `.my-custom-thing` set as to open with the application I ship along. So, what should happen is that, when the user clicks on the link, my application opens and reads the file and does stuff with it. Are media types even the proper use case for this? Or, should I maybe "create" my own protocol in the sense of `mycustomthing://example.com/the-file-to-use`? Will that work with every (reasonably modern) browser?


Is it bad practice to use an interface for categorization only?

For example: Say I have classes `A`, `B`, `C`. I have two interfaces, lets call them `IAnimal` and `IDog`. `IDog` inherits from `IAnimal`. `A` and `B` are `IDog`s, while `C` is not, but it is an `IAnimal`. The important part is that `IDog` supplies no additional functionality. It is only used to allow `A` and `B`, but not `C`, to be passed as an argument to certain methods. Is this bad practice?


What is an “implementation plan”?

I was recently given the task of creating an implementation plan document. When I asked for an example of one that I could look at, I was told to look at the Project Plan that had already been created an use that as a base. I'm still a bit confused on what I should be creating. Can anyone point me to a good example out there or to something that explains what this is and more importantly the details about what it should contain.


What is the best way for a programmer to handle being code reviewed?

I am fairly new to code review, but I have been coding for years during my PhD - which doesn't always make you a good programmer! If the reviewer changes your code and goes through it with you line-by-line, what do you do if you disagree? Sometimes you made choice X and the reviewer changes it to Y, and you had Y in your mind but decided not to do it because of the disadvantages, but the reviewer asserts that those disadvantages are not important. Should you verbalise your disagreement, or just not and listen to them? Its difficult if you are not good at accepting criticism, and if the reviewer is a more senior person in the organisation. It would not be good to come across as too defensive.


Design for a template class

I have an abstract class `abstract class MathFunc` that is used to implement the mathematical functions Rastrigin, Griewangk and Rosenbrock in their specific classes `final class Rastrigin extends MathFunc`, `final class Griewangk extends MathFunc` and `final class Rosenbrock extends MatjFunc`. This hierarchy of classes and how they are defined so far works flawlessly so I think there is no need to look for improvements on this area. Now I have to implement another class `Generation` that will have some `ArrayLists` in it but the thing is I need to have a Generation implementation for each mathematical function described above. So that I need something like:               ArrayList<Rastrigin> rast = new ArrayList<>();     ArrayList<Griewangk> grie = new ArrayList<>();     ArrayList<Rosenbrock> rose = new ArrayList<>();      Inside these lists I have some Rastrigin/Griewangk/Rosenbrock objects that I need to instantiate. I know from the past projects in C++ that I can use templates to specify a generic data type and I'm thinking that this is my solution. My implementation so far looks like this:               public class Generation <MathFunc> {         private final ArrayList<MathFunc> pop = new ArrayList<>();         private final ArrayList<MathFunc> nextpop = new ArrayList<>();         private final ArrayList<MathFunc> Crossover = new ArrayList<>();              Generation(MathFunc tp)         {             for(int i = 0; i < PopSize; i++)             {                 pop.add(tp);             }         }     }      But the problem is: can I use the abstract class to instantiate the objects that rely on it? Is there another way to do it? I'm quite confused about the usage of templates. But doing `Generation(Mathfunc tp)` seems a little weird to me since abstract classes are not instantiable.


Why would I care about the asymptotic growth of the lower bound of the worst case time/space?

In mathematics, there are notations for asymptotic lower bounds, upper bounds, and tight (within-a-constant-factor) bounds. When describing the growth of functions in general, it makes sense that all three might be relevant to some function or other. In algorithm analysis, asymptotic notation is usually used to describe the growth in time or space requirements. To me, it seems logical that I may be interested in the maximum, the minimum or the expected requirements. Ignoring the expected requirements, I might be interested in the lower bound of the best case (minimum space/time) or the upper bound of the worst case (maximum space/time). I can't imagine why I should ever be interested in the lower bound of the worst case or the upper bound of the best case. Since the lower bound is a kind of best case and the upper bound a kind of worst case, these seem like "best case of the worst case" and "worst case of the best case" mismatches to me. But on several occasions, I've had replies to answers/comments that suggest this may be a failure of imagination on my part. So - what is it that I'm failing to imagine? I won't consider a statement along the lines of "it's quite common to say that the lower bound of the worst case of the blah algorithm is blah" to answer the question, unless it also says why people care.


What if I have no good ideas to implement a feature?

I'm working on my own application and I'm stuck. I have to implement a feature but I can't find a good approach to implement this feature. I was thinking about it for a couple of days, and no good thoughts came. Searching the Internet didn't give me any inspiration. I need to move on, but I want to know, what's the best:   * Think more, wait more, and keep on searching for the best approach   * Stop wasting time and start with poor design, covering everything with tests What do you think? As I said before, I'm working on my own application. I don't have any deadlines, but I also want to finish coding the app asap.


More info about Poplar language originiating from Xerox Parc

Peter Weinberger in an interiview mentioned a language called Poplar > What’s interesting is that at the same time that we were doing AWK, there > was a project at Xerox PARC called Poplar … maybe called Poplar. Anyway, > whatever it was called, there was this project at Xerox PARC, which had > fairly similar goals. That is they were going to take these files consisting > of a lot of characters and you break them apart in various ways and you > process them using some language and you pass them on. And they put a lot of > work into clever ideas. It was a functional programming language. ... And it > was supposed to be user friendly and in addition you wrote the program sort > of here and then you worked an example on the other side of the page and the > compiler checked that the program worked the example the same way you had. > So that you had some feeling for what the program was doing Is there more information about this language? Or it's just the Parc's internal project that never left their laboratories?


How best to merge/sort/page through tons of JSON arrays?

Here's the scenario: Say you have millions of JSON documents stored as text files. Each JSON document is an array of "activity" objects, each of which contain a "created_datetime" attribute. What is the best way to merge/sort/filter/page through these activities via a web UI? For example, say we want to take a few thousand of the documents, merge them into a gigantic array, sort the array by the "created_datetime" attribute descending and then page through it 10 activities at a time. Also keep in mind that roughly 25% of these JSON documents are updated every day, and updates have to make it into the view within 5 minutes. My first thought is to parse all of the documents into an RDBMS table and then it would just be a simple query such as "select top 10 name, created_datetime from Activity where user_id=12345 order by created_datetime desc". Some have suggested I use NoSQL techniques such as hadoop or map/reduce instead. How exactly would this work? For more background, see: Why is NoSQL better for this scenario?


How to dynamically add new posts once they are created

I am trying to design an application where users can make posts with Django on the backend. Right now I have to refresh the page with JavaScript every 20 or 30 seconds to check for new posts that might be available for that page. I was wondering if there are more effective ways to do this? Maybe with a JSON response? I am looking for a solution like Twitter, where they show how many new posts are available that are not on the page or even like on Facebook where they update the wall posts automatically. Is there a particular technology should I be researching in order make the updates more efficient?


The difference between best practices and common sense?

There is a lot of conversation regarding best practices1 in software development. I've seen at least three major points get a lot of discussion both on SE and elsewhere:   * What qualifies as a best practice, and why?   * Are best practices even worth discussing in the first place, because it's reasonable to assert that no practice is a "best" practice?   * When should you forego a best practice -- or perhaps most best practices -- either because it doesn't seem applicable or because of external constraints (time, money, etc.) that make the trade-off impractical? Something that seems to come up far less often, but more than never, is a notion of **common sense** in software development. Recent experience has brought this notion to the front of my mind again. My initial impression is that it is a different discussion than best practices, but with perhaps some cross-pollination. When I think of common sense in general, I think of a set of rules that you've either picked up or been taught that give you a baseline to reason and make decisions. Following common sense is a good way to avoid you shooting your entire leg off. But beyond a pretty low baseline, common sense gives way to a need to make educated decisions, and educated decisions can even override common sense when the evidence seems compelling enough. I might be playing a little loose with the definition here, but I think it is close enough to spearhead my example. When I think of common sense in software development, I think of all of the rules of basic hygiene to prevent a codebase from rapidly decaying into an incomprehensible mess. As examples, things like: not using a single global structure to maintain and communicate state within a non-trivial program; not using variables/method/class names that are just random gibberish; things that probably resemble what we've come to call anti-patterns quite closely. Where applying best practices the practical analogue to learning patterns, applying common sense could be seen as the practical analogue of learning anti- patterns. With this in mind, I'd like to pose a few questions that seeing the answers of others for might help me reason my way through this. **Do others believe that there is a notion of common sense in software development? Would be interested knowing the reasoning either way. ** **If so, is it a notion worth discussing? Is it something we should push for as much as we sometimes do with best practices? Is it something worth pushing for even harder?** If the analogy to anti-patterns seems reasonable, the general rule is that anti-patterns are only employed if there is no other way, and even then only under very limited circumstances. **How flexible should one be in allowing a codebase to deviate from common sense?** It seems unreasonable that the answer is "not at all," because sometimes expediency demands deviations. But, it seems like a different sort of argument than when to employ a "best practice." Maybe it isn't; if you don't think so, I'd like to learn why. This is far more opened ended and maybe worthy of a follow-on question all its own, **what sorts of recommendations would you point at that seem like matters of common sense?** Other thoughts are also welcome. * * * 1Perhaps I would do better to call them "commonly recurring domain patterns", but the name "best practices" is common enough that everyone knows what they are, even if they don't agree that they are. If the "best" part bothers you, just imagine I replaced "best practices" with something less authoritative sounding.


Are nested loops always O(n^k)?

If I have a loop within another loop, yet I know the inner loop will only run once, will this algorithm still be O(n^2)?               For i = 1 to n do               For j = 1 to i do                    If (i==j) do                        For k = 1 to n                            {Do stuff}      The very inner loop will run at most 1 time, since `i` will only equal `j` once per iteration of the second loop. Is this still n^3?


What are "Metro apps"?

While it is relatively new now (2011/09/15), are there any resources for explanations of Metro applications for Windows8? I've not seen anything at the moment that summarises an "elevator pitch" for them.


using dbus on Android

I would like to know if it is possible to use DBUS on Android using Java. From what I have been searching till now it appears like there is no DBUS programming support on Android. But then bluetooth on Android uses DBUS. I would like to confirm if it is actually the case. If so, is there a possibility that DBUS would be supported in the future.


What is the difference between Agile Modeling and the Agile Manifesto?

By searching for the different software development methods I found that there are two AM:   * Agile Modeling   * Agile Manifesto The problem is that I can't get the difference between them. If one is a part of another? or an update to the other?


What are safe keys to remap in vim?

So far I've been trying to use Vim in as vanilla a configuration as possible, so as to save myself hassle when moving between machines. However, there are a few things I'd really like to bind keys, such as to shorten `"_diwP` which I use often to delete the word under the cursor and replace it with one from the clipboard. Are there any particular keys that are conventionally reserved for user-defined mappings? The point of this question is mostly that I would like to avoid hassle later on when I decide to install some plugin or take my configuration files to vim on another OS and find that my key mappings clash with something else.


Is Windows Server 2008 R2 x64 usable as a developer workstation OS?

We're upgrading the RAM on our developer workstations and looking to move to a 64-bit OS. We've been using Windows 7 x86, but I'm wondering about using Server 2008 R2 x64 so that developers can use Hyper-V to virtualise different setups. Is anybody using Server 2008 R2 x64 as their workstation OS? If so, are there any issues running Visual Studio 2010, Expression Blend 4 and so on?


Way to allow inspection of java data model after exporting to file

I've refactored a program to remove its dependency on an sql database by storing all the state in a memory model. However the manager liked the ability to easily inspect the domain state just by doing an sql join/filter on the database at any time; and he wishes to maintain some similar domain inspection ability. We discussed having a call that dumps the model state to a file that can be inspected. There isn't that much state--it can all fit into memory--but the state is large enough that we need some mechanism to allow us to 'fetch' the child if a given parent better then manual inspection of the files. I need the best tool to make this doable. They are thinking of exporting everything to CSV to be read into a DB, which could work, but it seems off to be using a DB only for doing joins on data types. Plus, their old approach used Strings for joins that weren't guaranteed to be unique, and, with my addition of extra objects, thought would have to put into how to lay out the database fields to represent the new model objects (particularly child objects of parents). I've toyed with other ideas for this. One idea was to a CSV file and having some other program read in the CSV file and do 'sql like' joins, but haven't found a program that does this easily. I've also toyed with an interactive java interpreter so we can read things into our model and do calls against the model, even using linux base commands to write 'joins' with awk or similar. I'm not sure I like any option though. Does anyone have suggestions for a good way of doing this? p.s. We can SSH to the maintained systems at any time, but we can't copy files to or from them without permission when maintaining live systems. Any tool used to inspect memory has to be packaged with our release as its own jar with justification as to why we are including it.


MVP Pattern - Ways to restrict the user action based on security privilleges

In an MVP application, what should be the most appropriate way to implement restriction to some UI actions based on the current user's privileges? For example, in a role-based security, different roles will have different access to some UI interactions on the same view. If, for instance, we have an online store, on the products list page the customers can only view the details and add items to their cart, but an administrator must be also presented with `Add Product` buttons and `Delete` button on each item. Similar question has been asked here already, but the OP is asking for the UI making the permission checks. I am certain the UI (view) should not be responsible for permission validation, but still it has to know whether to visualize or not certain UI components. So, is there any well-defined or widely adopted pattern for telling the view which UI interactions it should disallow? I can think of a few solutions, but if there is a standard and proven one, I'd prefer to stick with that, rather than reinventing the wheel. * * * **Update** To clarify a bit further, as suggested in answers below, I am considering the approach of having the view accept the privileges information from the presenter. It is the form of that information that bothers me - if using flags as bit masks or some too-generic representation I will:   1. (+) Gain consistency in passing the permissions to the view   2. (-) Couple the view with logic for resolving the flags.  The other thing I have in mind is having the View expose all the flags it needs as settable properties for the presenter (like `view.IsDeleteItemAllowed`). So I will:   1. (+) Not have additional logic for the permissions in the view   2. (-) Add additional complexity to presenter to adapt permission flags to the view's properties. * * * So, I am thinking of using the later approach, because that way I can reuse the presenter with different view implementations; and will not rely on the view for understanding the permissions system (which may be a subject of changes). Is there anything I should worry about with that?


Using industrial earmuffs while programming to filter out talking

Unfortunately I have to work in a room full of talking colleagues. In order to concentrate, I wear headphones with music on at top volume, but this makes me sick at the end of the day. I would prefer silence, but there is no chance to get a private office. I could try and find some hidden place in the building and work on a laptop, but my boss wouldn't be happy with that. And I could leave the company, but I don't want to - I really like my job here. Industrial workers working in a noisy environment usually wear special earmuffs. I'm considering to get a pair of these, but I have two problems:   1. I don't know whether industrial earmuffs really filter out the noise of talking. Maybe these are designed to isolate _very_ loud noises. Talking is not loud here, it's just irritating.   2. These earmuffs usually have a weight of approx. 250 g. I don't know if this weight on the head is tolerable for, say, 8-10 hours of coding. Has anyone ever tried to wear industrial earmuffs during programming? Thank you in advance. **=== UPDATE ===** Instead of industrial earmuffs I chose to try custom-molded earplugs. My earplugs are made of medical silicone. They fill my ears completely and dampen the chatter well enough. It's relatively slow to remove them, which is an advantage: people who would like to bother me during programming have to wait. Maybe they will understand what I want and just leave me working. Anyway, I also tried SimplyNoise. The brown noise dampens chatter better than my earplugs, but it's really exhausting. The rain sound is much better in this respect. I also found it less tiresome than listening to music.