Database design with "draft" version of data

The database I'm currently building is pretty traditional relational database stuff, but there is one requirement that is not clear to me how model appropriately. There are many business rules which are translated into database consistency checks (i.e. date A must be between date B and C or this field must be not null when another field is a specific value). My problem arises because a user must be able to work on a "draft" version on the data, being allowed to save their changes even if the consistency checks fail. Eventually, a user can commit their draft, but only once all the consistency checks pass. The main reason the client wants this functionality is so that they can query the database directly for reports, and be sure that they are using the most recent version of the data that is "consistent", but not restrict the user from entering partial data. I've played around with storing the changeset to the data in JSON in a document store, and then applying the changeset in code when dealing with the user is dealing with draft data, but this makes it hard to manage things like relationships and the creation/deletion of records. Is there a common way to accomplish this goal? Or does anyone have any suggestions about how I may approach this problem differently?


I've released a software product - how do I maximize exposure given no budget and limited time?

I'd like to reach out to the community on this one. As a software developer, I'm not an expert salesperson or marketing guru - I think in code and not much else. Most developers I come across are like this and also tend to be serious penny-pinchers. Let's say, as a developer, I recently released a new software product that I'm pretty sure will be a hit IF people only knew about it. Assume a budget of $0.00 and limited time each day (i.e. 30 to 60 minutes). What can I do, within those limitations, to maximize exposure? If possible, please back up your reply with at least two working examples.


How to be a good citizen when crawling web sites?

I'm going to be developing some functionality that will crawl various public web sites and process/aggregate the data on them. Nothing sinister like looking for e-mail addresses - in fact it's something that might actually drive additional traffic to their sites. But I digress. Other than honouring `robots.txt`, are there any rules or guidelines, written or unwritten, that I ought to be following in order to (a) avoid appearing malicious and potentially being banned, and (b) not cause any problems for the site owners/webmasters? Some examples I can think of which may or may not matter:   * Number of parallel requests   * Time between requests   * Time between entire crawls   * Avoiding potentially destructive links (don't want to be the Spider of Doom - but who knows if this is even practical) That's really just spit-balling, though; is there any tried-and-tested wisdom out there that's broadly applicable for anybody who intends to write or utilize a spider?


Are my method or variable names too long?

So I was currently in the middle of coding, unfortunately for me, I was in "The Zone" then I thought to myself, are my method/variable names to long? **POP** out of the Zone I go! So I came here to ask, are my method/variable names too long? You be the Judge! Bonus points to anyone who can figure out what I'm writing, although I'm sure a guru will figure it out fast! Anyway, here are some of my method and variable names. Methods : searchBlockedListForBlockedSquares(), isCurrentSquareNextToAtLeastOneBlockedSquare(), searchBlockedListForBlockedSquares() Variables: isNextToBlockedSquares; I Guess there was only one variable that seemed too long.


What is the difference between a floating decimal number and fixed decimal number?

Please explain in layman's terms.


Is a long list of parameter checks an anti-pattern?

Background: I'm working on an application that will manage backup generators. These generators need to be able to be "linked" together. For example, Generator B might serve as a backup for Generator A. If A fails, then the software turns B on. Or they might be linked in a load-sharing configuration, where Generator A and B run together, and share the load. I'm making a function that will make the link, given 2 generators and the type of link desired.               public void LinkGenerators(Generator A, Generator B, Type linkType);      In writing my tests, I've come with a large number of invalid parameter configurations. My `LinkGenerators` function looks like this:               public void LinkGenerators(Generator A, Generator B, Type linkType)     {          if (linkType.BaseType != typeof(Link))          {             throw new ArgumentException("linkType is not a valid link type");          }          if (linkAlreadyExistsFor(A, B))          {             throw new InvalidOperationException("Link for A and B already exists");          }          if (A.Equals(B) || B.Equals(A))          {             throw new InvalidOperationException("A and B cannot be the same generator");          }          if (A == null || B == null || linkType == null)          {             throw new ArgumentException("Cannot pass a null argument");          }          .....          //Actually make the link after making sure all the arguments are valid.     }      Most of the LinkGenerator functions consists of verifying that the parameters are good. The actual link creation takes 2 lines of code. There's a bit of business logic (verifying that link doesn't already exist and that the generators are not the same) mixed in with a bit functional logic (making sure that the linkType derives from `Link`, arguments aren't null...), and makes me.......uncomfortable. Is a long list of parameter checks an anti-pattern or a code smell? And if so, what can one do about it? (Just to make this clear to close-voters probably misunderstanding the question: this is not a question about "coding style for conditions" like this one).


Standardization and official guidelines for C++ template parameter naming

What are some explicit and official guidelines or standards for template parameter naming in C++? I've done something like this in the past:               template<typename TContainer, typename TKey>     void AddKeyToMap(TContainer& the_map, TKey const& the_key);      I've also seen names like `container_t` and `key_t`. I'd also accept advice against standardization here, if it makes sense.


Python syntax highlighting on Codeplex

My .py files in a Codeplex (hg-based) repository don't show up with the nice syntax highlighting as they do for C and C++ when I browse the code on the web. Is there a way to change the syntax highlighting settings in Codeplex?


How can I discourage the use of Access?

Lets pretend that a very large company (revenue numbers with more than 8 figures) is looking to do a refresh on a software system, particularly the dashboard used by employees. This system was originally put together in the early 1990's to handle inventory tracking and storage across a variety of facilities (10+). Since this large company is now in the process of implementing some of these inventory processes with SAP they are in need of a major refresh. The existing system:   * Microsoft Access project performs dashboard duties   * Unique shipping/receiving configurations at different facilities require unique forms and queries within the Access project   * Uses 3rd party libraries referenced by Access to directly interface with at control system (read: motors, conveyors, and counters)   * Individual SQL Server 2000 instances (some traces of pre-update SQL Server 6.0 documents) at each facility The Issue:   * This system started as a home brewed inventory tracking scheme with a single internal sponsor who is still in charge of the technical direction. The original sponsor prescribing the desired deliverables that are being called for in the current RFP.   * The RFP describes a system based around a single Access project.   * Any suggestion that Access is ill suited for a project of this scope are shot down under the reasoning that "it works for the scope now". Are there any case studies, notices, or statements that can be used to disuade this potential customer from repeating their mistake? Does Microsoft make any statements directly about when it is _highly_ recommended to ditch Access? **EDIT:** To answer some of the comments below, the system is getting a rewrite no matter what due to the need to integrate a even greater push towards the deployment of an ERP solution. Problems with the current solution involve additional maintenance of ODBC connections, Office deployments, deploying an Access file to hundreds of workstations, and about 15 years of someone who doesn't know how to program generating enormous amounts of technical debt.


how to move Silverlight app to Html5

I have been working with Silverlight 5 application for a while. I liked this technology and I was captivated to the point to get certified in Silverligt development. However, Html5 gained momentum this point, a new wave of thinking about new applications. Now, i am considering whether to develop in Sl or html5. I have read thousands of post on the subject and can not find clear if there is any way to migrate an application to HTML5 SL, know if there is any tool to help the process?


Project/DLL separation of concerns in ASP.NET MVC

I'm coming from a web forms n-tier background into ASP.NET MVC projects, and I'm wondering what the best practices are for separation of the components of MVC into different libraries (or not to) in the way one might with an n-tier model. Most of the sample apps I have seen only had one project file and objects were separated only by folder. Thanks


Revealing interest in other companies in an interview

I graduate at the end of this year and I've been to a couple of interviews recently.   In almost all of them, i've been asked: "to which other companies have you applied to?" Why is this important to them? What is the best way to answer this question? FYI, I was caught out by this q and my answers involved some kind of lies.


Flat File in a Unit Test

Is it considered bad practice to use a flat file when doing unit tests? If an application reads in flat files and parses them, would this be a better approach than hard coding strings into the unit tests themselves?


Domain integrity check in application

Is it better to check for allowed domain values on the frond end or let the database engine handle the domain integrity. For example If you have a data entry form for employee, is it better to check for allowed values on the data entry form before submitting the data to the database assuming network IO is not a big issue. What if there are lots of checks to be performed, would the engine be faster or would checking the value on the front end take the load of the dB engine?


Is object pooling a deprecated technique?

I am very familiar with the concept of object pooling and I always try to use it as much as possible. Additionally I always thought that object pooling is the standard norm as I have observed that Java itself as well as the other frameworks use pooling as much as possible. Recently though I read something that was completely new (and counter- intuitive?) to me. That pooling actually makes program performance worse especially in concurrent applications, and it is advisable to instantiate `new` objects instead, since in newer JVMs, instantiation of an object is really fast. I read this in the book: `Java Concurrency in Practice` Now I am starting to think if I am missunderstanding something here since the first part of the book adviced to use `Executors` that reuse `Thread`s instead of creating new instances. So has object pooling become deprecated nowadays?


Adapter Pattern to expose different aspects of an object -- Is this a correct use?

Quite frequently, I use an Adapter-like design to expose different aspects of data objects. For example, in a 3D modelling application I use an object hierarchy to represent the 3d models in the scene. This hierarchy contains lots of internal information and is quite complex to traverse. For exporting the 3D model data to different file formats (which involves quite significant transformation and omitting or converting some objects), I have a separate class called ModelAdapter. It extracts the important information of a 3D model and provides them in a different format, usable for export. The export plugins, in turn, read the data from the ModelAdapters and have nothing to do with the internal scene data structure. For Example:               class 3DModelAdapter     {     private 3DModel internal_model;     public List GetTriangles()     {      internal_model.Do_Some_Complex_Thing_To_Retrieve_The_Triangles();     }     ...     }      ` Is this a valid use of the Adapter pattern? Is there a better way to accomplish the same thing?


CakePHP - Element Overkill

While implementing a flash game portal I decided to "component-ize" my views. The repeating elements were a no brainer and the templates for these were placed in elements. I pass through data from the controller to the element via the view using the Html helper. This is all working fine, and except for a very minor subset of elements, I haven't had too many issues with complicated logic in the view in order to massage parameters - in other words they have all been completely pass-through and therefore very transparent to the elements. Here-in lies my problem. I realize I have over 20 elements which far eclipses my paltry 8-10 views and 3 controllers. I've also had the urge to turn almost everything into a "component" and convert it into an element. For example, I have a rating control that is used on only one page - the game play page - and I recently contemplated converting it to an element. I'm wondering if I've gone overboard at this point. So, in summary, my question boils down to what are the best practices when using the CakePHP Html helper and what makes a chunk of html a candidate for an element (aside from the the obvious of only writing it once). I've read the cakePHP manual and it gives "rough" guidelines but I'm looking for some "field level" or real world experience to guild my decisions. TIA


How to encourage version control adoption

I have recently started working in a team where there is no version control. Most of the team members are not used to any kind of version control. I've been using mercurial privately to track my work. I would like to encourage others to adopt it, and at the very least start to version their code as they develop changes. Can anyone give me advice on how I can encourage adoption of a distributed version control such as mercurial. Any advice on how to win people including managers to DVCS would be much appreciated.


Is it beneficial to read old Java programming books?

Many of my Java books are 5 - 10 years old. Does it still help to read them, or should I use something within 2 years.


What is a better word for aligning your nesting?

I was taught by an old-time programmer who called this nested code               if(condition){
         text text

              a	              b

     } else {       log();     }      as opposed to this code which was considered to be not nested               if(condition){
     text         text

a	b

     } else {log();}      When I started reading tutorials I found early on that I had the wrong definition to nested. Messy vs clean is not sufficient for this because messy code encompasses other problems that I am not talking about, for example confusing flow of logic, using static initializers inappropriately, poor use of variable names, using twice the code to get the job done in a more confusing manner, etc. What is the right word for this, where the first example is ... and the second example is not ...?


What features should the next systems language come with?

It seems like we still resort to C or C++ when we are going to do "serious" systems programming. We have some small languages which try to come up with new stuff inside systems programming such as Go and D (I have had a little experience with D and I like it a lot so far), but those aren't very widely used (Go is from 2009, so it shouldn't be that surprising but D is from 2001). There are non-language-technical reasons why these aren't so popular, such as there aren't many jobs, frameworks etc., but exclude such things and instead focus on what features should the next generation systems programming language come with? What do you, as a systems developer, lack in the "traditional systems programming languages" (that is C, C++ etc.)? Why do these things matter now in today's world (concurrency etc. would matter, I guess)?


Which timezone is used for permalinks of posts

I wanted to add timezone support to my blog app but got stuck with a design problem. Every post has a published_on field which stores the publication date in a timezone aware format (UTC converted to user's timezone). So far so good. But the permalink of a post is created from the publication date as well. It has the format: /year/month/day/slug. This of course is **not** timezone aware and must be the same for all users around the world. So I have to define a timezone to use for the **permalink**. There are three options which make sense:   * The author's timezone   * UTC   * The default timezone of the server. Which would be the most appropriate?


How should UI layer pass user input to BL layer?

I'm building an n-tier application, I have UI, BL, DAL & Entities (built from POCO) projects. (All projects have a reference to the Entities). My question is - how should I pass user input from the UI to the BL, as a bunch of strings passed to the BL method and the BL will build the object from the parameters, or should I build the objects inside the UI submit_function and send objects as parameters? EDIT: I wrote `n-tier application`, but what I actually meant was just layers.


What makes Python more used as an implementation language than the others?

Perl and Python are often compared to each other (let's not forget Ruby), and almost always those discussions will come to the conclusion pretty much anything you can do in one or the other. Without going into that, I've noticed that Python however, is often used as an implementation language (uhmm, maybe the term here is incorrect technically - a language you use to, for example, enable some degree of scripting in a large application ... Tecplot, Rhinoceros etc.; these are from the scientific area; there are others surely) and Perl never (well, to my knowledge at least). So I was wondering - what makes Python more suitable for something like that? What particulars make a language more suitable to be implemented as part of a larger app. for scripting in general? Is it only that that wasn't so common 10 years ago (scripting in applications), and Python is just at its peak at the moment, ... or something else?


as a team: multiple projects vs single project?

I've been wondering for a while. I guess I have been adapting to the circumstances but I am in desperate need of some clearly defined workflows. Ok, so say I am working with one other person and I have 2 projects come up both of equally large size with LOOSE deadlines. What should I do: > a) turn down one, work on other exclusively > > b) take both on and develop both simultaneously > > c) assign one person to each project I have done c in the past which works fine. As a manager also, I've simply had to manage that project while I work on another. No big deal. But what is the ideal option above? I'd hate to do a because I am turning down work either though deadline would permit working on both projects. Any input? Following things should be taken into account: > -) all members have same expertise in design & development and can > effectively function as freelancers > > -) timezones may not be the same so they would not be working at the same > time


Web Development: is always Typing necessary or can type on demand work?

I realize this idea might seem really foreign but I started thinking about this a bit back. Far as web sites go, at least in my experience, there is far more time spent retyping things to a String than the other way around. For instance: Say you have a user model:               user        int UserId      And I wanted to log the user in:               View  -> string to int -> controller -> int to dbInt -> database -> dbint to int -> controller -> int to string -> View      At no point in that whole exchange did I need an int. The one typing I did need was with the database, but that's just kind of expected. Now if I wanted to show a list of users based on a group id, the same thing happens except that UserId conversion happens for how many there are on the list and in the end it will just be represented as a string in the UI. Now I understand that a string might be larger memory wise than some types (bool for example) but is this more costly than all the typing that happens? Could it be more productive to only type when needed (Validating a number, date, ect) and just leave them as strings for the most part?


How big should OSGi bundles be?

Or more completely "What are the trade-offs and questions that should be raised when trying to decide the bundle structure of an OSGi application?" Our existing OSGi bundles have tended to be quite fat: basically an API bundle and an implementation bundle, but with a lot of functionality. That has advantages in terms of project and build complexity, but maybe doesn't give us all the reusability and flexibility we desire. So in a recent project, we intentionally made quite thin bundles. We did a walkthrough this AM and we wondered if we'd gone too far. In this quite-small service we had 7 bundles, several of which only had 1 domain class. The question raised was "This is almost like we're driving towards a bundle per package. But we _have_ classes and packages already in the language, are we going too far with our bundle granularity?" To make it concrete, this is a Web Service that performs a calculation on the aggregate results of other Web queries (specifically, we query a bunch of astronomical databases for objects in a given area and then we filter the results based on our own criteria and then we estimate a probability of an adequate observation based on the filtered results). We ended up with 7 bundles, which seems like a lot for what is essentially "a servlet that performs a calculation." Is such very-fine granularity good (lots of flexibility at runtime) or bad (overly complicated)? How can we develop our intuition about the "just right" granularity of our OSGi bundles?


What is OpenCL?

I've been looking around, but I'm still not sure on the what OpenCL is. Other than multi processor stuff... Is it another graphics API like OpenGL and DirectX? Or something that works alongside OpenGL? I'm planning on learning OpenGL soon (with java if it makes a difference) so I want to know how/which direction to learn it with. Also, I hear things about CUDA which confuses me further. Just looking for some simple clarifying statements. Thanks.


Is Python's C interface faster than JNI?

I was reading What makes JNI calls slow? and I was wondering if Python's C interface is any better than JNI. I heard that if you want to make certain parts of your python programs faster, or if a certain part of the program was really hurting your program's performance, you write them in C, and make Python call them. Does the C interface it incur the same costs JNI does? why or why not?


What can / should be done with regular expressions?

I've recently learnt regular expressions and I love writing / using them. I'm looking for ideas and more opportunities to use them, however I don't want to overuse them as an all purpose tool, as often warned by people. What kind of things should I use regular expressions for, and where should I not use them? (Apart from the obvious: HTML parsing).


Pattern for user interaction and confirmation

Suppose a FileWriter class that needs validation that it will not erase a file already present, if one is found. It would have two functions:               public bool FileExists(string filePath) //...     public bool WriteFile(string filePath, string text) //...      The main concern is to not erase a file already present. A first interface is actually just interaction via a console:               public void Save()     {         FileWriter fileWriter;         //...         if (fileWriter.FileExists(filePath))         {             Console.WriteLine("File already exists. Continue? Press 'y' for yes");             if (Console.ReadKey().KeyChar != 'y')                 return;         }         fileWriter.WriteFile(filePath, text);     }      And some time later comes a second interface, this one with a GUI, that needs the same user interaction:               public void SaveButton_click(object sender, EventArgs e)     {         FileWriter fileWriter;         //...         if (fileWriter.FileExists(filePath))         {             if (DialogResult.Yes != MessageBox.Show("File already exists. Continue?", "", MessageBoxButtons.YesNo))                 return;         }         fileWriter.WriteFile(filePath, text);     }      Save for the way the interaction is made, the logic is the same. What pattern can be used to not duplicate this logic? Is a callback function to perform the check the best approach? Formatted as C#, but doesn't have to be C# specific.


Protected variable & protected method in the era of TDD

I understand protected method is good for unit testing since you can easily mock by the class by overriding the protected method for the sake of testing. However, protected variable is just a global variable (although limited) and should be avoided at all. Especially if you've all the essential getter/setter declared, you should have zero protected variable and it should not affect anything else. So, in the future, if I am going to elimiate all protected variables in my codes, are there any caveat that I am not aware of?


What is your approach to debugging a transient problem

I am working on a system that controls a label printer and occasionally the label printer will print the same label 2,3,...,10 times. The error is transient, occurring once per 3000-4000 (once a month) or so labels. I am adding tracing to a log file to see what commands are being sent to the printer and state of the printer (we have a state machine defining allowable commands). But since this is a transient problem that may tell me that we had an error, but not why we had the error so I can fix the problem. I am also trying to get the print job files for the errant jobs so that I can emulate the job in my test environment. Hopefully with these I can reliably make the error occur I am curious how other might approach diagnosing this type of transient error.


Sporadic unittests or TDD?

I've read some basics about unit tests and TDD, but I find it hard to convince myself why TDD can have an advantage over only selected unittests. I've read common arguments for TDD, but don't see the improvment compared to simple unittests. Maybe you can help to clarify:   * TDD allows a loosely coupled, testable design -> I believe I can well imagine if a class is theoretically testable, without having to write tests; Loose coupling is a fundamental requirement that one can judge without refering to TDD?!   * TDD gives confidence in refactoring -> Isn't it more efficient to add selected unittests as soon as you start refactoring? While you have to think what to cover by test, you still save writing a lot of tests.   * TDD makes you define the interface first -> To me it seems some minor points are easier to decide while coding (which also agrees with agile?). It's even hard to predict a nested return data structure, but after coding I can often validate that I get what I expected. I made up the nested data while coding (a small unit) and see the behaviour. I'd save a lot of time writing the method first and using the validated result a posteriori to plug into a unittest.   * from what I've read many (of course not all) sources state that TDD does require more development time even considering the benefit for debugging; merely the code quality improves -> Can it be that some programmers make different kinds of mistakes and for some TDD doesn't cover the type of mistakes they make anyway? So if my typical bugs are not approachable by predictable tests, it's not for me?   * TDD aids changing teams, and larger interacting teams -> Is this a large issue? I can imagine it is, however as for the moment I program alone I cannot judge. How does TDD help teams in ways that... and here is the important point: other ways don't? It can force some discipline for less experienced team members, but apart from that any advantages?


Testing website content with graphs

I'm looking for a way to test my webpages that have dynamically generated graphs (using such things like Google Graphs). Does anyone know if there are such tools that exist (perhaps Selenium would do this). Thanks


What are some really tough programming books?

I was wondering what are some really tough books on programming that would make me think. I'm talking about low level languages such as c etc and algorithms, points, functions etc. Thanks ALot.


How to represent association in programs

Could someone help me in implementing association in cpp. I am trying to implement a dice game where I have two classes a diegame and a dice.


How to define template directives (from an API perspective)?

## Preface I'm writing a template language (don't bother trying to talk me out of it), and in it, there are two kinds of user-extensible nodes. TemplateTags and TemplateDirectives. A TemplateTag closely relates to an HTML tag -- it might look something like               div(class="green") { "content" }      And it'll be rendered as
content
      i.e., it takes a bunch of attributes, plus some content, and spits out some HTML. TemplateDirectives are a little more complicated. They can be things like `for` loops, `ifs`, `includes`, and other such things. They _look_ a lot like a TemplateTag, but they need to be processed differently. For example,               @for($i in $items) {        div(class="green") { $i }     }      Would loop over `$items` and output the content with the variable `$i` substituted in each time. So.... I'm trying to decide on a way to define these directives now. ## Template Tags The TemplateTags are pretty easy to write. They look something like this:               [TemplateTag]     static string div(string content = null, object attrs = null)     {         return HtmlTag("div", content, attrs);     }      Where `content` gets the stuff between the curly braces (pre-rendered if there are variables in it and such), and `attrs` is either a `Dictionary<string,object>` of attributes, or an anonymous type used like a dictionary. It just returns the HTML which gets plunked into its place. Simple! You can write tags in basically 1 line. ## Template Directives The way I've defined them now looks like this:               [TemplateDirective]     static string @for(string @params, string content)     {         var tokens = Regex.Split(@params, @"\sin\s").Select(s => s.Trim()).ToArray();         string itemName = tokens[0].Substring(1);         string enumName = tokens[1].Substring(1);         var enumerable = data[enumName] as IEnumerable;         var sb = new StringBuilder();         var template = new Template(content);         foreach (var item in enumerable)         {             var templateVars = new Dictionary<string, object>(data) { { itemName, item } };             sb.Append(template.Render(templateVars));         }         return sb.ToString();     }      (Working example). Basically, the stuff between the `(` and `)` is _not_ split into arguments automatically (like the template tags do), and the `content` isn't pre-rendered either. The reason it isn't pre-rendered is because you might want to add or remove some template variables or something first. In this case, we add the `$i` variable to the template variables,               var templateVars = new Dictionary<string, object>(data) { { itemName, item } };      And _then_ render the content manually,               sb.Append(template.Render(templateVars));      ## Question I'm wondering if this is the best approach to defining custom Template Directives. I want to make it as easy as possible. What if the user doesn't know how to render templates, or doesn't know that he's supposed to? Maybe I should pass in a `Template` instance pre-filled with the `content` instead? Or maybe only let him tamper w/ the template variables, and then automatically render the content at the end? OTOH, for things like "if" if the condition fails, then the template wouldn't need to be rendered at all. So there's a lot of flexibility I need to allow in here. Thoughts?


How does google code prettify works?

I am using google code prettify. After a page renders, I decided to check how `<code>` and `<pre>` tags and their contents were manipulated.   But in view source, I found no changes were made (in contrast to online syntax highlighters, which generate css style code with code text).   So, how/where is info about keywords, variable, comments, etc (from code tag text) stored and manipulated?


How about multiple bits performance in common databases?

If there are 20 bit columns (non-null boolean), is it better to explicitly hold them in an integer type (int32)? Or, will the underlying database merge them in a single integer? I'm using PostgreSQL, though. Generally, is using bit-mask in SQL databases kind of anti-pattern? Backgrounds: The usage of these bit columns are left to be defined by the end user, along with a few of other int, float, double, varchar columns, so as to make the table a little more extensible. I'm also not going to use one-to-many custom property table in practice. Add an integer column is cheap, but if the underlying database could store several bit columns in one int32 field, I don't have to explicit merge them myself.


Logic in setters vs. getters?

Okey dokey, next crappy-code-at-work-rant-turned-into-a-real-question (I hope): So, I'm debugging some code, and we've got something like this:               objFoo.TabIndex = 5   'VB.NET property with setter implicitly called      and TabIndex is a property whose setter is the beginning of an _insane_ call tree, with subroutines and XML and special cases depending on context (like: modes), and so on. (Gack. You can see what working here is doing to me. I just prefixed Foo with "obj". :( ) Ok, granted, we need to manage state and perform computations and whatnot. Our state is either in the database (but may be expensive to pull out) or it's not yet ready to be committed to the database (e.g., it's only half-baked), so we can't just run out to the d/b every time we need some info, but... Is it better to manage this state in setters or is it better to do it in getters? I would think doing it in getters (i.e., lazily) would mean we would compute (and, presumably, cache) only what we need, while doing it in setters means we're essentially overcomputing, anticipating what getters may be called in the future and precomputing their results. (And then, there are the data members that don't have getters at all, they're just global variables in a 6,000-line class.) Shouldn't we just, as a general rule, set the indicated data member, maybe set some flags indicating other data is now invalid (cache invalidation) and wait for the various getters to be called to recompute? I can imagine one argument for doing this in setters is that our object is so complex that we really need to configure its state properly, using multiple complex data members. But isn't that a red flag in itself, indicating that a better approach would be to break the object up into smaller objects, not write a complex setter? (Now, I know there are all sorts of exceptions which people will no doubt point out, but I'm looking for a general rule of thumb and the logic behind it, or the statement that no such general rule of thumb is possible, accompanied by a convincing argument.) Thanks. John.


How to unit test image processing code?

I'm working in image processing (mainly OCR) and I wonder how I should integrate unit tests in my development. I'm already using unit tests for more "common" type of code but when dealing with image processing code I'm not sure how to deal with it. This kind of code always need some image data input/output and mocking this is not obvious. For now I'm mostly doing integration tests but they take a while to run and I would like some ideas on how to break down this kind of code into unit tests so that I can run them more quickly. Edit: Analyzing a character can go through many steps involving multiple rotation, scaling and morphological operations. These steps change often as the algorithm is being developed. Thus the input and expected output can evolve a lot while testing. Each character can be 100x100 pixels so hardcoding them in the code or working with generated data is out of question.


timers with threads on queue

So I've been asking the wrong questions for the last three days and after searching a lot I think I have an idea of what I need, my question is how to use timers with two threads writing and reading on one queue. In other words, I have one queue(or any other data structure) and two threads, producer and consumer, so the producer write values on the queue, with a time for each value(let's say 10 seconds) and the consumer read the queue, both are using lock mechanism, what I need is a timer function that check which value has passed the 10 seconds and remove it from the queue. I know how to implement the producer/consumer threads, but I don't know where to put this, is it a third thread or what? and do I need to write the time of the value when entered the queue, so the timer function can check it, or just write 10 and the timer function will decrement 1 each second?


Atmosphere + Long Polling : No message distribution?

I'm experiencing a strange behavior with Atmosphere + Long Polling. I'd like to have a broadcaster per user, so I have registered a broadcaster on resource suspension with id : /user/. I use Atmosphere on a clustered environnement, so I have configured to use an external broadcaster that use Hazelcast. (No chance for Redis, corporate rigidity). Everything seems to work, BUT all broadcasted messages never reach the browser.               Future<Object> f = BroadcasterFactory.getDefault().lookup("/user/foo").broadcast("my lovely message");     f.get()      I can see my pending request on each browser (Chrome/ Firefox), but no resume, and no response until the socket timeout to renew the connection. My environment :   * Servlet 3.0   * JBoss AS7 7.20   * Spring 3.2 + MeteorServlet   * Atmosphere 1.1.0RC1 (same with the most stable version) + jQuery Atmosphere


I can write code... but can't design well. Any suggestions?

I feel that I am good at writing code in bits and pieces, but my designs really suck. The question is, how do I improve my designs - and in turn become a better designer? I think schools and colleges do a good job of teaching people how to become good at mathematical problem solving, but let's admit the fact that most applications created at school are generally around 1000 - 2000 lines long, which means that it is mostly an academic exercise which doesn't reflect the complexity of real world software - on the order of a few hundred thousand to millions of lines of code. This is where I believe that even projects like topcoder / project euler also won't be of much help, they might sharpen your mathematical problem solving ability - but you might become an academic programmer; someone who is more interested in the nice, clean stuff, who is utterly un-interested in the day to day mundane and hairy stuff that most application programmers deal with. So my question is how do I improve my design skills? That is, the ability to design small/medium scale applications that will go into a few thousand of lines of code? How can I learn design skills that will help me build a better html editor kit, or some graphics program like gimp?


Java - What methods to put in an interface and what to keep out

I'm designing a file handler interface:               public interface FileHandler     {         public void openFileHandler(String fileName);         public void closeFileHandler();              public String readLine();         public String [] parseLine(String line);         public String [] checkLine(String line[]);              public void incrementLineCount();         public void incrementLineSuccessCount();         public void incrementLineErrorCount();              public int getLineCount();         public int getLineSuccessCount();         public int getLineErrorCount();          }      It is soon apparent to me that these methods **can't be made private**. I don't want incrementLineCount to be public. What is proper way to design an interface like this?


Handling a sms pull request from spring controlller

I am using spring xml mapping and I have to handle a request that is coming from sms gateway and I want to send the response as SMS. My scenario is like   1. user sends sms from mobile in the format `code subcode XXXXX`.   2. sms gateway will generate a request and send to my registered url using the format `url??mobileNumber=99999999&timeStamp=2014-01-06 16:10:20&operatorName=&areaCode=&message=code subcode xxxxxxx` I want to handle this request from my spring controller. Right now what I did was I created a controller and handle it from reference data. Any other better solutions?


Junior developers in a remote working environment

Our company is looking to introduce remote working as an option for its developers. This book (Remote: Office not required) has been offering some valuable guidance. However one issue that is not addressed is the employment and management of junior level developers. In a remote working environment, how do you ensure that junior developers receive the same standard of guidance and experience that they would gain from being around more senior developers in an office environment?


How to sell my work?

I'm a freelancer, a company I'm working with (which has a government as customer) asked me to write an app (web-based and/or system) to allow them archiving documents, and making them downloadable by given users/groups. I'm planning to make it with APIs, and to make a light web interface and a cross-platform desktop app. My question is: How much can I sell it? Based on time developing? A very light, free and nude app (same as dropbox), then make them pay for each functionality (users/groups/ssl/resume downloads/desktop app...)? Or make a global price, based on approximate cost, based on I don't know what ? It's my first closed source project.


Is it a bad idea to sync file system with remote server using HTTP?

I have started a project which will duplicate Dropbox or Google Drive behavior but using Amazon S3 az a backend. Idea is very simple, a Node.js server that watchs a directory for file changes and PUT them on the S3. Or it will look at S3 for changes and applies them to file system structure. I'be uploaded very early version of my app to Github. You can find it here. Because I am a web developer, I am using web technologies to solve the problem. I'm afraid of my limited mindset and picking wrong tools for the job. There are other solutions to this problem. One is S3FS which is a FUSE file system for Unix systems. In my opinion that is very hard to use and limited to platform. My solution uses Node.js to overcome cross-platform issues. I can pack my Node.js app with App.js and make it an easy to use software. To clarify, my questions are:   * Is HTTP/HTTPS good enough for file transfer?   * Is Node.js good enough for working with File System?   * Scalability: can this approach fail in large file sizes?


Should a programmer know Linux?

I'm a PHP/Python programmer learning Java and C#(.NET). My main OS is windows 7 but I've used Linux and currently dual-booting with Ubuntu. My Linux knowledge however, is pretty limited. I can work with the command line on simple tasks but that's pretty much it. I don't do any shell scripting, don't know very well the most important commands, nor the system in general. My interests are web development, mobile apps and maybe some embedded stuff in the future. Should I get myself familiarized more with Linux ? Even if at the moment I'm not that interested in it? Is it a must for future job positions considering my field of interest? Thank you.


How to learn UML for a design usage?

10 years ago at college I had some UML lectures. From these I remember and use only some basic part of class and sequence diagrams and how our teacher was trying to convince us that in the future, we won't be coding but we will be using (bloated at the time) UML tools to generate software ! What a laugh ! Today I think I can have a better use of UML than only reverse engineering my code to have some nice diagrams to illustrate a documentation. I feel than I can use it to design some part of my code and avoid late problems. But each time I want to really use UML to design something I get lost: too much diagrams, too much obscure jargon, too much text field and options in UML editor with dark meanings... So I want to know how do you have learn UML in order to know enough to use it in design phase without being drawn by its complexity. Note:   I already have this book: UML Distilled: A Brief Guide to the Standard Object Modeling Language from M. Fowler. What I miss is more a practical approach with one or many real world examples of how to model a real project using UML.


Host Matching Interview Tips?

So I've gotten past the technical interviews for a company, and now I'm having an interview with my potential host for an internship during the summer. What are some tips for interviews like these? I know they're not really technical, but I'm not sure what exactly they are meant to gauge. Any tips on what to say, how to show my interest in the project, questions I should ask, etc.? * * * Edit: Side question: What's a good synonym for the word "interesting" or "interested"? I find that I use those words a bit too often (e.g. "I'm definitely interested in working on the front-end!" or "Yeah, that sounds really interesting, I would love learning more about it." or "Those all sound really interesting, I'm definitely interested in all of them!", etc.)... but I can't seem to find any good synonyms. (Online sites don't really give me good synonyms.) Any ideas?


Can agile be effectively used for initial development on a substantial project?

I think the short answer to this question is probably "yes", but I thought I'd ask anyway! We are in the process of taking **a number of existing similar-but-different applications** and, as part of what is for us possibly the largest development project ever, attempting to **replace them and any subsequent similar-but- different applications with one over-arching super configurable system** to rule them all. I fully expect Difficult Second System Syndrome to give us plenty of problems delivering the behemoth in the first place, but I don't want our choice of methodology to make it all worse. We've dabbled in agile, from something mostly waterfall, but this would be our first substantial project using some new improved methodology. We have Big Plans for the new system, and while it doesn't all have to be delivered at once **we will need to implement large chunks of it from the word go to allow anything to be given to the customer that they would even understand**. My concern is that, since we're dramatically changing so much at once, there is little scope for small chunks of work that lead to useful/demoable deliverables. I'm worried that, even if we did manage to find a way to do it in small chunks, we'd need those chunks to fit well into a bigger picture, and so would find it hard to develop them in isolation for that reason too. We're aiming for quite a decoupled SOA approach, which is something. **Timescales are tight** , and reputations have been staked on delivering on time. So I'd like to know if, in this case:   * it is advisable to do loads of up-front design, put together the overall shape of the app and get the crucial modules working in one big push (which might be sprintable in terms of keeping track of work, but not so much in terms of feedback and improving design and so on), before maybe going more agile from then on, or...   * try to be as agile as possible from the start - agree things like coding standards, maybe some API basics, general module splits, and then trust to independent coding while bearing flexibility in mind to let the other stuff gradually flesh out; maybe some stuff has to be reworked, but anything that can be better steered during development rather than up-front will benefit, or...   * maybe something else, and...   * any general tips?


Should code from an incomplete story be removed from the build?

During the sprint review the product owner may say that a particular story is incomplete or the team itself may not have completed some committed tasks. In what situations do you leave the code in the build? If the code is left in the build, is this a conscious decision made during the review? In other words, do you discuss this issue during the review? Are there specific instances where code should be removed?


Writing Software

A couple of weeks I got my first Java assignment in my first career job and my partner and I are working through the requirements. I'm mostly shadowing him and learning (awesome!) and it's been great to see how he works. One thing that I noticed that I never even thought of was how to build an application from the ground up. I mean I understand the software life cycle and all, but actually implementing in the real world was very much so different that I imagined. As an example, we have a requirement where one object has many objects and I had no clue how to implement that and he was like (with his 20 years experience), "Oh that's just an ArrayList<> of objects within this class. How can I get like that? Is it just an experience thing or are there good reference books on how to WRITE good code? I mean, I understand the basics of programming, but putting together an entire app just baffles me. Can someone please advise me on how to proceed? I hope this makes sense...


Why must we learn Procedural programming before we learn Object-oriented programming

I'm in the 4th year at an IT university now, and when I talk with my professor about this topic he rejects my opinion and gives me a very heavy criticism (in my university, we were being taught C (ANSI) (in Procedural Programming class - in the 1st year at university ) before C++ (in OOP class in the 2nd year) and others... But at age 13 my brother was taught, by me, Java first and nothing else. Now, he can do almost everything which a normal 2nd-year-student can do with Java. To you pros, I'd like to know why you think we should be taught procedural programming first.


What language/framework/workflow sets do you recomend for a small office?

I work in a small office (only 1 designer, me and plus 1 programmer). We have a solid background in classic ASP development and some sort of a small proprietary framework/cms based on ASP + MySQL + Javascript written line by line in here and the projects aren't so big until now and we want to step up with something more fast and secure way to develop without reinventing the wheel (again). I have a little knowledge in PHP and .Net (C#) from some particular projects and personal learning. We have researched various languages and frameworks, as well as some new (to us) methodologies like TDD and some version control oriented workflows with GIT, etc. Until now we have thought in PHP with some framework like CodeIgniter or Kohana and ASP.net (C#) with MVC 3, since I can start from some knowledge I already have and maybe adopting GIT as our version control system for the bigger projects. We need some advice in getting a new set of skills and tools that work the best for us before getting 1 by 1 and trying. **EDIT: What we need to change(maybe)**   As you can imagine, we don't have a testing process like TDD or BDD and the testing is done very breafly (We have luck with so little problems after release) nor a real idea of how to use it (need more study and clarification). We use Dreamweaver most of the time to code and need a more fast and robust development environment with an autocomplete feature like MS Intelisense and nice highlighting (I personally like to write code and have used the notepad to write almost all of my first apps, but in a profitable work with a short deadline we can't go this way. Not that Dreamweaver is bad, but it's too general and lacks some features). I know that security is a thing to see at the programmer side, but there's plenty of frameworks with features that helps in this case and now we have a very basic and limited set of tools written by us to do this (poor SQL injection protection, etc). Our "version control" is purely based on a network share and our machines. The final version is always the one in our file server and most of the time, when we have to make some changes, we change the files directly and upload them again. A backup of this share is made each 2 or 3 months. We are growing up and expect to hire someone soon. Its hard to find a VBScript programmer for ASP and when we find one, the salary is to high for us by now because nobody is learning it in this days and who knows already have a job with a good one. **Final concerns:** We've decided to use ASP.Net(C#)/MVC as our primary framework and use CodeIgniter as an alternative to linux servers and other projects. Thinking in joining some MS program for startups and small business to help with some costs. We're getting Git as our vcs in our private file server for the origin and instances in each develop machine for us to clone, work and push back. We also considering a service like Bitbucket to maintain a copy on the cloud. If some of you have any more advice or other thoughts about this I'll follow- up. I would like to thank you all and mark many of the answers as right but I can't. I think this question may be a base of reference for small offices like us to get some points and help on the same decisions.


Name of my software similar to name of an other program

I am going to write some software. I'd like to call my software X-former (from XML + transformer). But there is already Xformer emulator. (My software is not related to emulators.) Taking this into account, is calling my software X-former: a. legal; b. ethical?


Is there a way to avoid type-checking in this scenario?

I have a class `SuperClass` with two subclasses `SubClassA` and `SubClassB`. I have a method in a different class which takes a `SuperClass` parameter. The method should do different things depending on the type of the object it receives. To illustrate:               public void doStuff(SuperClass object){         // if the object is of type SubClassA, do something.         // if it's of type SubClassB, do something else.     }      I want to avoid type-checking (i.e. `instanceof`) because it doesn't feel like proper OO design. But I can't figure out how to employ Polymorphism to elegantly solve this problem. How can I solve this problem elegantly?


Algorithm to match items be value into sets base on total

Given n sets of items. Each item has a value. The items in a set have similar values but vary by a small amount. The goal is to create new sets containing three items selected from the original sets such that the total of the values is within a given range. Only one item a source set can be selected. For example: If we have the following starting sets:   * Set A - { 4.0, 3.8, 4.2 }   * Set B - { 7.0, 6.8, 7.2 }   * Set C - { 1.0, 0.9, 1.1 }   * Set D - { 6.5, 6.4, 6.6 }   * Set E - { 2.5, 2.4, 2.6 } Goal is to create sets containing three elements such that the total is between 11.9 and 12.1.     * For example { 3.8, 7.2, 1.0 }   There can be unused elements. Can someone suggest an algorithm for this problem?


Over normalization in database

Currently I am working on creating a new database schema as part of a major new product. Our previous customer address records (in a previous product) look something like this in our current schema (not all columns shown):               AddressID, AddressLine1, AddressLine2, City, State. Zip, Country, Etc.      I want to normalize this so that an address actually breaks down to:   * 1 address to many address lines    * 1 address to a zip/postal code So, I sent out a communication saying that zip code will now be in its own table and that each "address" corresponds to one zip/postal code. Also addresses would be broken out so that we could support more than 2 address lines with a 1 to many relationship. Some people in my group are now saying that I am over normalizing the database. Am I? Note, I am not a DBA but I feel that this is more logical and more efficient than the previous schema. **UPDATE** Thx to everyone for thier input. I'm not going to break out the address or zips to thier own tables. My original plan was to have a zip code lookup and re-use for the addresses so I would only have to have one set of zips, but I'll just drop everything on the record itself, and have a separate table for zip lookups.


MVC to create desktop and mobile webapps?

I'm planning the creation of a webapp with a dedicated mobile web interface and a dedicated desktop/tablet interface. I am considering ASP.NET MVC, but it is clear to me that MVC is for separation of concerns as explained here, anyway in my case i'd like to minimize the code and to support elegantly phones and desktop (may be landscape tablet can be "desktop" too). So is MVC a wise choice in this case or which is the 1st stop for this kind of xdevice web app?


Image strategy on Android

I am creating an application with lots of photos. They will take `> 100 mb` on memory. So far I have 3 ideas: >   1. Place it in `@drawable` \- app will be heavy >   2. Download by JSON and place in java array - caching - How long it can be > there? >   3. Download by JSON, place it on phone memory/SD card and read in the > application from memory. User can Remove pictures. > The best option will be to give possibility to user if he want to have a pictures or not. What strategy is most efficient and recommended?


"Pretty good" WPF/Winforms programmer interviewing for ASP.NET job

I have 5 years of experience writing WPF and WinForms applications. I solo wrote the software and thing always turned out well, and the company I work for has happy customers. Plenty of SQL, EF, LINQ, etc along the way. Things look nice to boot. I know zero ASP.NET. Neither my job nor personal projects have let me to work with it. Tomorrow I have an interview for a job that is for an ASP.NET/MVC/WPF/WinForms developer, though I gather from my recruiter that they like to ask about ASP.NET specifically. Now my question is, what exactly are my strengths here? I know I have a good amount of skills, but will they translate well going to ASP.NEt, in that I should act confident that I could pick it up quick on the job since I learned the other technologies? Any other advice? For comparison's sake, while I feel that I have a good handle on and am "pretty good" at WPF programming, it took me a while to get the hang of it coming from WinForms. I feel that if an employer had kept a close eye on me during that time, they wouldn't have been impressed. Any thought? Thanks!


Looking for a book, blog or feed about anti-patterns

In my experience, being familiar with anti-patterns is as vital as knowing patterns themselves. Despite an abundance of literature on patterns, there is a surprising lack of literature on anti-patterns. Browsing the web usually reveals advises that are either too vague (e.g. " _do not use global variables_ "), too specific (e.g. " _java.lang.Boolean.getBoolean doesn't do what you think it does_ ") or obviously wrong to begin with (e.g. _God object_ ). What I am looking for are anti-patterns that appear to be good solutions at first glance, but tend to lead to issues further down the line. Do you know any good source of such anti-patterns? (the only good example I know is SQL Antipatterns)


confusion understanding the fluid 2 column navigation layout

I'm trying to understand the following cross-browser layout: http://matthewjamestaylor.com/blog/perfect-2-column-left-menu.htm but I'm having some confusion with some of its parts and there isn't enough information on the page or in the css comments to help me.     * What is the purpose of the .colleft div? Why can't the 2 columns be directly under the .colmask container?   * Why does the .colleft div have a right 75%? I don't understand its purpose/benefit.   * Why don't the widths of .col1 and .col2 add up to 100%?   * How was left:102% calculated for .col1 and left:6% for .col2? The comments for this are not very clear to me. How is it any different from not even specifiying a left/right css property?


Should ** bind more tightly than !, ~?

Designing a programming language, I'm including the `**` exponentiation operator. In Fortran and Python, the two languages I know of which have this operator, it binds more tightly than unary minus, which makes sense for practicality as well as tradition. It should bind more loosely than the prefix increment operator `++` because the other way wouldn't make sense. Thus the usual single precedence level for the prefix unary operators gets split in two, which is fine as far as it goes. I'm also including the logical and bitwise _not_ operators `!` and `~`. Which side of the split should they fall on? Should they bind more loosely or tightly than `**`? I haven't been able to find either objective reason or relevant precedent for either choice. Is there any of either that I'm missing? Failing that, which would people find less surprising?


Add a second developer to the team

In my company, I'm the only developer, but we plan on expanding the team by hiring a second programmer. I know there are a lot of implications to that (especially around source control). I've Googled a lot, but haven't found a good tutorial/article on how to grow the team from one to many developers. Do you have any resources that we could make use of?


Why are most websites optimized for viewing in portrait mode?

I simply cannot figure this out. Almost all monitors have an aspect ratio where width is much bigger than the height and yet almost all websites are designed exactly for the other way round? I am not really a web developer and am just experimenting stuff at the moment but this madness baffles me!!! Edit: The point is not that I would like to limit the height of a website. The point is that I'd wat it to somehow fill all available space when I have my 1920x1080 in landscape mode. Edit 2: See this to understand what I am saying ![enter image description here](http://i.stack.imgur.com/t6tGR.png)


What is the development process like at Google?

What tools do they use? What processes? What rules do they have regarding code? How do they test their code?


Writing unit test only for applications that requires them

Bit of a rant, but bear with me. People call me purist. I do not code in any way other than TDD. When I try to push TDD as a company policy, the following conversation: company owner: "we'll do TDD when the project warrants it"   me: "if you can't do TDD on even small/simple projects, you won't suddenly know how to do it for big projects. Also if a project is small/simple. the so- called cost of unit test should be negligible".   company owner: "all the devs here know how to do TDD, they'll do it when required". That last sentence struck me as complete B(each) S(and). My argument is if a dev "choose to do TDD when he's told it's required". He's doing it wrong and he has no clue about unit test/TDD. Unit testing is like my left hand and my code is like my right hand. Yeah sure I can just use my right hand. It'll just do things wonky and slower. Do I have my head too far up my @$$? I just have a hard time believing a dev who does TDD fluently would prefer not to do it. (For a whole application) Edit- I'm not talking about whether TDD/Unit testing is/if/how/when required and its benefit. It's a dead horse. I'm talking about now that I do it day in and day out, I feel uncomfortable NOT doing it. I just want to know if it is a healthy mentality.


Apply filter only if not null

My function takes an optional parameter, `type`, which is used to filter through a collection. However, the filter should only apply if the parameter is passed in (in other words, non-null). If the filter is not passed in, it should not be applied. How can I write my logic to reflect this? What I have now is -               if( other conditions && ( Type == null || (Type != null && Order.Type == Type ) ) )         return val += Order;      But this feels clunky and wrong. Is there a way I can simplify my logic here?


What is the significance of the Salesforce platform to a developer?

I decided to learn Salesforce (without any knowledge of this platform) and so far it just seems that I can simply store JSON objects into the cloud... similar to OData + Microsoft SQL or Azure Table storage.   * Link to Salesforce REST API Is my understanding over-simplified, or what additional value does Salesforce provide to the developer?


Integrate NuGet Package Restore feature into checkout process

There are some situations where I have no internet connection and so I am forced to work offline. Usually it would look like this: I get connected, do a checkout from source control server, and move out of office. The NuGet packages stay on the server, because I have enabled Package Restore and should have opened Visual Studio and fired a build at least once, to download them. Before using NuGet we had the package management integrated using SVN externals. The required assemblies were automatically downloaded during checkout. But this system has some limitations, I'd like to get rid off. The prefered way to use Package Restore would be to execute it on checkout or update. Is there a way doing so, using hooks for SVN (TortoiseSVN) or GIT (TortoiseGIT, Github for Windows) as version control system?


Simple straight-line path algorithm

I need a simple pathfinding algorithmn to go from point A to point B. A* seems like an overkill because It doesn't matter wheather I hit walls or not and there's no terrain. I was wondering if there was a simpler one which would find a direct path(a straight line) from point A to B.


cakephp admin panel, different controller for different group of tasks or one for all?

I am writing an admin panel in cakephp I got a question the panel will have the functionality to add items to the main website (images specifically) so I am wondering if I should put all the functionality (add,edit,view,delete) to the main admin controller or should I make a different controller for that? As the admin panel will most likely be extended with more features such as adding new users, modifying them etc. What do you recommend?


What is a good code practice of when to make a function/method for small repetitive code segments?

Many times throughout writing larger programs I have questioned after how many copy and pastes does it make sense to put the code into a function or method and what is a good rule of thumb? I have been using a rule of thumb of four lines or greater and appearing more then twice, then I make a simple function / method containing that code. Can you think of a better practice or offer any pointers? This is more of a general design pattern question rather then a language specific question.


Is return-type-(only)-polymorphism in Haskell a good thing?

One thing that I've never quite come to terms with in Haskell is how you can have polymorphic constants and functions whose return type cannot be determined by their input type, like               class Foo a where         foo::Int -> a      Some of the reasons that I do not like this: **Referential transparency:** "In Haskell, given the same input, a function will always return the same output", but is that really true? `read "3"` return 3 when used in an `Int` context, but throws an error when used in a, say, `(Int,Int)` context. Yes, you can argue that `read` is also taking a type parameter, but the implicitness of the type parameter makes it lose some of its beauty in my opinion. **Monomorphism restriction:** One of the most annoying things about Haskell. Correct me if I'm wrong, but the whole reason for the MR is that computation that looks shared might not be because the type parameter is implicit. **Type defaulting:** Again one of the most annoying things about Haskell. Happens e.g. if you pass the result of functions polymorphic in their output to functions polymorphic in their input. Again, correct me if I'm wrong, but this would not be necessary without functions whose return type cannot be determined by their input type (and polymorphic constants). So my question is (running the risk of being stamped as a "discussion quesion"): _Would it be possible to create a Haskell-like language where the type checker disallows these kinds of definitions? If so, what would be the benefits/disadvantages of that restriction?_ I can see some immediate problems: If, say, `2` only had the type `Integer`, `2/3` wouldn't type check anymore with the current definition of `/`. But in this case, I think type classes with functional dependencies could come to the rescue (yes, I know that this is an extension). Furthermore, I think it is a lot more intuitive to have functions that can take different input types, than to have functions that are restricted in their input types, but we just pass polymorphic values to them. The typing of values like `[]` and `Nothing` seems to me like a tougher nut to crack. I haven't thought of a good way to handle them. I doubt I am the first person to have had thoughts like these. Does anybody have links to good discussions about this Haskell design decision and the pros/cons of it?


Breaking down a complex story at project start

I'm trying to get to grips with agile project management (with Pivotal Tracker) but keep finding myself running into walls when trying to define the first few stories of a project. Take for example this very simple story: "A user should be able to tag a product" Assuming I've already defined "product" elsewhere, this story would possibly involve writing a polymorphic tagging system under the hood, on completion of that system id be able to finally add the ability to tag a product. My problem is with the amount of work hidden in this story. I can define tasks to get the story done but stories as a whole are supposed to be 1-2 days work? I don't feel right about the story just revealing the tip of the iceberg but that's the only part that relates to the User. How do you overcome this kind of thing? What are the best practices? **UPDATE 25/08** Thanks to everyone for your guidance, I've taken all advice onboard on how to define stories. I am now switching to Jira Grasshopper which has better support for tasks within stories (assignment, estimates etc) and tracking of development tasks once the sprint has began.


What database structure is suitable for tracking File audits?

I need to track permissions and access requests to a file server in a database. I'm given the full path of the folder and am considering parsing the path (splitting on the "/" character) and creating a self-referential link to the table... in addition to a column intended to store the full file path. What is the ideal approach for dealing with such a system that can have a tree of folders and having a database schema suited for that purpose? Is self-referential columns overkill?


What is a *slightly* less extreme equivalent to being "fluent" in a language?

tl;dr: What is a less extreme (but still noticeable) alternative to the word "fluent", when saying e.g. "I am fluent in C++/Python/whatever?" * * * I think I can call myself "fluent" in C#, because I know the language and runtime very well, and I'm very familiar with the .NET framework's APIs and classes, etc. I would _like_ to claim the same thing for Python and C++. But while I _can_ program in Python (I did so for an entire summer, making a website with Django), for example, I would not call myself _fluent_ because **my code isn't always "Pythonic"** (e.g. using `map`/`filter` vs. list comprehensions), and I'm not too intimate with some aspects of the language and standard library yet (e.g. the introspection API, etc.). Is there a word or phrase I can use on e.g. a resume to describe what I know? I can think of "very familiar with", but is there a better word/phrase I can use?


How long can a programmer concentrate in a day?

There is this question ( which is now closed as _not constructive_ ) that asked about the average productivity per day. My question is, is there any scientific study on the productivity of programmers? I can't help but feel that doing 8 hours of quality programming work from Monday to Friday consistently is very hard. And if yes, is there any literature that investigates this?


Is there a guide for software development to design efficient hotkeys for actions?

I don't know how to word this easily but basically the software I am writing has a ton of actions and I want to assign hotkeys to every one of them so power users can work super fast. First off they are not actions related to the application itself, i.e. Quit, Maximize Window, About, Preferences, etc. But rather actual operations you perform on the data set. It's not exactly the same but closest example I can give is the Nuke compositor, where each action is represented by a node. So things like Blur, Sharpen, Add, Color Correction, Keylight, etc. But since the number of nodes are over 500, I don't know how to create easy to remember hotkeys that do not use every modifier key combination. Is using 2 key combo, i.e. CC for Color Correction the best way? Are there resources on this subject? Basically maximizing the use of hotkeys to take working speed to the max without having to remember 1000s of key combinations. ![enter image description here](http://i.stack.imgur.com/icbaH.png)


Lowercase in Linux file names

As I find that UpperCase are really readable for first letter word separation in long complex names, I tend to give some of my Linux files names with some UpperCase. Mostly executables, some directories too. But it's been a few weeks I have remarked that the huge majority off all file names in my linux distrib are lowercase... So I made some googling a moment ago, and I found this article: Linux File Names, that states one should _always_ use lowercase in the unix world, > ...It's best to _always_ use lowercase in Linux unless you can think of a > good reason to use uppercase or mixed case. Most Unix people use lowercase > almost exclusively, but aside from this "cultural" point, there's another > good reason to use lowercase. If you're sharing or accessing a DOS file > system with Linux, DOS will not be able to see the files that have uppercase > or mixed-case file names... Is that really the case?


Universal means of describing what functions a library should expose

I am busy with a hobby OS and I am planning on making the project open-source and eventually have support for multiple platforms. With this in mind I have taken the approach of putting all hardware specific code in a separate Hardware Abstraction Layer (HAL) library so that the kernel does not need to know how the specific hardware handles things such as memory and interrupts. The kernel will just call the HAL function asking for some memory or to hook an interrupt by calling `hal_memory_malloc(...);` and `hal_interrupts_hook(...);` respectively. My question is, I would like to know if there are any universal means of describing what functions the library has to expose if a developer wants to port the HAL to another platform. Seeing the Kernel knows the name of the function because it's in the kernel's header files the library just needs to have a function with that specific name in it. As the kernel I don't care how your function works as long as its there and I can call it. _**Edit_** My kernel and library is written in C so the library will be a normal statically linked libray At the moment I have a Word Document that has a diagram showing the different functions but this is going to become a mess soon. Any advice would be greatly appreciated.


Should I store "system b" password in "system a"?

I am developing a system for mailing which has a account id/password to login and I need to store the smtp server account and password for sending mail. Since the mail is auto send I can't request the user input password/id each time when sending. Therefore, is storing the user account id/password (system b password) in my system (system a) insecure design? How can I improve this?


Does this implementation of the state pattern make sense?

I have the task to implement the state pattern in one of my classes. The assignment referenced a suggested implementation, and upon reviewing that implementation I was confused since I believed it to be nonsensical for most applications and frankly simply bad from a design point of view, since it completely dismisses some very basic design principles of software code. This is the class diagram of the suggested implementation: ![enter image description here](http://i.stack.imgur.com/mexgp.png) I wonder: What is the use of this implementation? It (imo) clearly violates the two main design principles of software engineering: Make things easily maintainable, and easily extensible. In my eyes, this implementation has zero easy extensibility(you have to change the source of at least two classes, for example, to implement a new state that you forgot about when first implementing it). The coupling between this code and client code seems to be huge. If you remove anything in this pattern, all client code will break. If you want to add anything, you have to change all client code in order to adapt, for example, a new state, because new states can only be entered via the enter() method of the concrete state, or by directing injecting them into the Controller using the changeState() method. As a bonus, you can only have one garage door in the entire world, since the states are practically singletons. The enter() method in the concrete states was given as this:               public static State enter(Controller c) {     if(m_instance == null) m_instance = new <<concreteStateName>>(c);     return m_instance;     }      Or you can have multiple garage doors, which all open simultaneously if you open one. Why would you put all methods in the abstract State class? Where's the polymorpy? Why do concrete states have either empty or exception throwing versions of methods that have nothing to do with their state (for example, the resulting interface of Opened will have a "lock()" method, even though you can't directly lock the garage door when it's open. You have to close it first). Why not choose a single method and implement it differently in the concrete States, making the thing easily extensible again? It is also (again, as far as I can see) not really maintainable without a lot of troubles. What if you, after a couple of months of using the garage, decide that one state is in fact not only obsolete but wrong? You're going to have to take it out, and the according method in State() with it, breaking the entire code base that uses this implementation. This is a garage door with four states. I wouldn't want to work on that thing if it had any more states. The situation gets more confusing when I look around the internet: The pattern actually seems to be implemented exactly this way a lot of times (for example it is implemented like this way in our national Wikipedia (German)). The actual question: Am I missing anything or is this simply bad? Since this is so widespread, I'm thinking that I might be missing something obvious here.


Is it fine to use logs in the Helper Methods?

I have been doubting for a long time whether or not to have a logger in methods (usually helper methods) like the one below. Whether we can print it in the method or print the response where the method is called.               public String getAddNewUserUrl()     {         String url      =   null;         String mode     =   null;         try         {             log.info("Inside getAddNewUserUrl "); // Can u use logs like this.             mode        =   new ModeUtil().getMode();                  if("local".equalsIgnoreCase(mode) || "staging".equalsIgnoreCase(mode))             {                 url     =   ResourceBundle.getBundle("ApplicationResources").getString("staging.url");             }             else             {                 url     =   ResourceBundle.getBundle("ApplicationResources").getString("staging.url");               }             log.info("The url is  : " + url);  // Can u use logs like this              }         catch(Exception e)         {             e.printStackTrace();             log.info("Exception in the method getMode ::"+e.getMessage());         }         return url;


Should data be stored to local database in Android when heavily using REST services?

Let's say I have an application that has constantly changing data. Changes are so frequent that you basically need to refresh data every time you open some screen and keep refreshing it. Is it worth implementing local database for such application? Implementing database in such application seems redundant because:   * Data structure might be complex (arrays, optional parameters and etc) and so using cursors is not a very efficient way to pass it around   * Data does not need to be stored for long time   * If optimized to request filtered data in certain screens (to reduce data traffic), must make sure to filter database updates in such way that unfiltered data (which might be used by other screens) is not affected. Not that hard but still something to develop (and test) However, implementing local database might mean faster navigation. But again, that's not true if service requests are highly optimized to avoid sending redundant data. Do applications like Play Store, Facebook, Google+ use local database to replicate data structures stored in remote database? **I just wanna know what is the common practice for developing applications heavily based on web services.**


Erlang web frameworks survey

(Inspired by similar question on Haskel) There are several web frameworks for Erlang like Nitrogen, Chicago Boss, and Zotonic, and a few more. In what aspects do they differ from each other? For example:   1. features (e.g. server only, or also client scripting, easy support for different kinds of database)   2. maturity (e.g. stability, documentation quality)   3. scalability (e.g. performance, handy abstraction) main targets Also, what are examples of real-world sites / web apps using these frameworks? EDIT: Starting a bounty in hopes that it will get some conversation going


JUnit Testing in Multithread Application

This is a problem me and my team faces in almost all of the projects. Testing certain parts of the application with JUnit is not easy and you need to start early and to stick to it, but that's not the question I'm asking. The actual problem is that with n-Threads, locking, possible exceptions within the threads and shared objects the task of testing is not as simple as testing the class, but testing them under endless possible situations within threading. To be more precise, let me tell you about the design of one of our applications: When a user makes a request several threads are started that each analyse a part of the data to complete the analysis, these threads run a certain time depending on the size of the chunk of data (which are endless and of uncertain quality) to analyse, or they may fail if the data was insufficient/lacking quality. After each completed its analysis they call upon a handler which decides after each thread terminates if the collected analysis-data is sufficient to deliver an answer to the request. All of these analysers share certain parts of the applications (some parts because the instances are very big and only a certain number can be loaded into memory and those instances are reusable, some parts because they have a standing connection, where connecting takes time, ex.gr. sql connections) so locking is very common (done with reentrant-locks). While the applications runs very efficient and fast, it's not very easy to test it under real-world conditions. What we do right now is test each class and it's predefined conditions, but there are no automated tests for interlocking and synchronization, which in my opionion is not very good for quality insurances. Given this example how would you handle testing the threading, interlocking and synchronization?


How to start a Software Company

I've always been interested in wondering how software companies happen. I find it extremely difficult once you're tied down with car, house, life etc. Funding is always the biggest concern. To make this a bit more specific, I see two types. Those offering a _product/service_ or those offering a _consultancy_ company. One things that bugs me about the product/service kind is that we all know how burning the candle at both ends is extremely exhausting. Coding for 8-10 hours in the day and then code in the evenings on your own stuff, doesn't last long. No matter how passionate you are about your idea, simply put, coding day and night is a recipe for burn out. Is this a defeatist attitude though? Can it be balanced? A consultancy kind isn't as tricky in my honest opinion. I think once you have spent years and years in the industry building up relationships, contacts from contracting or moving around, and of course, being involved in the community, then landing your first project as a consultant I'm sure is easier than the product/service kind. I'd imagine friends then could join you as you take on bigger company projects, like an Agile implementation or TDD training, then off you go gaining bigger things. Could you please specify which company type you're answering if you can't contribute to both. I'd like to hear everyone's experiences or ideas on any level for software company start-ups.


annual goal for programmers in IT company

As IT manager what goals would you set for your programmers in your team. These goals would be used in the annual performance review. Any recommendations? How would you create goals that actually measure programmers technical abilities.


Posting High Salary in Job Ad for Programmer

Would posting a high salary on a programmer job advertisement encourage strong candidates and weed out lesser candidates? The salary would be relative to the position. Edit: Maybe it wouldn't alter your application, but would you have any concerns or does this raise any red flags? It wouldn't make them seem desperate?


What is the best way to scale a CQRS system?

In the previous months I have been asking a lot of questions concerning the architecture of an application I'm working on. Thanks to the answers the architectural design has changed - in fact, it has really been simplified as shown in the following graph: ![architecture](http://i.stack.imgur.com/ELCA8.png) Internally I have a two services ( **NOT WCF!** ) that follow CQS principles. It means that the query service simply returns database views; while the command service has a full domain model that contains all business logic, and repositories to access the database (no event mechanism or other complex pattern here). Both services use the same database. These services are class libraries, NO WCF services, because they are used only internally so I don't need the overhead of WCF (don't distribute your objects, Martin Fowler's first law). These internal operations are used by the ASP.NET MVC site and the PartnerService. This PartnerService is a WCF service, which exposes the functionality I would like to be exposed to partners. If I ever need to scale because of high traffic, I could add web servers and/or migrate parts to a full CQRS system (my contracts are already designed for it). Does anyone see any problems with this? One thing I see is that if the query or command service changes, this impacts both the web site and partner service directly, so I have to deploy the changes to both. But I don't know if this is an issue...? Any feedback is appreciated! Thanks!


How do I manage multiple relationships from a software design perspective?

How do I go about managing projects when there are two fundamental relationships that need to be maintained? The most obvious example that I can think of would be a firm doing some kind of location-based consulting. I've been wracking my brain on how to explain this, in essence, this is the bullet point version:   * Each client that has multiple locations   * There are several projects that relate to specific client locations   * There are deliverables for these projects      * Each deliverable my only relate to a few locations the project is linked to The system seems to break down when you overlay these two main relationships; a client with multiple locations which have projects assigned to them, and deliverables that link back to individual locations. You just end up with too many many-to-many relationships that are difficult to manage. The problem is then visualizing this in a system. You have a client record with location sub-records. Each location record has many project records associated with it. Each Project record has deliverable records, and then those deliverables relate to specific loations. I realize that this seems a bit estoeric, but is there a way to simplify this so that it is visually understandable?


clojure/erlang/go for high volume server

I have a project that will need to handle 1000s of requests a second with a decent amount of processing for each. For the most part, the processing will be done on a list of items, basically filtering it and returning a smaller list. This process can be done in parallel fairly easily and I should also say, speed is important. I've narrowed my language of choice for the project down to clojure, erlang, and go, and have researched them all to a moderate degree. My question is, what factors should I be looking at in my decision? What language is better for what (examples would be great)? Because it's a little difficult for me to tell.


Cheerp -- C++ for web: advance or regression?

Recently I've run into Cheerp, a C++ to Javascript compiler, which uses a modified version of clang to generate Javascript code from C++ sources. That makes me wonder: why in the seven kingdoms would someone do this in their right mind? I mean: why would you take a language that is not designed for web at all, that is far more convoluted and bureaucratic, write your code and then compile it into Javascript itself? Can anybody see any advantages in doing so? We surely can discard performance as a reason, because in the end it generates pure Javascript code. Is there anyone here that have real experience with this? P.S.: I'm not sure if this is an on topic question, but this is the most general forum about programming that I could find in the StackExchange network. ## Edit Although this seems like a subjective question, it is not. I am asking for reasons why this tool could be useful. I got interested at first, but started wondering why would someone use it.


I am a solo developer working on a decently small project with about 3 other people (non-developers). These other people are involved in the project in non-development ways and one is also my manager. Everyone is pretty open to ad hoc discussions, too. My manager just gave me what seems like a dream come true - I was tasked with determining what meeting structure would work best for the project. This seems like a wonderful way to deal with meeting overload and/or pointless meetings. With great power comes great responsibility, as now, if I suggest something which ultimately results in much wasted time it's my fault. I have never had such a blank slate to think how I would structure meetings. My thoughts are:   * Daily "touch base/status update" meeting for 15min or less (similar to standup meetings) to communicate daily objectives and review previous day. Or, it seems I could just get a whiteboard and put it at my desk to communicate this info.   * As needed meetings to make specific decisions or address questions any of the team has ... I don't see the need for a weekly "status" project meeting. I'm also not sure the second bullet would require many formally scheduled meetings. My concern is these "developer focused" (ie me) might cause alienation with others or make my manager feel a loss of control on the project, as this structure would be considerably different than most projects are run. What project meeting structure should a single developer choose? * * * Addressing comments: > What are the other people contributing? Are they the intended users of this > project? Working on non-development aspects of it (such as website themes & > images or a DBA, or QA testing)? Other levels of management/administration? They are some of the eventual users and are interested in the overall workflow. They are also contributing to several areas of forms/documents (the format of which will not affect any development work). > Are you able to get feedback from the other two members? Some managers need > to have a regularly scheduled meeting or they'll never be able to fit it > into their schedule. Getting time does not seem to be a problem going forward.


How to mitigate security risks when deploying a database to the web via automated migrations?

I'm looking at using built in database migrations frameworks (such as the migration framework included in EF Code First or migratordotnet) but I have concerns about the implications of allowing a production website to have permissions to execute DDL statements. In the past when working with web apps I would migrate database objects manually which would allow me to restrict the permissions the web application's database user was given. This mean even in the case of a SQL Injection attack, a stolen web.config or some other attack on the web site it would be more difficult for an attacker to do serious damage (though obviously not impossible). It seems to me by performing migrations via the application (as seems to be almost required when using a PaaS like AppHarbor) you your application up to more threats. So, the heart of my question is:   1. Are my concerns unwarranted?   2. Are there any steps I can take to mitigate those threats while still taking advantage of automated deployments?


Sleeping Web Server?

Are there any languages or even servers that instead of running a script on page load, (Apache/PHP, Ruby on Rails, ...) actually keep the code loaded and running forever, and when it receives a connection it calls a function of that code? (Like a PageLoad event basically?) I didn't really know how to call this so I went for Passive Web Server because the code is basically sleeping till an event occurs, instead of fully unloaded or just cached.


Is the synchronized keyword,still used/needed in java?

Is the synchronised keyword still required (ignore backwards compatibility, I'm thinking in terms of writing new code, today) or should we all be using the features available in the Concurrent and Collection packages?


What does "branching is free" mean in Git? I hear this a lot whenever Git is mentioned in comparison to other version control systems. I haven't had the opportunity (?) to deal with others (SVN, etc.), so how is branching "expensive" in others?


APIs that deal with logins

I have been asked to make a mobile app for a friends website. The website is a Multi level marketing site that sells products and franchises. A client logs in in to the website and can view his or her dashboard ( user can view team members, business volume, commissions, invoices, etc.) The app is supposed to bring the dashboard to user's mobile devices (w/ some added features). The company does not have any APIs that deal with interaction or authentication, and I am new to the whole secure login side of app development. My questions is this, how do I let the users gain access to their information via my app from the secure website when there is no API?


Why nginx's http parser doesnt use regular expressions?

I see the http parser written by Igor Sysoev for nginx does not use regular expressions https://github.com/joyent/http-parser What could be the main reason for such design decision? I guess I could write few regular expressions to parse HTTP req & res this would be a lot less complex than Igor's version of the parser. What am I missing here?


what is sharding in MongoDB

i have just reading MongoDB.came across sharding but not getting what exactly is it .watever i understood is its better to have more small servers than a huge one for data storage and when data exceeds capacity of one server you can use another machine to store data.can anyone give soem more idea about sharding?


SOA: should I always consider it?

While I think how to direct the future development: ### Mini-introduction As a fixed rule, I start with SOA (and REST as protocol) then I work on the interfaces (and that interface is a customer of my service, and usually is a separate project). I assume my _deviation_ is because I'm first of all a back- end developer ( _with poor drawing skills_ ). ### Considering:   1. The BIGs are making a great effort in making quick and easy to use tools for creating interfaces. _(I am referring to projects such as the bootstrap, angular, android studio, and many others)_ ; This is a relief for those who develop platforms, opens the door to many new applications for their platforms.   2. MV*, JSON, Javascript are becoming a standard in building (even) complex applications; It does not matter if the interfaces are all the same, the boilerplate today have reached a level that can be considered viral.   3. The increasingly common repository of modules (ex. NPM), enable even novice programmers _the use_ and _implementation_ of external APIs with great ease.    4. _fate_ can always kiss our products and this maybe become the new facebook (with this I am referring to the fact that a product, even if required as a standalone, it can easily attract the interest of many, and it is very likely that new interfaces are required out of the initial planning). ### Questions:   1. Is SOA an approach that architects (and programmers) should **encourage** and **consider** starting new design?   2. Is SOA the **most suitable architecture** to react to **unplanned expansion**?