Repository pattern implementation that knows nothing about the database table and column names

I've seen around the Internet and Github, implementations for the design pattern Repository that knows about database table and column names. I was think, if I want to work with the database as a plugin, that I can unplug and plug another respecting Open/Closed for the rest of my code, my repository should not know about the column names of the database I'm using. So how to implement this pattern in a way that it can transform the result from the database into a Entity of my domain, without knowing about the database table and column names? As my main language is PHP, I saw that in Doctrine\ORM you can easily pass different yamls or xmls config files, mapping the column names to property names on the Entity, but... I cant be a hostage of a library implementation, if I want to implement raw PDO, or any other library for my repositories that doesn't make this hydration out-of-the-box, my implementation should do, so how? **Update**   ![Illustration](http://s30.postimg.org/u2vp7n0xt/Desenho_sem_t_tulo_1.jpg) **Update 2**   Please, take a look at: http://leocavalcante.github.io/patterns/2014/07/11/repository-pattern-and- database-schema.html


Views : ViewControllers, many to one, or one to one?

I have developed an Android application where, typically, each view (`layout.xml`) displayed on the screen has it's own corresponding fragment (for the purpose of this question I may refer to this as a `ViewController`). These views and Fragments/ViewControllers are appropriately named to reflect what they display. So this has the effect of allowing the programmer to easily pinpoint the files associated with what they see on any given screen. The above refers to the one to one part of my question. _Please note that with the above there are a few exceptions where very similar is displayed on two views so the`ViewController` is used for two views. (Using a simple switch (type) to determine what `layout.xml` file to load)_ On the flip side. I am currently working on the iOS version of the same app, which I didn't develop. It seems that they are adopting more of a one-to-many (`ViewController`:`View`) approach. There appears to be one `ViewController` that handles the display logic for many different types of views. In the `ViewController` are an assortment of boolean flags and arrays of data (to be displayed) that are used to determine what view to load and how to display it. This seems very cumbersome to me and coupled with no comments/ambiguous variable names I am finding it very difficult to implement changes into the project. What do you guys think of the two approaches? Which one would you prefer? I'm really considering putting in some extra time at work to refactor the iOS into a more 1:1 oriented approach. My reasoning for 1:1 over M:1 is that of modularity and legibility. After all, don't some people measure the quality of code based on how easy it is for another developer to pick up the reigns or how easy it is to pull a piece of code and use it somewhere else?


Why isn't testing a language a supported feature at the syntax level?

You can find an endless list of blogs, articles and websites promoting the benefits of unit testing your source code. It's almost guaranteed that the developers who programmed the compilers for Java, C++, C# and other typed languages used unit testing to verify their work. So why then, despite its popularity, is testing absent from the syntax of these languages? Microsoft introduced LINQ to C#, so why couldn't they also add testing? I'm not looking to predict what those language changes would be, but to clarify why they are absent to begin with. As an example: We know that you can write a `for` loop without the syntax of the `for` statement. You could use `while` or `if`/`goto` statements. Someone decided a `for` statement was more efficient and introduced it into a language. Why hasn't testing followed the same evolution of programming languages?


Determining which decorator classes are available via reflection

I'm creating a pizza place application where employees will be able to create orders for customers(pizza and any number of toppings). This is for a school project but the requirements have nothing to do with this question. On the GUI I have a number of checkboxes that the employee will use to determine which toppings the pizza should have. I want to use the decorator pattern for this. **This is what I want to do(just not sure if its a good idea):** I want to put all of my decorators in a separate namespace, and then using reflection grab all of the decorator names out of that name space and use them to build the checkbox list. The reason for doing this is because if more toppings are added later I think it would be beneficial to just be able to add assemblies (topping decorators) without having to recompile/re-distribute the entire application. Thoughts? (I just learned reflection and I have a hammer and am just trying to pound everything in that even remotely looks lilke a nail)


Remote limitations of hg4j?

I’m evaluating hg4j to see if it’s useable in my current project. I need a (preferably) pure Java hg library that can:   1. Check out a working copy of a _remote_ hg repo at, say, http://myhg01.example.com/myapp   2. Create a new repo on the same hg server; perhaps a new repo called “fizzbuzz” that would then be hosted from http://myhg01.example.com/fizzbuzz   3. Check code in (“push”) to that new repo My question: does hg4j currently do this? If not, does anyone have any suggestions for me?


How many indexes is too many indexes?

I have a table with about 37 indexes. Would that be considered too many? What are some best practices regarding indexing? EDIT: It is warehousing data, updated daily with new transactions. There are 47 million rows. 3 of the indexes are very necessary. The other 34~ are 'where' clause indexes intended to speed up queries.


Service layer coupling

I am working on writing a service layer for an order system in php. It's the typical scenario, you have an Order that can have multiple Line Items. So lets say a request is received to store a line item with pictures and comments. I might receive a json request such as               {          'type': 'Bike',         'color': 'Red',         'commentIds': [3193,3194]         'attachmentIds': [123,413]     }      My idea was to have a `Service_LineItem_Bike` class that knows how to take the json data and store an entity for a bike. My question is, the `Service_LineItem` class now needs to fetch comments and file attachments, and store the relationships. `Service_LineItem` seems like it should interact with a `Service_Comment` and a `Service_FileUpload`. Should instances of these two other services be instantiated and passed to the `Service_LineItem` constructor,or set by getters and setters? Dependency injection seems like the right solution, allowing a service access to a 'service fetching helper' seems wrong, and this should stay at the application level. I am using Doctrine 2 as a ORM, and I can technically write a dql query inside `Service_LineItem` to fetch the comments and file uploads necessary for the association, but this seems like it would have a tighter coupling, rather then leaving this up to the right service object.


What syntax should I use to execute functions in jQuery Terminal?

I want to add feature, to jQuery Terminal, that will allow to execute commands from the server. Right now it only have formatting syntax that look like this:               [[<list of one letter styles> ; <color> ; <background> ; <class>] TEXT ]      and if you want to display bold white text you can use: `[[b;#fff;]Some Text]`. What syntax should I use for executing commands that will not interfere with formatting but will be similar? Maybe something like `[{name}(param1, param2, param3)]` or `[[exec:name(param1, param2, param3)]]` Any suggestions are wellcome.


From a DDD perspective is a report generating service a domain service or an infrastructure service?

Let assume we have the following service whose responsibility is to generate Excel reports:               class ExcelReportService{             public String generateReport(String fileFormatFilePath, ResultSet data){           ReportFormat reportFormat = new ReportFormat(fileFormatFilePath);           ExcelDataFormatterService excelDataFormatterService = new ExcelDataFormatterService();           FormattedData formattedData = excelDataFormatterService.format(data);           ExcelFileService excelFileService = new ExcelFileService();           String reportPath= excelFileService.generateReport(reportFormat,formattedData);                    return reportPath;            }         }      This is pseudo code for the service I want to design where:   * `fileFormatFilePath`: path to a configuration file where I'll keep the format of my excel file (headers, column widths, number of columns,..etc)    * `data`: the actual records returned from the database. This data   can't be used directly coz I might need to make further calculations to the data before inserting them to the excel file.   * `ReportFormat`: Value object to hold the report format, has methods   like `getHeaders()`, `getColumnWidth()`,...etc.   * `ExcelDataFormatterService`: a service to hold any logic that need to be applied to the data returned from the database before inserting it to the file.   * `FormattedData`: Value object the represents the formatted data to be inserted. `ExcelFileService`: a wrapper top the 3rd party library that generates the excel file. Now how do you determine whether a service is an infrastructure or domain service?   I have the following 3 services here:   `ExcelReportService`, `ExcelDataFormatterService` and `ExcelFileService`?


Front end developers vs HTML/CSS coders plus "the JavaScript developer"

I was just googling around to find a good definition of front-end developer and the definitions that I found were pretty much "a guy that does HTML/CSS/JavaScript (jQuery)". But I think this is no longer the case. Today we have very complex interfaces, say a single page BackboneJS app that require a lot more than just "a guy that does HTML/CSS/JavaScript" and has no background in Computer Science. I would argue that the guy that engineers the front-end app (Backbone, Angular, etc) should be as (if not more) skilled programmer than the guy that engineers the back-end. So in my scenario (single page webapp - say with Backbone), I have 3 people:   1. A back-end programmer - the guy responsible for all the API calls that the Backbone app would make    2. A "front-end" programmer - they guy that's responsible for getting the work from the designer (wireframes if you will) and turning it into responsive, cross-browser, cross-platform HTML/CSS code   3. The "JavaScript" developer who makes everything light up, hooks up the HTML/CSS to the API and brings the app to life.  My question is: What is the most usual modern dev team structure? How is the work usually divided between the front end and back end developers. Of course if you only have full-stack developers that can produce JavaScript and say PHP equally well, then you have less of an issue. But still, who is the front-end developer and how do you call "the JavaScript developer"? Excuse my simple language, I tried to stay as far away from terminology as possible.


Software License for project using .NET and Sql Server Express

I considering making my application open source on github. I don't intend to sell it (neither in binary form nor source code form). It probably isn't even useful to a lot of people except maybe for learning purposes. The application is developed in .NET 4.5 (WPF). It doesn't use any external libraries. Only pure .NET libraries as provided by Microsoft. However, it is dependent on Microsoft Sql Server Express 2008. I would like to license the application under the GPLv3 but I don't know if that will work because of the SQL Server requirement. If not, what would you recommend? Sorry, but English isn't my first language and hence I'm having difficulties understanding all this legal stuff. Thanks for your time.


static set and non-static get method

I've the following Interface.               public interface ValueInterface     {       long  getValue();     }      And the class:               public class ValueCreator implements ValueInterface     {       private static long value  = 0;            public void setValue(long valueInDollar)       {         value= valueInDollar;       }            @Override       public long getValue()       {         return value;       }     }      The static code analyzer findbugs warned me not to set a static field in a non-static method. If I make the set method static, I can't make the getter static as it is an interface overridden method. So, is it okay to have a static setter and non-static getter or what could be a better approach?


What is the standard for modeling modern applications prior to development?

I'm taking on my first enterprise-level application ~~and I want my team to model the entire ASP.NET MVC C# application before we even tap out one line of code.~~ UPDATE: This was not intended to be a philosophical discussion about when to document/model an application. Please only provide answers for "how" to document/model. The truth is that I've always skimped in this department and I've never really modeled an application before. What is the standard way to do this? What type of diagrams should be used and what would the documentation look like? Links to sample diagrams and documentation is appreciated. When searching I can find numerous things around the net but I wanted to see if there is a current modern consensus on how to go about doing this. Thanks in advance! ### Closing Statement I had no idea this was such a sticky subject. Thank you to all of you that could set aside the obvious controversy and provide useful answers. It was an interesting discussion to say the least :) Another useful link I discovered is this: Do you use UML in Agile development practices?


What is happening to PHP 6?

I am excited about the changes in PHP 6 previewed in PHP 5.3+. However, I wonder why it takes so long to release PHP 6? Books about it have been published since 2008, and announcements on it since 2007, but I am yet to hear about an alpha or a beta. Why does it take so long to release it? Or is that the way it goes with all languages when they transition to a major release where I guess it takes around 4-5 years to release?


Should we have a database independent SQL like query language in Django?

**Note :**   * I know we have `Django ORM` already that keeps things database independent and converts to the database specific `SQL` queries.   * Once things starts getting complicated it is preferred to write `raw SQL` queries for better efficiency.   * When you write `raw sql` queries your code gets trapped with the database you are using.   * I also understand its important to use the full power of your database that can-not be achieved with the `django orm` alone. My Question :   * Until I use any database specific feature, why should one be trapped with the database.   * For instance : > We have a query with multiple joins and we decided to write a raw sql query. > Now, that makes my website `postgres` specific. Even when I have not used > any postgres specific feature. I feel there should be some `fake sql` language which can translate to any database's sql query. Even Django's ORM can be built over it. So, that if you go out of ORM but not database specific - you can still remain database independent. I asked the same question to `Jacob Kaplan Moss` (In person) :   * He advised me to stay with the database that I like and endure its whole power, to which I agree. But my point was not that we should be `database independent`.   * My point is we should be database independent until we use a database specific feature. Please explain, why should be there a `fake sql` layer over the actual sql ? ================================ **Update:** ================================ **My suggestion:** Solve the independence of the database on a `fake sql` level and then build ORM over that fake sql. So, if I have to write a sql query - I will use `fake sql` that would work on all databases yet raw SQL. That way, I will remain database independent unless I use a feature very specific to my database. Therefore, a query like `select * from table limit 10;` will work on both `postgres` and 'MS-SQL Server'. Is that sensible ? **Note:**   * I am not talking about `ANSI SQL`, I am suggesting a `fake sql` to make all databases work with 1 standard sql. **[ Which may not cover db specific features ]**


Team Parallel development in ASP.NET

I am developing an application written in ASP.NET (C#) which heavily use on Master Page and Session. As there will be enhancement in the same web application, and will be done by my teammate. is there any good approach that can enable we to work on the same solution, and delivery the change to UAT / PDN separately? the change control team of my company don't allow us to create 2 set of code in UAT and merge it into one set in PDN. any idea is welcome. Thanks.


The term "interface" in C++

Java makes a clear distinction between `class` and `interface`. (I believe C# does also, but I have no experience with it). When writing C++ however there is no language enforced distinction between class and interface. Consequently I've always viewed interface as a workaround for the lack of multiple inheritance in Java. Making such a distinction feels arbitrary and meaningless in C++. I've always tended to go with the "write things in the most obvious way" approach, so if in C++ I've got what might be called an interface in Java, e.g.:               class Foo {     public:       virtual void doStuff() = 0;       ~Foo() = 0;     };      and I then decided that most implementers of `Foo` wanted to share some common functionality I would probably write:               class Foo {     public:       virtual void doStuff() = 0;       ~Foo() {}     protected:       // If it needs this to do its thing:       int internalHelperThing(int);       // Or if it doesn't need the this pointer:       static int someOtherHelper(int);     };      Which then makes this not an interface in the Java sense anymore. Instead C++ has two important concepts, related to the same underlying inheritance problem:   1. `virtual` inhertiance   2. Classes with no member variables can occupy no extra space when used as a base > "Base class subobjects may have zero size" Reference Of those I try to avoid #1 wherever possible - it's rare to encounter a scenario where that genuinely is the "cleanest" design. #2 is however a subtle, but important difference between my understanding of the term "interface" and the C++ language features. As a result of this I currently (almost) never refer to things as "interfaces" in C++ and talk in terms of base classes and their sizes. I would say that in the context of C++ "interface" is a misnomer. It has come to my attention though that not many people make such a distinction.   1. Do I stand to lose anything by allowing (e.g. `protected`) non-`virtual` functions to exist within an "interface" in C++? (My feeling is the exactly the opposite - a more natural location for shared code)   2. Is the term "interface" meaningful in C++ - does it imply _only_ pure `virtual` or would it be fair to call C++ classes with no member variables an interface still?


How to Be a Software Engineer?

My problem is kind of weird so please bear with me. I have been working in a start up concerned basically with mobile development since my graduation 2 years ago. I develop apps for iOS but it's not really relevant. The start up structure is simply founders > developers, with no middle-tier technical supervision or project management whatsoever. A typical project cycle of ours is like this: meet with a client > send very vague requirements to an outsourced graphics designer > dig in development right after we get the design, no questions asked > then improvise improvise improvise! It's not that we are unaware that stuff like requirements analysis, UML, design patterns, source code control, testing, development methodologies... etc. exist, we just simply don't use them, and I mean like never. The result is usually a clunk of hardly-maintainable yet working code. Despite everything we are literally flourishing with many successful apps on all platforms and bigger clients each project. The thing is, we want the chaos to stop and we're looking for advice. How would you fix our company technically? Given that you can't hire project managers or team leaders just because we are barely 5 developers, so it wouldn't be a justified cost for the founders, but one-time things like courses, books, private training... etc is an option. Lastly, if it's relevant, we are based in Egypt. Thank you a lot in advance.


Program more professionally (planning, notation, ...)

I program a data-analysis framework for my company (20000LOCs by now). There are 2 programmers who help writing individual module for interfaces I have predefined. So far I haven't used much planning or tools. I basically think of new classes in my head and write them down in Python+Eclipse. As Python is good for proto-typing I can easily modify it if I overlook one aspect. However, sometimes I need to refactor some structure and I wonder if that hadn't happened if I used planning tools. What do you think is the most important start to plan programming more professionally? The project won't become too big as it's only for data analysis, but managing which data is processed which way is also tedious. Can you suggest methods, reading or tools? My class hierarchy is pretty flat so I don't see much use in class diagrams. However, something like call diagrams and diagrams which show how objects reference each other might help. I've learned OOP by myself, but I'm confident that once I consider all requirements I can design a nice class structure. What about TDD? For the moment I cannot imagine how to use it since most calculation are on network-like data with objects and many object references (links). Moreover data content hasn't been a problem yet. Yet, I suspect that some more professional approach might be more efficient. Ideas?


Methods for systematically researching technologies to use in a project?

If I want to recommend a technology/plugin/library to my company for use in a project, are there any methodologies I can use that will produce more reliable results and a more convincing presentation of said results than just my own "common sense" approach?


Should I Correct Candidates' Interview Answers?

I've been interviewing software engineers lately and I tend to ask harder and hardeer questions until they get something wrong, then switch to another technology track and do the same. When the candidates do get something wrong, I always tell them the right answer...mainly because that's what I would want if I were being interviewed. It sucks to just hear "no that's not right" and nothing else... Yesterday a candidate made a snarky comment when I gave him the correct answer after he answered incorrectly, saying "well I'm not sure I'll ever use that information...". I never speak condescendingly or critically. I just say in a matter of fact tone: "actually, in xyz language, abc is implemented in such a way, not in that way". Is my practice of providing correct answers inappropriate? Should I reconsider this practice?


Code Review process

I'm looking for a light-weight code review process. A couple of requirements, the reviewer must be able to do the review alone at the time of his/her choosing (not tied to check-ins), the reviewer must be able to easily find the target code, the review has to leave some document showing what was reviewed. I know there are tools available for code review but I work in a very ridig environment and introducing new tools is not an option. One idea I've been thinking about is to create a new Visual Studio Task List token called REVIEW, and use it to mark the code that needs reviewing. Something like,               // REVIEW doe_john: New method, not sure about the exception.      Then we would add a Review workitem in TFS (we're using the CMM template). Another possibility, which I would actually prefer, would be to have developers create a TFS Review workitem and add links to code to it, but I don't know if this is possible. Obviously you can add a link to a file, but I'd like to have a link to a particular method.


is 'protected' ever reasonable outside of virtual methods and destructors?

so, suppose you have some fields and methods marked protected (non-virtual). presumably, you did this because you didn't mark them public because you don't want some nincompoop to accidentally call them in the wrong order or pass in invalid parameters, or you don't want people to rely on behaviour that you're going to change later. so, why is it okay for that nincompoop to use those fields and methods from a subclass? as far as i can tell, they can still screw up in the same ways, and the same compatibility issues still exist if you change the implementation. the cases for protected i can think of are: non-virtual destructors, so you can't break things by deleting the base class. virtual methods, so you can override 'private' methods called by the base class. constructors in c++. in java/c# marking the class as abstract will do basically the same. any other use cases?


Are these advanced/unfair interview questions regarding Java concurrency?

Here are some questions I've recently asked interviewees who say they know Java concurrency:   1. Explain the hazard of "memory visibility" - the way the JVM can reorder certain operations on variables that are unprotected by a monitor and not declared `volatile`, such that one thread may not see the changes made by another thread. Usually I ask this one by showing code where this hazard is present (e.g. the `NoVisibility` example in Listing 3.1 from "Java Concurrency in Practice" by Goetz et al) and asking what is wrong.   2. Explain how `volatile` affects not just the actual variable declared `volatile`, but also any changes to variables made by a thread before it changes the `volatile` variable.    3. Why might you use `volatile` instead of `synchronized`?    4. Implement a condition variable with `wait()` and `notifyAll()`. Explain why you should use `notifyAll()`. Explain why the condition variable should be tested with a `while` loop. My question is - are these appropriate or too advanced to ask someone who says they know Java concurrency? And while we're at it, do you think that someone working in Java concurrency should be expected to have an above-average knowledge of Java garbage collection?


Are there any off the shelf solutions for feature use analysis?

I write a set of productivity tools that sells online and have tens of thousands of users. While we do get very good feedback, this tends to come from only the most vocal users, so we fear we might be missing the big picture. We would like to know if there is any off the shelf (or nearly so) solution to capture usage of different features and to report usage patterns and trends over time. Note: These tools are native apps, not web-based. I know about Google Analytics and the like. They're great, but I'm looking for native code solutions.


Computed Values and Simple Reads - A nagging pain for my Domain Driven Designs!

The problem I continually face is how to deal with computed values driven by domain logic while still working efficiently against the data store. Example: I'm returning a list of Products from my repository via a service. This list is limited by pagination info from request DTO sent by the client. In addition, the DTO specifies a sort parameter (a client-friendly enum). In a simple scenario, everything works great: the service sends paging and sorting expressions to the repo and the repo issues an efficient query to the DB. That all breaks down, however, when I need to sort on values generated in memory from my domain model. For instance the Product class has an IsExpired() method that returns a bool based on business logic. Now I can't sort and page at the repo level --it would all have be done in memory (inefficient) and my service would have to know the intricacies of when to issue these params to the repo and when to perform sorting/paging itself. The only pattern that seems to make sense to me is to store the state of the entity in the db (make IsExpired() a readonly field and update it via the domain logic before saving). If I separate this logic into a separate "read model/dto" and "reporting" repository, I'm making my model more anemic than I'd like to. BTW, every example I've seen out there for computations like this really seems to lean on in-memory processing and glossing over the fact that it is far less efficient in the long run. Maybe I'm prematurely optimizing, but that just doesn't sit right with me. I'd love to hear how others have dealt with this as I'm sure it's common on nearly project involving DDD.


Web interface with FastCGI or with direct HTTP?

Let's assume I want (for fun at start) to play with some new DSL (domain specific language) idea. And I really want its user[s] (probably only me at first) to interact thru a web interface. I'll probably implement it in C++ (probably using LLVM). Should I use an HTTP server library (like libonion or microhttpd) to talk directly HTTP or should I use FastCGI? I could also use libraries doing both like cppcms or wt... In particular, I am noticing that several recent web frameworks (Opa, Ocsigen, ...) do not have any FastCGI interface but only HTTP one.... (but Ur/Web seems to have both) So my feeling is that FastCGI is really out of fashion.... Any opinions on that? Do you know recently started project using FastCGI ? (and what about SCGI?)


Is there a better way of handling access control logic instead of it being in the UI?

Through most of my dev experience, I've never had to deal with much variety of access control architectures. They've all been pretty straight forward:               Group [Create, Update, Delete]         - User 1         - User 2          Group [Update, Delete]         - User 2      Which, for all intents and purposes, works well. The problem I have is the actual implementation of it. All the solutions I've worked on either grant/deny the visibility of a menu link, or disable a button etc. This is all controlled via the top-most layer of the app, whether it be a WebApp or WinForms UI. I'm in the early stages of designing a rather large WinForms system so I'd like to get the security architecture right from the beginning. Although I don't see myself getting away from visually limiting the user from performing certain actions (by disabling restricted controls etc), I'm sure there are better solutions available then doing most of the work in the UI. As I understand it (and these might be limited by my ignorance), these are my options:   * Put the logic to return and verify user rights in the business layer   * On the form_load event, get these rules and enable/disabled UI elements   * Leave the UI elements in tact and halt the operation from within the business layer if the user doesn't have permission for the action (dirty!) Surely there must be more elegant solutions than this. Could someone please provide me with alternatives or improvements to the aforementioned ideas? Am I thinking about it incorrectly? Should I re-evaluate my database design while I'm at it?


Will staying in this position affect my career negatively?

I work at a small software company where the owners are also the managers. My concern is that any and all progression in technology is met with utter disdain by management. Some of the comments are as follows:   * LINQ, nHibernate, and ORM are bad programming practice, we will never use them.   * The majority of large applications are still written in VB6.   * The web is just a waste of time, its not meant for applications. Every time a new version of development software is released, I have to listen to the management complain about it for hours. Technologies like WPF, WCF, MVC and Entity are completely ignored. All that said, its not a horrible place to work, the pay is average and its close to home. My concern is that, even though we are technically using the latest version of .NET, we are hardly using the latest technologies, we might as well be using .NET 1. If I decide to move, will this "experience" limit me career wise? I have been here for a few years already. EDIT: I am really grateful for the superb response. I honestly think it might be in my own best interest to make a move.


Multiple possible jsp views for a request

I'm looking to offer the user some way of changing how a single page looks based on some pre-defined jsps. i.e. Two or more jsp's contain similar information, and would be backed by a single controller method. The controller would decide which view to return.   1. Is there a common way of achieving this? At the moment I have some administration screens where I control a list of possible views. The user can then choose which one to see from a drop-down. My current issue is that I don't know how to confirm (at the admin screen) that the view is valid.   2. Is there a way of asking spring for all possible views so I can filter them and resent a drop-down on the admin screen rather than a free text field? If not is there a way of asking spring if a single view is valid? All these views will reside under a common directory, so it would probably be possible to scan recursively from that point and build a list of possible views. This goes beyond simply changing the css, since the page content might be different despite being backed by the same model.


Books and stories on programming culture, specifically in the 80's / early 90's

I've enjoyed a number of (fiction/non-fiction books) about hacker culture and running a software business in the 80's, 90's. For some reason things seemed so much more exciting back then. Examples are:   * Microserfs (Douglas Coupland)   * Accidental Empires (Robert X. Cringely   * Almost Pefect (W.E. Peterson, online!)   * Coders at Work (Peter Seibel) Today I'm an entrepeneur and programmer. Back in the 80's a I was a young geek hacking DOS TSR's and coding GWBasic / QBasic. In the 90's I was a C.S. university student, experiencing the rise of the Internet world wide. When reading these books running a software business seemed so much more fun than it is nowadays. Things used to be so much simpler, opportunities seemed to be everywhere and the startups seemed to work with much more real problems (inventing spreadsheets, writing word processors in assembly on 6 different platforms) than all our current web 2.0 social networking toys. Does anyone share these feelings? Does anyone have any good (personal) stories from back then or know of other good books to read?


Source code modification and GPLv3 compatibility

Assume that the source file A contains the following license notice: "This code is Copyright 1234 by XYZ. It may be freely redistributed in its entirety provided that this copyright notice is not removed." Can I combine it with a project B published under the GPL version 3 license? In particular, does the lack of a permission to modify source file A ("redistributed in its entirety") prohibit that?


Is there a good reason not to display error messages to users?

Windows 8 seems to have chosen to silently shutdown applications that misbehave, there is no message informing the user something bad happened and no information on why the application closed. I heard through the grapevine that employees at Microsoft are tired of customers blaming them for crashes and that they believe when they display an error to the user the user will accuse Microsoft of the crash instead of the app developer. Regardless of whether that is true or not is it really not a good idea to display error messages? I thought that error messages at least give users something to use when they are searching the web for help or talking to customer service. What possible good reason is there for crashing silently and not showing an error message?


Use of Unmodified AGPLv3 lib - am I AGPL too?

So, I've been reading the AGPL and here is my understanding (not being a lawyer and I'm not trying to look at it through the lens of "Since I WANT it to be ''free'', it therefore is.". In my case, I am considering the use of itext, an AGPL library, to crack open PDF files and extract the text - that's it. There will be an internal desktop app and I've proposed using my extraction code (which uses the itext dll) on the website to speed up the process for those folks upstairs who've been doing it manually for years. Under definitions:   * "the program" means the itext lib, being the copyrightable work.   * "modify" or "based on" means, a version of the program which differs from the original. Not applicable here since I am not modifying the code.   * "covered work" means the original or modified versions of the original work. In my case, it would be the original work.   * "propagate" and "convey" mean to copy or distribute the program (the itext lib, in my case, compiled as a dll), in which case, as I understand it, the source to the covered work must be made available. This doesn't apply to use within companies (since the company can require employees to not make copies and distribute software). Use on public facing networks though, might be a consideration per sec13, though the web users won't be interacting with the program itself or with the output of the program.   * "interactive user interface"... so far, haven't seen one in the lib but this is probably the least clear of the definitions since it mentions the "work" and libs (the work, in this case) generally don't interact with users. If I need to, I can include a mention somewhere, no biggie. So, by my interpretation of the definitions, the covered work is the itext code I am using. The code I write separately, is not based on or modified from the itext code and thus, can be licenced any way I choose, incl locking it down tightly or posting openly on my fav forum. So long as I do not modify or incorporate copyrighted AGPL code directly into my code, there is nothing I can see in this licence that prevents me from linking to the original version I downloaded. Most I might have to do is provide the source to the version of the covered work. So, emotions aside and focusing solely on legality, what say you? I think it's clear from the FSF FAQ, that internal corporate use means I can do pretty much anything I like and no source needs to be distributed outside the organization. My only real concern is making a web app which in turn, makes calls to the itext lib. What am I required to do in this case? I believe I only need to provide a link or location to download the itext code. Another option, what if I made a small, separate, standalone program, and had the website call it via a standard "run" mechanism? The rest of the existing website should not have to suddenly fall under the AGPL even if my text extractor portion does, correct?


see what ARC does?

If I understand correctly, all ARC does is automatically add memory-management statements such as `retain` and `autorelease` in the proper places in a program. Is there any way to see all the memory-management statements that ARC automatically adds to a program?


One codebase - lots of hosted services (similar to a basecamp style service) - planning structure

We have built a service (PHP Based) for a client, and are now looking to offer it to other clients as a hosted service. For this example, think of it like a hosted forum service, where a client signs up on our site, and is given a subdomain or can use their own domain, and the code picks up the domain, checks it against a 'master' users table, and then loads the content as needed. I'm trying to work out the best way of handling multiple clients. At the moment I can only think of two options that would work:   * **Option 1** - Have 1 set of database tables, but on each table have a column called 'siteid' - this would mean every query has to check the siteid. This would effectively work with just 1 codebase, and 1 database.   * **Option 2** - Have 1 'master' database with all the core stuff such as the client details and their domain. Then when the systen checks the domain, it pulls the clients database details (username/password/dbname) from a table, and loads a second database. The issue here is security of the mysql server details, however it does have the benefit that they are running their own database instead of sharing one. Which option would I be better taking here, and why? Ideally I want it to be fairly easy to convert the 'standalone' script to the 'multi-domain' script as we're on a tight deadline.


Refactoring a live system that is tightly coupled with improper data models and business logic in the front-end

# Scenario This was a project that I once had to maintain. After reading _Working Effectively with Legacy Code_ , I started to think how I would refactor this system in a live environment, _if I had to (thankfully, I didn't)._ The system was a legacy system without documentation and extremely tightly coupled. Database relationships were incorrectly modelled - i.e. objects that were meant to be many-to-one were mapped as one-to-one. Using "duplication" allowed for "pseudo-many-to-one" relationships. Business logic was stored as JavaScript solely on the front-end. Data was tightly coupled to Presentation data. As an example, a Question object could not exist without a Table Cell object. The database had a table call "TableCell" to store inline CSS for each cell which was mapped one-to-one with a "Question" object. The system was a horrendous mess and eventually lead to loss of data and a complete re-write in the end. In total the project was about 350K LOC. As a side note, the reason why the system was re-written (or needed refactoring) was that it was to be exposed to the Internet, but we were able to modify the business logic using the Chrome Debugger to elevate roles, inject code, and execute all sorts of undesired functions. ## Question The book used examples where the logic was placed in the middle tier. However, what happens when the business logic is placed in the front-end? From my point of view the refactor process would have to go this way:   1. Refactor the front-end JavaScript to understand the business logic   2. Refactor the middle-tier to include validation   3. Refactor the database to decouple the data models   4. Migrate the data   5. Refactor the middle-tier to decouple the data models   6. Refactor the front-end to reflect the changes in the data models. I have read Techniques to re-factor garbage and maintain sanity? and it is helpful, but it doesn't address the order in which refactoring should occur for this specific scenario. This process seems to add a lot of redundancy as the front-end and middle-tier are refactored twice in the live system.   * What is a more efficient way to refactor such a system while keeping the system live?


Handling multiple packet types in Java 8

I have a Netty-based game server implementation that handles 40 or so distinct packets with their own serialization structure, for brevity I'll refer to them as `FooPacket`, `BarPacket`, ... These packet types have been assigned consecutive numerical "packet types", which are unsigned bytes. For example, `FooPacket` is type 0x01, `BarPacket` is type 0x02, etc... All of these packets extend an abstract class, `MyGameNetworkPacket`. My current approach with Netty is to use an initial decoding layer to convert a TCP stream into a series of unparsed packet objects, which are defined as consisting of a packet type, length, and buffer containing the actual packet contents. (no byte stuffing is performed). I then feed this packet down the pipeline to one of a few "deserializing processors", each of which handles a set of packet types that are semantically related to each other (for example one such processor might handle connection state messages, while another may handle packets related to a certain aspect of the game itself). As per the design of Netty's MessageToMessageDecoder usage, my decoder is implemented as:               protected void decode (ChannelHandlerContext ctx, UnparsedPacket msg, List<Object> out)             throws Exception {         switch (msg.command) {             case FooPacket.COMMAND_ID:                 FooPacket fooPacket = new FooPacket(msg.frame);                 out.add(fooPacket);                 break;             case BarPacket.COMMAND_ID:                 BarPacket barPacket = new BarPacket(msg.frame);                 out.add(barPacket);                 break;         }          }      Once I get a structure decided upon I can easily create this with a code generator. In addition, I override `public boolean acceptInboundMessage(Object)` to specify if an unparsed packet should be handled by this decoder. This is attaining a bit of what appears to be a code-smell for me, so I was looking into alternative solutions, such as:   * Having an array whose (integer keys) map to values of a lambda that takes a RawPacket and returns the parsed packet. This seems like a somewhat weird way to use an array and requires that I manually maintain the definition of that array so that its index-element mapping exactly matches the actual packet type to packet structure mapping already in use.   * Having a map structure that does the same thing as the array. Similar pitfalls, but somewhat more maintainable. Are these any more novel ways to approach this that I haven't thought of yet?


How create unit test the performance of an application?

What I want is to run automatically methods to tests the performance of an application. Just like the unit tests, but with the purpose of evaluate the performance and create reports if is it possible. Is there any framework or tool to achieve this?


Using Mockito.reset

I've just read a lot of arguments against using `Mockito.reset` and can't make much sense of it. Put differently, I agree in general, but there's always a case which looks like using `reset` is useful or even necessary. Grossly simplified, my class under test is an encapsulated map like               class Handler {         private final Map<String, String> map;              public void handle(RequestResponse rr) {             if (rr.isPut()) {                 map.put(rr.key(), rr.value());                 rr.response("OK");             } else {                 rr.response(map.get(rr.key());             }         }     }      To test it, I mock `RequestResponse` and do something like               when(rr.isPut()).thenReturn(true);     when(rr.key()).thenReturn("key");     when(rr.value()).thenReturn("value");     handler.handle(rr);     verify(rr).response("OK");          reset(rr);          when(rr.isPut()).thenReturn(false);     when(rr.key()).thenReturn("key");     handler.handle(rr);     verify(rr).response("value");          reset(rr);          when(rr.isPut()).thenReturn(false);     when(rr.key()).thenReturn("anotherKey");     handler.handle(rr);     verify(rr).response(null);      I can see, I'm testing three things at once:   * proper response after "put"   * proper value returned from get with the same key   * `null` returned from get with another key I can imagine reasons to separate the two last tests. However, they both need the first one and I still need a `reset` in between? Or don't I? ### Update In the meantime the class under test has got a bit more complicated and the need for `reset` bigger. It's sort of a state machine and the test looks like   * repeat the following accross different paths      * try an illegal step and expect an exception     * try another illegal step and expect an exception     * do a legal step and verify output I actually only need two methods, one verifying the exception for an illegal step and the other verifying correct output for a legal step. Executing an illegal step mustn't change the state, so it's safe to mix it in. Consider this example: If the only valid input sequence was `A, B, C` (three steps) and the corresponding outputs were `a, b, c`, then a test looks like               checkException("B")     checkException("C")          checkOutput("A", "a")     checkException("A")     checkException("C")          checkOutput("B", "b")     checkException("A")     checkException("B")          checkOutput("C", "c")     checkException("A")     checkException("B")     checkException("C")      walks through the whole path and verifies everything. It would take many "normal" single-condition-verifying tests to achieve the same, right?


Basic logical operator question

#include <stdio.h>     int main()     {         int k=5;         if(++k < 5 && k++ / 5 || ++k <= 8)         {              printf("%d",k);         }         return 0;     }      Why is the output 7 and not 8?(I am a beginner in programming so please bear with me.)


Simple method for reliably detecting code in text?

GMail has this feature where it will warn you if you try to send an email that it _thinks_ might have an attachment. ![Did you mean to attach files?](http://i.stack.imgur.com/sHTG9.png) Because GMail detected the string `see the attached` in the email, but no actual attachment, it warns me with an OK / Cancel dialog when I click the Send button. We have a related problem on Stack Overflow. That is, when a user enters a post like this one:               my problem is I need to change the database but I don't won't to create      a new connection. example:          DataSet dsMasterInfo = new DataSet();     Database db = DatabaseFactory.CreateDatabase("ConnectionString");     DbCommand dbCommand = db.GetStoredProcCommand("uspGetMasterName");      **This user did not format their code as _code!_** That is, they didn't indent by 4 spaces per Markdown, or use the code button (or the keyboard shortcut `ctrl`+`k`) which does that for them. Thus, our system is accreting a lot of edits where people have to go in and manually format code for people that are somehow unable to figure this out. This leads to a lot of bellyaching. We've improved the editor help several times, but short of driving over to the user's house and pressing the correct buttons on their keyboard for them, we're at a loss to see what to do next. That's why we are considering a Google GMail style warning: > Did you mean to post code? > > You wrote stuff that we think looks like code, but you didn't format it as > code by indenting 4 spaces, using the toolbar code button or the `ctrl`+`k` > code formatting command. However, presenting this warning requires us to **detect the presence of what we think is unformatted code in a question**. What is a simple, semi-reliable way of doing this?   * Per Markdown, code is always indented by 4 spaces or within backticks, so anything correctly formatted can be discarded from the check immediately.   * This is only a _warning_ and it will only apply to low-reputation users asking their first questions (or providing their first answers), so some false positives are OK, so long as they are about 5% or less.   * Questions on Stack Overflow can be in _any_ language, though we can realistically limit our check to, say, the "big ten" languages. Per the tags page that would be C#, Java, PHP, JavaScript, Objective-C, C, C++, Python, Ruby.   * Use the Stack Overflow creative commons data dump to audit your potential solution (or just pick a few questions in the top 10 tags on Stack Overflow) and see how it does.   * Pseudocode is fine, but we use c# if you want to be extra friendly.   * The simpler the better (so long as it works). KISS! If your solution requires us to attempt to compile posts in 10 different compilers, or an army of people to manually train a bayesian inference engine, that's ... not exactly what we had in mind.


Licensing issue for RSA and Rijndael algorithms

I'm using .Net to build a commercial application, i.e. a secure chat application. This application is using RSA and Rijndael algorithms. Do we need licenses for using RSA and Rijndael algorithms for commercial product?


How do you design code?

Even though I work as a programmer, I've never actually been trained as one. Everything I know is self-taught. As part of my continual process of self- improvement, I want to develop better habits/techniques. I'm wondering how most of you design your code before you actually begin coding? Right now, I write an empty program with all my methods and variables commented, and pseudo-code in place of blocks of logic. Do you guys have other tricks/techniques you can share? Right now, most of my work is in client-side Javascript development but of course, these techniques should be global.


Making the move to team leading

I'm looking for some examples of experiences from people who have made the move from programmer to team leader. I'm kind of wanting to know the reasons why people have done it. Specifically, these are some questions and concerns that are floating around in my head.   * Did you have a waning desire to write code but still a strong desire to create programs?   * Did you realise that you were more of a people person and you could utilise your communication skills better?   * Was it because you were asked by management and thought why not?   * For the money?   * How were the initial few months after making the move?   * Were relations with colleagues affected?


OSS - GPL v3 plugins in non-copyleft codebase.

I've been working on software to modify a game's resource files, and I'm planning on releasing it in open source. I'm perfectly fine with releasing my code under gpl v3. However, I'm afraid that that would deter others from writing extensions for my software, as I have had others offer to do so - the community which I'm working with is very much afraid of open source leeches, and as a result, the majority of popular released projects are closed source. As such, I'd be more comfortable with something like BSD or MIT. The codebase is extremely modular, and one window might consist of the end products of many different plugins. One plugin which I am working with is the work (licensed under gpl v3) of a person who I have communicated with, who was enthusiastic of me using his software. As one other person has contributed to that software, I don't think he can simply release his source to me under a different license. In the future, I'd like to have more plugins for a variety of things which would be difficult to manually implement (as doing so would require large amounts of reverse engineering). Tl;dr: As I am in good terms with these people, is there any means for me to use their code as plugins? I would have permission, but licensing would be the issue, since others have contributed to the codebases. If so, would it be okay if i distributed their plugins with my built software (in a plugins folder)? How about placing them in the code repository and visual studio solution? Any other advice would be appreciated. Thanks!


Continuously Improving output of a team

I am having my own software service company, DIGICORP and I am leading a team of 10 developers. The total company size is of around 50 persons. We are four friends who have started this venture from 2004. During last year, we have read the Getting Real and Rework books from 37signals founders. We closely followed what Zappos did, we have started focusing more on providing quality service and building great environment in the company. This has changed a lot in the way we were doing business. We have been able to build a friendly culture. We also make sure that the team does not face any issues with infrastructure. We keep doing innovative events to make sure that the team has more and more reasons to work at the company. We started making following changes to our business decisions   * Limited Team Size   * Not throwing more time at a problem (Avoiding late night stays and working on weekends)    * 5 days and 8 hours of effective output We face mainly following two issues.   * We find that the output we get today was less as compared to past. This is not just an observation, some of our old employees talk to us in one to one and they also raise the same question.    * We recently discovered that in the friendly culture we have most of the time started showing the better side of the work that way it is becoming more difficult nowadays to reprimand someone when they make mistake. Also due to the same fact, everyone in the company has a feeling that they are producing the greatest output.  So the answer I am looking for :   * How can we improve culture so that everyone in the team keeps improving output regularly and their 8 hours keep becoming more and more valuable?


Choice of technology to develop multi-platform application

What I have is business WinForms application written in C#.   What I would like to do is to redesign it to meet multi-platform approach. I was thinking about architecture involving application server (executing all the logic and performing database operations) and thin client side running on Windows and Mac OS as well as Android, iPhone or just in web browser. Windows version should also have to be able to use methods from some DLLs. Solution that comes to my mind is desktop client developed to target Silverlight (for Windows and Mac OS users). Web part, based on ASP.NET, would be adjusted for mobile devices. All would use WebServices provided by WCF server running on Mono. What do you think about this approach? Why is it good and why if it's not? I know that all of those platforms are in range of Adobe AIR but choosing it will result in abandonment of all existing code and development team's knowledge about .NET. Thank you for any hint.


If the user declines a "continue?" prompt, what exit code should be returned?

In terminal based scripts (Shell, Bash, Python, etc), if you prompt the user _"Do you wish to continue?"_ and the user chooses _"No"_ , what exit code should the script ideally return? On one hand, the script executed as the user expected it to (the user wanted to quit, so it quit), so it should give an exit code of `0`. On the other hand, the script was unable to complete its main task, which should be a non- zero exit code.


Multiple applications in a single Visual Studio solution

I am doing work for a company that is wanting to put all their .Net applications (web applications, Windows applications and console applications) together in a single Visual Studio solution. I am looking for experience from developers who either structure their own applications this way or who work in a company that does this. Is this a good idea?   * What are the pro's/con's to putting all your applications in a single solution rather than having separate solutions for each application?    * How fast is Visual Studio with a solution of 20+ projects?    * And how stable is the solution file with source-controlled concurrent development?


Discovering functionality from parallel class hierarchy

I have an abstract syntax tree which I want to compile down to different representations. I am now struggling to arrange the classes in a way that new representations can be added easily. The easiest way to achieve this is to add a method for each representation, e.g. `compile_to_foo`, `compile_to_bar`. Additional representations can be added by monkey patching. The problem with this is that the compilation implementations are spread all over the place, and that it violates the single responsibility principle. The advantage is that compilation can be inherited. Now, I could also define a compilation function containing a giant switch which dispatches on argument type. But this looses advantages of polymorphism, and makes inheriting behavior of the compilation more difficult. This is not a viable option. An interesting solution would use an abstract factory: ![Abstract Factory](http://i.stack.imgur.com/Lhciy.png) This design looks fairly promising, but has some disadvantages:   * The AST Node hierarchy cannot be extended without also extending the `AbstractCompiler`, and in turn all concrete compilers and their parallel hierarchies of concrete nodes.   * The subtyping information of the AST nodes is spead across the whole system. it has to be specified between the `AbstractNode`s in order to share behaviour (I will be using roles), between the `ConcreteNode`s in order to share `compile` implementations, and in at least in the `AbstractCompiler` to provide default implementations (e.g. `method NodeA() { return Node() }`). This could be partially solved via metaprogramming.   * When an AST is built, this can only compile down to _one_ representation. If I want to have multiple outputs, I need to rebuild the AST with a different `ConcreteCompiler`. Ideally, I would just pass a concrete compiler instance as a parameter to the `compile` method: ![Ideal class diagram](http://i.stack.imgur.com/pRbBz.png) … but I have no idea how the `compile` method could obtain the actual implementation from a parallel class hierarchy (without again using a giant switch on the node type). I also investigated the Bridge pattern, but the solution does not seem applicable to my problem without creating a thousand little bridges. I carefully read through this previous question: “Designing a robust architecture for multiple export types?”. The key difference is that the input data (there: equivalent, standalone data represenations) are now hierarchical AST nodes, so that inheritance between the compilation implementations is crucial. The system will be implemented in Perl, so I'm not restricted to classic OOP, but can also use Metaprogramming, Roles (aka. traits), and Functional Programming. What am I missing? Is there an architecture I could use to elegantly structure this system? How can I make the corresponding class from the parallel class hierarchy discoverable to the node classes, without sacrificing polymorphism?


How can I separate the user interface from the business logic while still maintaining efficiency?

Let's say that I want to show a form that represents 10 different objects on a combobox. For example, I want the user to pick one hamburguer from 10 different ones that contain tomatoes. Since I want to separate UI and logic, I'd have to pass the form a string representation of the hamburguers in order to display them on the combobox. Otherwise, the UI would have to dig into the objects fields. Then the user would pick a hamburguer from the combobox, and submit it back to the controller. Now the controller would have to find again said hamburguer based on the string representation used by the form (maybe an ID?). Isn't that incredibly inefficient? You already had the objects you wanted to pick one from. If you submited to the form the whole objects, and then returned a specific object, you wouldn't have to refind it later on since the form already returned a reference to that object. Moreover, if I'm wrong and you actually should send the whole object to the form, how can I isolate UI from logic?


Is this bad design? How can it be improved?

I wrote the following a while back, but I've come to review it recently, and now don't think it's good design. The design is for a kind of modular database layer using Entity Framework 4. There is a single database object which loads (lazily) entity framework contexts from external libraries in a specified location, and instances of the loaded contexts are stored in a hash table against their name (EG "ContentMgmtContext"). All contact with the database in this system is through stored procedures. To make a call to the database, the query method signature looks like this:               List<TReturn> Query<TReturn>(string Context,                                   string Procedure,                                   TransactionScope Scope,                                   List<ObjectParameter> QueryParameters)      This modularity is something I like. However, there is one significant drawback to this approach: `when using the database layer, the code using it has to have a reference to the library in which the context is stored, in order to access the types returned by the stored procedures through Entity Framework.` In the model, the objects from the database layer are translated in to new objects that the view and controller use. I think this is bad design, but how can I improve it? I've considered adding an empty interface like `IStoredProecedureObject` to give every data type returned by a stored procedure a common base type, however this appears to be foiled by Entity Framework. Every time the `.edmx` file is recompiled, the code is generated anew, and any additions removed. Is there any way to stop this happening? How can I improve this design? What (else) is wrong with it? Or am I on the right track?


Do hardcopy certificates matter?

I'm asking this question because Oracle has decided not to give hardcopy certificates for all Sun certifications Is this good or bad? and does any employer ask for the certificate itself?


I use an IDE (Eclipse) to develop software.  Why should I switch to vim or emacs?

My day job is java/web developer. I have been using eclipse for ~5years. I think its excellent and I also use Webstorm for javascript and html/jsp. I do on occasion need to ssh into server and mess around with config files; for this I use vi and it pains me. I have to get up a webpage listing the syntax/commands : _press escape, then asterix, turn around three times and the text will be entered two lines above your cursor_. Its so **unintuitive** to me, and I imagine anyone who grew up in the late eighties nineties. Here are the main reasons I think eclipse is brilliant(and I assume other IDE's), and do not switch to emacs and/or vim.   * Error highlighting with no need to recompile project.   * Code assist.   * Refactoring.   * Opening call hiearchy/Opening declaration.   * Fully integrated with source control.   * Debugger is included.   * availablity of 3rd party plugins - eg findbugs/checkstyle. One of the arguments I hear is that with emacs/vim you can create your own plugins - well OK, but you can do that in eclipse too. But you don't need to as everything is already there! Its like saying buy this half built car, you can build the rest yourself. Why are people using emacs/vim ? Do people who use it actually work on complex object-oriented projects in large organisations ? **What are the reasons to switch to vim/emacs. How would my productivity increase if I did switch?**


How should I implement "queueing" of approval on my objects?

I have a list of objects that will need to go through an approval process. I am curious if it would be best to simply add some properties to my object, like `ApprovedBy`, and `ApprovedOn`. Another option is to create an `ObjectApproval` class that contains this information as well as other information that needs to be stored. If I wanted a list of objects that still needed approval, I could simply query for a null `ApprovedBy` in the first scenario. In the second scenario, I would have to maintain an accurate list of `ObjectApproval` items. The next thing is, what if I need a multi-step approval process? In this case, I think it would be better to create an `ObjectApproval` type to track all the intricate details, and I could simply query for the `ObjectApproval.Step` (or something similar) to find out the items a specific user needs to approve based on their role Any thoughts on this? Or perhaps design patterns to recommend?


What is the best solution for static memory allocation?

I'm working on image processing and I need to use big Images in a critical system. A good practice for critical systems is to avoid dynamic allocation of memory but what is the design/recommendations for static memory allocation? If we do a static allocation of a big matrix we get stack overflow.               class test     {         public:             test(){};             ~test(){};              private:             float m_bigMatrix[3000000];     };      To solve this problem we can define the matrix as static, but then this matrix will be the same for all the instance of this class.               static float m_bigMatrix[3000000];      The other solution is to have a static object.               static test t;      I've got a solution from another forum where it was suggested that the best approach would be to use a class specific for memory management. All the instances of the class are static and are used by other classes throughout the code. Here is a sloppy version for this solution (it's just an example):               class MemManager     {     public:         MemManager(){ m_counter = 0u; }         ~MemManager(){ printf("Out of MemManager nbr %d\n", m_counter); }              uint16_t getCounter() { return m_counter; }         uint16_t getData(uint32_t pos) { return m_data[pos]; }              void setCounter(uint16_t val) { m_counter = val; }         void setData(uint16_t val, uint32_t pos) { m_data[pos] = val; }          private:         static const uint32_t MEM_SIZE_DATA = 100000000u;         uint16_t m_counter;         uint16_t m_data[MEM_SIZE_DATA];          protected:     };          class MemUser     {     public:         MemUser(){ m_memManager = NULL; }         ~MemUser(){ printf("Out of MemUser\n"); }              void init(MemManager& memManager) { m_memManager = &memManager; };         uint16_t getCounter() { return m_memManager->getCounter(); }         uint16_t getData(uint32_t pos) { return m_memManager->getData(pos); }              void setCounter(uint16_t val) { m_memManager->setCounter(val); }         void setData(uint16_t val, uint32_t pos) { m_memManager->setData(val, pos); }          private:         MemManager *m_memManager;          protected:     };          int main()     {         static MemManager mManager;         mManager.setCounter(1);         {             MemUser mUser;             mUser.init(mManager);             printf("Exit scope\n");         }         for(uint8_t i = 1u; i<5u; i++)         {             static MemManager mManager2;             printf("Note that mManager2 is the same: %d\n", mManager2.getCounter());             mManager2.setCounter(i);         }         printf("Exit process\n");         return 0;     }      So, is this correct? What is the best solution?


When will java change to 64bit addressing and how can we get there faster?

Having to work with large files now, I would like to know when the java libraries will start switching to long for indexing in their methods. From Inputstreams read(byte[] b, int off, int len) - funnily there is long skip(long) also - to MappedByteBuffer to the basic indexing of arrays and lists, everything is adressed as int. Is there an official plan for enhancment of the libraries? Do initiatives exist to pressure oracle into enhancing the libraries, if there is no official plan yet?


Learn a language bottom-up or top-down?

When starting the first project in a new language, you have basically two approaches to learning. Either you do a quick Google search, pull together the most popular frameworks and libraries and work your way from their tutorials towards what you want to achieve (top-down). Or you start with the language basics and the standard library and by and by replace your own simple components with more sophisticated third-party components once you know what you're searching for (bottom-up). Now I'm about to embark on my first serious Javascript project. There's probably as much to know about the language as there is about jQuery, ExtJS and whathaveyou, and I'm trying to decide what to focus on.


Licensing for a web based desktop application?

I have created a desktop application(winfoms) using C#.net 3.5, the application is an SEO application, so it has to be connected to the internet, i implemented a simple licensing routine where every time the application is started it will query the web service on my server with the key and machine hash to validate. But recently i have noticed that some "crackers" have disabled the license verification (simply removed the lines of code that does that) of the application which i have obfuscated, and the sad thing is that they are selling it at a cost that is only 10% of what i am selling for, they didn't even bother to remove my website address and company details from the about box. The application is having an auto-update feature, which they so-called crackers have intentionally left it on in the cracked version I was just trying to figure out a way out of this, i can release an update and disable all the versions that are brought from the crackers, but without a proper licensing it will broken again and the next time, i don't have the guarantee that they will keep the auto update feature on.


How many are too many interfaces on a class?

I would probably consider it a code smell or even an anti-pattern to have a class that implements 23 interfaces. If it is indeed an anti-pattern, what would you call it? Or is it simply just not following the Single responsibility principle?


Can I change operator precedence and associativity in C++?

As the title says, I find it useful to be able to overload operators. Is it possible to also change the way the operators are parsed by specifying the precedence and associativity of overridden operators?


When to use event.initMouseEvent for simulating mouse clicks?

I wonder if there are benign use-cases for simulating mouse clicks using event.initMouseEvent. I found that it is used for creating pop-under ads in the following way:                       var e = document.createEvent('MouseEvents');             e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, true, false, false, true, 0, null);             a.dispatchEvent(e);      This code simulates a click on the opening browser window, to force the newly opened window beneath it. Evil. I'm thinking of simply preventing all simulated clicks in my own browser via a browser extension, but I wonder if I might break useful websites and behavior in the process. Therefore I wonder what situations justify simulating mouse clicks, and if there are big sites that use it in non-evil ways.


Algorithm to analyse and predict

I'm having a set of data's, say               Question,     Question's Main Category,Main Category followers,     Question's Related Categories,Each Related Categories followers,     Whether it got answer in 24hrs [Yes/No]       Now, I need to analyse a database with thousands of sets of data's like given above and predict whether the new given question(with all details like main category,followers...etc) will get answer in 24hrs or not ? I have no idea which algorithm will be more suitable to solve this kind of problem.


How to develop an attitude for abstraction fundamentals?

I know it's mostly a psychological question, but what practices exist for a software developer to improve the _sense_ of **recognizing basic concepts** in the domain and the _habit_ to **define simple reusable expressions** for them instead of duplicating their definitions all over the code? I'm not speaking about hard-to-learn tools for abstraction but trivial, essential ones like constants and functions that every programming language has. For example, if someone has the task of changing multiple string literals in the code by adding a prefix to them, instead of `"FooBar"`, they should write (pseudocode):               def prefix = "Foo"     prefix + "Bar"      Or if there is a domain-specific derived property of a certain type of entity to compute, introduce a function for that which clearly reflects the nature this derived property:               def boolean isRight(Foo foo) = foo.bar.length > 0      The problem is that even more experienced developers sometimes fail to do this due to lots of possible causes (encountering a new programming language, time pressure etc.). Do you know any good, respectful ways to communicate this with fellow colleagues (not students) in order to let this approach become more instinctive?


Overloading Operators - C++

I was experimenting with new overloaded operators, I have created one void operator and another one that returns something when it's called:               #include <iostream>          struct chichachicha{         int operator()(){             return 25;         };     };          struct boomboom{         void operator()() {             std::cout << "Hi folks!" << std::endl;         };     };          int main(){         chichachicha objC;         int f = objC();         std::cout << f << std::endl;         boomboom objB;         objB();         return(0);     }      Is this the best way to write a code that does that? How can I write an operator that can be called from anywhere in the code without instantiating the associated struct, that returns `void`/nothing and only prints a string of text? I'm not considering static methods, just operators.


I'm a manager. How can I improve work relationships and communication with programmers?

A little background first. I'm a project manager at medium-sized company. I started as a CS major and had a little exposure to programming, but after a few months I knew it's not my path, so I switched over to management. That proved to be a good decision, and after graduating I've worked in software management at various companies (for 5 years now). Recently, we had a very painful project. It was the worst of the worst, with many mistakes both on our side and on the customers side and just barely ending it without losses. It has led to many frustrating situations, one of which escalated to the point where one of our senior developers left company after a vocal argument with us (the management). This was a red flag for me: I did something terribly wrong. _(for the record, the argument was about several mistaken time estimates)_ I searched many places for answers and a friend pointed me to this site. There are many questions here about frustrations with management. I can understand that the general bad experiences lead to a general reluctance against "those guys in the suits". I'm that guy in the suit. It may not look like it, but all I want is a successful project, and with limited resources it takes painful decisions. That's my job. One of the things the aforementioned senior developer complained about was work equipment. Frankly, I had no idea that the computers we had were not suited for working. After this, I asked many programmers and the general consensus was that we need better machines. I fixed that since then, but there was obviously a huge communication gap between me and the programmers. Some of the most brilliant developers are the most shy and silent people. I know that, and it was never a problem during an interview. People are different, and have strengths at different areas. The case of the underpowered PCs is just one of the many that led me to thinking that there is a communication issue. How can I improve communication with programmers without being intimidating and repetitive? What I'm hoping is that people don't complain about good things. If you love your workplace and love (or at least _like_ :)) your manager, please tell me about them. What are they doing right? Similarly, if you hate it, please describe in detail why. I'm looking for answers about improving communication because I think that is my problem, but I might be wrong.


Implementing Digitally signed data in a Web Application

I understand PKI well from a conceptual point of view - i.e. private keys/public keys - the math behind them, use of hash & encryption to sign a certificate, Digital Signing of Transactions or Documents etc. I have also worked on projects where openssl C libraries were used with certs for securing communication and authentication. I am also extremely familiar with openssl command line tools. However, I have very little experience with webbased PKI projects & hence I am trying to design and code a personal project for this. ## The requirements (This is a learning project - This is never going to be used in a bank) This is the website for a bank. All Internet Banking users are allowed use any signing certificate issued by a few known CAs (verisign, Thawte, entrust etc). The Bank is not responsible for procuring certificates for the user. The user logs into the bank site with his userid/password etc. He has access to most parts of his account. However, when the user wants to do a transaction - like transferring money to different account - the bank wants him to sign the transaction with a certificate. ## The design When user choses "Transfer" option - the website throws up a form where there are 3 entries - "Transfer To" account, the Amount of the transaction and a way for chosing a cert for doing the digital signing & do the signing. I concatenate the "Transfer To" Account no & the amount plus a nonce and this is the string which will be signed and sent to the backend. I have searched a lot but haven't been able to figure out how to achieve - letting the user chose a cert - do the signing. I know how the user can add certs to his personal truststore on Windows. But how would I ask the browser to show him certs to chose from? How does the signing get done - I really don't want to write crypto code in Javascript!!! So is the alternative having an ActiveX or a Java Applet? Is there a better way? Is there a way to ask the browser to use the cert and do the signing? I have not decided on a platform/framework/language for now - so this question is rather generic. I have searched a lot for this kind of info without luck - all I get is tutorials on digital signing, tutorials on how to enable PKI in Apache etc. If someone feels my whole approach is wrong & there is a better way to do digital signing in a web-app - feel free to suggest those alternatives also.


GUI-Development with QT for OpenGL/C++/MAC

I am a complete newbie considering QT. Would you say it is recommendable to use. I would like to build a GUI for my programm. I need about 10 buttons.(Maybe more) It would also be nice to have a regulator to choose colour like in photoshop. Is it hard to understand if you already have intermediate level in c++ and opengl. Which books would you recommend? Are there many differences between windows and mac, because it seems that there are much more books for windows. What else can you do with QT except for GUI- Development. Thanks in advance...


Watching file changes/additions/removal, but with an eye on partial transfer

I would like to monitor the filesystem in python, so that my application gets warned of the new file addition, file removal, or file change. Once the file is detected, the application starts extracting the contained data through various plugins. The problem is that I am dealing with big files, and when the user starts copying a file from outside into the watched directory, it will be detected, but it will appear as corrupted. Checking for file size between invocations is potentially a good strategy, but it ignores the fact that other generators of the file (such as wget) might have long pauses when the file is not changing in size, and yet is not completed. I don't have control of the file format I am downloading either, so I can't check for an end-of-file mark, because it could not be there. Is there a cross platform way (or different, platform specific ways for linux and windows) to solve this problem? Can I check if a file is currently open somehow? How is this problem solved in other software?


How is switch/case handled as to avoid comparisons to the case values?

I've read in multiple answers that switch/case avoids "unnecessary" comparisons, but I never learned this in college, and I'm a little stumped on how the program would figure out which case to jump to without doing a comparison. Obviously, in the case of `int switchVar=3; switch (switchVar) { case 0: ... case 1: ... case 2: ... case 3: ... case n: ... }`, this would be pretty easy, as it could just create an array of pointers that point to the beginning of each case's code block, and it would simply do something along the lines of `instructionPointer = switchJumpTable[switchVar];`. However, this breaks down if you were to do a switch/case on a string, e.g. `char switchVar[]="North"; instructionPointer = jumpTable[switchVar];` where trying to access the "North" index of an array would cause an error (or if the compiler allowed this behind the scenes, I still don't see how it would avoid comparisons when converting the char array into an integer in order to access the array.) I can think of one way to get around unnecessary comparisons, but it wouldn't be terribly efficient, so I'm sorta curious as to how this is actually done, as I can't imagine that compilers are using the method that I have in mind.


Should we quit trying to do agile if QA takes 12 weeks?

Someone in my company recently proposed changes to our core product that our managers feel should trigger what I guess my company considers a full QA cycle (i.e. testing the entire product suite from the ground up). Apparently our QA takes 12 weeks to do a full QA cycle for our product. My problem with this is that we are trying to do Agile (although mostly half-assed in my opinion) development. We will do a whole set of sprints and then do a release, which QA will take forever to go through I guess. The question is really, if our QA is going to take 12 weeks to do their job, shouldn't we just give up trying to do Agile? What the hell is the point of trying to do Agile in a situation like this?


What is the *correct* term for a program that makes use of multiple hardware processor cores?

I want to say that my program is capable of splitting some work across multiple CPU cores on a single system. What is the simple term for this? It's not multi-threaded, because that doesn't automatically imply that the threads run in parallel. It's not multi-process, because multiprocessing seems to be a property of a computer system, not a program. "capable of parallel operation" seems too wordy, and with all the confusion of terminology, I'm not even sure if it's accurate. So is there a simple term for this? Edit: The parallelization framework used by my program implements parallelism by forking multiple processes and communicating between them. Edit 2: I found the following in Wikipedia's article on Concurrency: "Concurrent programming is usually considered to be more general than parallel programming ..." Based on this, both "concurrent" and "parallel" are apt descriptions of my program, with "parallel" being the more precise one. However, I realize that Wikipedia, like any encyclopedia, is appropriate for getting an overview of a subject, but may not be the best source for resolving such subtleties. So I would appreciate it if someone could cite a more authoritative source demonstrating the difference between these two, or whether there really is a difference.


PDF to doxygen - how to do it?

I have a big pdf with the documentation for a project and I need to render this to doxygen (so take each function from the pdf and write it out into doxygen). Any suggestions on how to do this quickly and effectively (other than doing it by hand)?


Synchronously write file

I am implementing a server in C for a course project. The server should serve more than one client simultaneously. The description of the project states that `fork()` should be used to serve more than one client. Each children should write something to a common file. How do I handle this synchronously? Is there any mechanism like in Java where only one thread can use a function at the same time?


How do you map members and their responsibilities to an organization?

I'm working on a Django project that tracks arts-related activities, and I'm stuck on the human-resources part of things. (code below) I have a class `Ensemble` that subclasses `Organization`. `Organization` only has one important field, `name`. `Ensemble` has another field, `players` (a many to many relationship). A player is a `Performer` which has two foreign key fields, `individual` and `instrument`. The idea is that a performer is any individual on a particular instrument--so, e.g., I can be one individual that can be two performers: one on guitar, the other on bass. The problem is that not all `organization`s are as clean as this. Some `Organization`s will have dancers, for instance (a dance troup), plus any number of generic `Individual`s who do any number of specific tasks not tracked as a specific class (like `Performer`). So at first I was thinking it would be best to just map `Individual`s to the `Organization` through a many to many relationship, create a `Job` class mapping `Individual`s to a `JobCode` class (which might include a row with something like 'performer'), but that doesn't work well if for instance you want to keep track of _which_ instrument a performer plays for that particular ensemble, or if they play multiple instruments, I would like to be able to make that explicit. That's why the `Ensemble::players` relationship made sense to me. So it seems I have an `Organization` class that will never truly be more than abstract, but I still need to be able to track what type of job an `individual` does for an `Organization`. `Ensemble` only makes sense for mapping `Performers` to an `Organization`, but what about `Teacher`s in a `School`? Again, I would like to be able to make it explicit that a bassoon player is teaching bassoon at the school, and not clarinet (even though they might play both). So I can't just map the `Individual` to the `School` organization, right? Also, this seems like it would be a common problem. Is there a conventional way of dealing with these kinds of relationships? What is the most effective? **Code:**               class Individual(models.Model):         surname = models.CharField(max_length=255)         name = models.CharField(max_length=255)         prefix = models.ForeignKey(Prefix, blank=True, null=True)         suffix = models.ManyToManyField(Suffix, blank=True)         date_of_birth = models.DateField(null=True, blank=True)         phone_numbers = models.ManyToManyField(PhoneNumber, blank=True)         addresses = models.ManyToManyField(Address, blank=True)         user = models.OneToOneField(User, blank=True, null=True)          class Performer(models.Model):         individual = models.ForeignKey(Individual)         instrument = models.ForeignKey(Instrument)          class Organization(models.Model):         name = models.CharField(max_length=255)         founded = models.DateField()         tags = TaggableManager(blank=True)         media = models.ManyToManyField(Upload, blank=True)          class Ensemble(Organization):         players = models.ManyToManyField(Performer)


Creating an effective C++ library website and documentation

Creating a C++ library also means documenting it so that others can use it, and that documentation can vary dramatically in quality. **How should a website for a C++ library be structured so that it is most effective?** I would frame "most effective" as being divided among three specific groups of library stakeholders, which should each be able to find and learn what they need to participate in and use the library:   1. New users need an excellent, easy introduction, download, setup, and documentation that clearly flows from one step to the next.   2. Seasoned users need a solid reference with fast access to the details they need, and clear information about new updates.   3. New contributors need a how to guide covering the steps they must take to get their contributions into the library. I would like to figure out how to make each very happy with what they see and use. This question is a bit of a cross between professional programming and user experience. For specific examples, Boost is one of the best collections of libraries, but the initial installation, reference documentation, and figuring out how to contribute can be somewhat confusing. On the other hand, I have found cppreference.com and the SGI STL documentation to be very clear and useful with explanations, links, and examples. While the examples are merely opinions and others may differ, it does help give context to the question I am asking.


What are the alternate models for remote desktop software?

A coworker and I were trying to brainstorm and list the different ways an application developer can write a program enabling a user on one computer to run remotely on another computer while being displayed on their own computer. She suggested all possibilities would fall into only three categories:   * remote desktop software   * hosted service   * appliance I think I understand how an application developer might approach this using the first model (for example, by writing an application that uses a service on the server via a protocol.) I'm unsure how the second model would be different than the first, and I don't understand what the term 'appliance' would mean in this case. What I would like to know is how should an application developer compare these alternatives when designing a strategy for a new application - that will be used remotely?


Use constructor or setter method?

I am working on a UI code where I have an `Action` class, something like this -                   public class MyAction extends Action {           public MyAction() {               setText("My Action Text");               setToolTip("My Action Tool tip");               setImage("Some Image");           }         }      When this Action class was created it was pretty much assumed that the `Action` class won't be customizable (in a sense - its text, tooltip or image will be not be changed anywhere in the code). Of late, now we are in need of changing the action text at some location in code. So I suggested my co-worker to remove the hardcoded action text from the constructor and accept it as an argument, so that everybody is forced to pass the action text. Something like this code below -               public class MyAction extends Action {         public MyAction(String actionText) {             setText(actionText);             setTooltip("My Action tool tip");              setImage("My Image");          }     }      He however thinks that since `setText()` method belongs to base class it can be flexibly used to pass the action text wherever action instance is created. That way, there is no need to change the existing `MyAction` class. So his code would look something like this.               MyAction action = new MyAction(); //this creates action instance with the hardcoded text     action.setText("User required new action text"); //overwrite the existing text.      I am not sure if that is a correct way to deal with problem. I think in above mentioned case user is anyway going to change the text, so why not force him while constructing the action? The only benefit I see with the original code is that user can create Action class without much thinking about setting text.


Which one is better for Offline chat using JMS either RabbitMQ or ActiveMQ?

I have a lot worked on the Java Standard Edition; and now I am new comer on the Java Enterprise Edition. Currently I am working on Offline chat module of Enterprise level Application using Spring MVC. Now I have confused in the selection of RabbitMQ or ActiveMQ?Can any one suggest me which one is better for the offline chat. Thanks In Advance


Should every member of scrum team be universal?

We have a scrum team where there are 5 developers, 2 automated testers, 1 manual tester. Our tasks are completely independent. Shouldn't there be 8 people, every one should be able to do every task: write code, write tests for it, sometimes manually test something?


How do I correctly sub-license a library that is under the MIT license?

How do I correctly sub-license a library that is under the MIT license. I am using and extending the library. The MIT license states that I am free to sub-license the library. Can I simply state:               <Software library> is copyright <original author> and licensed under the MIT license.          <orignal license>          Extensions to <Software library> are copyright <me> and licensed under the GPL license,      or commercial license if applicable.          <GPL, or commercial license>


Participants in Agile retrospective

Who should be the participants in retrospective? Will it be only the team members OR should the Product manager, all the stakeholders and dependent teams also participate. I am of the opinion that only the team should meet to discuss in retrospectives, else all team members will not open up. But one of the managers insist that all the stake holders should also be included.


What is a software prototype?

I understand this site is for programmers, and i have to ask specific coding question. I am doing a software engineering degree and i have been asked to reference at-least 7 books in my definition of prototyping. The best place to ask is here because most of you have probably read books on this and would be able to recommend books to me. I dont mind buying them from Amazon so if you could some books for me that define prototyping or a prototype i would really appreciate it.


confusion between these two networking terms: transmission rate vs. propagation speed

I read this in _TCP/IP PROTOCOL SUITE_ second edition, written by Behrouz A. Forouzan and Sophia Chung Fegan. > In traditional Ethernet, the minimum frame length is 520 bits, the > transmission rate is 10 Mbps, the propagation speed is almost the speed of > light, and the collision domain is almost 2500 meters. So what is **transmission rate** and **propagation speed**? Why they are not the same?


Which language is best for OpenGL?

I have the following list of languages:   * C++   * C#   * VB.Net   * D   * Delphi   * Euphoria   * GLUT   * Java   * Power Basic   * Python   * REALbasic   * Visual Basic I would like to know what people think is the:   1. Best ( _most efficient_ ) language to work with OpenGL?   2. Easiest language to work with OpenGL?


What is the structure of a team developing a computer game?

I wanted to ask if there is a typical structure for a team developing a computer game and, if so, what are the specific roles of the team members. Also, what is the size of such a team (in terms of order of magnitude, 5-10? 10-100? more?). Is there any literature on this topic?


What does XXX mean in a comment?

What do people generally mean whenever you see `XXX` in a comment. Occasionally, I'll see a comment like this:               # XXX - This widget really should frobulate the whatsit      Of course, I can tell what the comment means, but what does the XXX generally mean? Is it saying "This is a hack" or maybe "Perhaps we should revisit this later"? Or is it saying something else entirely?