ORM and component-based architecture

I have joined an ongoing project, where the team calls their architecture "component-based". The lowest level is one big database. The data access (via ORM) and business layers are **combined** in various components. E.g., there's a component for handling bank accounts, one for generating invoices, etc. So every component contains the data access to only a part of the schema. My issue is the coupling of data access and business logic in such a structure, because while such a partition makes sense for business logic, it complicates data access. From my point of view the separation of the data access layer into various components seems counterproductive, because it denies us the relational mapping capabilities of the ORM. E.g., when I want to query all invoices for one customer I have to identify the customer with the "customers" component and then make another call to the "invoices" component to get the invoices for this customer. The entity Customer can't have an Orders property, because Orders are mapped in a different component. Does anybody have some advice? Have I overlooked something?


Suggestions wanted on dealing with hyper territorial team

I have just started a new job and all is not well in neverland. I had high hopes for this company, but when I arrived, I walked into a team that I am having a hard time working with... The two existing developers on this project are having a hard time accepting any suggestions or changes to the code that they spent the last few months writing. It seems like a political minefield and so far their way of dealing with a new team member has been to avoid explaining as much as possible. example: this is a rewrite of an existing system and apparently I don't need to know anything about the old system because they have already reviewed it and know what needs to be done. I don't want to make this a long rant, but there are other issues including micro-management, assigning only trivial bug fixes, and an unwillingness to consider any suggestion, idea, or minor code change that is a departure from how it is currently written. Example: I had a bug fix to make sure a search screen truncated names longer than 25 characters. One of the existing developers made the comment that I need to talk to them before I start so he can show me how the existing string truncate is done, LOL. If I check in code without consulting them first then "the team" decides that it needs to be reworked. HOW do I deal with this? Has anyone out there ever overcome similar issues? Is this just a lost cause??? P.S. I'm not a junior level or incompetent programmer. I'm no rock star, but I've got as much experience and knowledge as the rest of my team, so I don't think that is the underlying issue.


Stuck due to "knowing too much"

Note more discussion at http://news.ycombinator.com/item?id=4037794 I have a relatively simple development task, but every time I try to attack it, I end up spiraling in deep thoughts - how could it extending the future, what are the 2nd generation clients going to need, how does it affect "non functional" aspects (e.g. Performance, authorization...), how would it best be architectured to allow change... I remember myself a while ago, younger and, perhaps, more eager. The "me" I was then wouldn't have given a thought about all that - he would've gone ahead and wrote something, then rewrote it, then rewrote it again (and again...). The "me" today is more hesitant, more careful. I find it much easier today to sit and plan and instruct other people on how to do things than to actually go ahead and do them myself - not because I don't like to code - the opposite, I love to! - but because every time I sit at the keyboard, I end up in that same annoying place. Is this wrong? Is this a natural evolution, or did I drive myself into a rut? Fair disclosure - in the past I was a developer, today my job title is a "system architect". Good luck figuring what it means - but that's the title. * * * Wow. I honestly didn't expect this question to generate that many responses. I'll try to sum it up. Reasons:   1. Analysis paralysis / Over engineering / gold plating / (any other "too much thinking up-front can hurt you").   2. Too much experience for the given task.   3. Not focusing on what's important.   4. Not enough experience (and realizing that). Solutions (not matched to reasons):   1. Testing first.   2. Start coding (+ for fun)   3. One to throw away (+ one API to throw away).   4. Set time constraints.   5. Strip away the fluff, stay with the stuff.   6. Make flexible code (kinda opposite to "one to throw away", no?). Thanks to everyone - I think the major benefit here was to realize that I'm not alone in this experience. I have, actually, already started coding and some of the too-big things have fallen off, naturally. Since this question is closed, I'll accept the answer with most votes as of today. When/if it changes - I'll try to follow.


New application development - Use existing database or create a new one?

A Client has a huge Windows Application running on a Database. This client wants you to develop an "Express" version of this application, including only, let's say, 20% of its features. This Express version must be a Web Application, opened on the WWW. You have 2 choices:   * Use the same Database to develop the web application   * Create a new database to the web application, including only the necessary tables and objects and use some synchronization mechanism to keep the databases up to date. The client prefers the 2nd option, because: Security: If they have a separated Database for the web app, they will not "expose" the huge Windows App Database on the internet. Performance: The windows application has some huge process that they run at night and "lock" the database for a couple of minutes. So, creating a separated DB would ensure better performance to the web application. I prefer the 1st option, because: Integrity: If we have different databases, we won't be able to create Foreign Keys between them. Avoid Sync: If we have different databases, we would have to create a synchronization mechanism, which is very prone to failures. Maintenance: Maintenance will be easier if we have only one database. No change will need to be replicated. Can you help me decide which way to follow, and why?


Encouraging software engineers to track time

How can I encourage my coworkers to track the time they spend resolving issues and implementing features? We have software to do this, but they just don't enter the numbers. I want the team to get better at providing project estimates by comparing our past estimates to actual time spent. I suspect that my coworkers don't see the personal benefit, since they're not often involved in project scheduling.


How to show someone of the power of model-view-controller design pattern?

I've been working with a friend on a project that we've taken over, and I've realized that we have a big problem implementing the model-view-controller design pattern due to the way that the project has been set up. The project is currently split up into the following three sections (.proj files in Visual Studio):   1. Model classes.   2. Controller classes (business layer logic).   3. View classes. Visual Studio isn't letting me create cyclic references (quite understandbly) between two of these three sub-projects. This means that the controller classes can have a relationship with the view classes, but the view classes can't have a relationship with the controller classes! The result of this is that as soon as the controller displays a view, the rest of the controlling logic has to go in the view class! So I've proposed that we merge all three sub-projects together (to avoid the cyclic references of visual studio). This means that we can create all the relationships between the three types of classes that the model-view- controller design paradigm requires. Ultimately, it will be we can place the controlling logic in the rightful place of the controllers, taking it out of the view classes. The problem is I'm having a hard time convincing my friend about this. He thinks that having these separate boundaries between the sub-projects means that there's safety that we won't ever do things like put controlling or viewing code in the model (as the model sub-project is currently only ever referred to and doesn't refer to the controller or the view). I was wondering if anyone could come up with some ways that I could really get my point across about how important this design pattern is, and how limiting it would be to go against it, and continue putting controller logic in the view classes? Many thanks.


Is there a difference in resource allocation & efficiency between a web app and a compiled one?

I'm a web developer. I feel like I develop less resource-intensive functionality often times, because I have this feeling that if I ask too much of the web app (animation, calculation, connections, etc), it will get lagged for users with slower computers. I've been curious for a while now about just how much difference there is in the capability (resource allocation) of a web (interpreted) app vs a compiled one. Also, I've heard that interpreted (JS, for example) programs are very inefficient and resource-hungry in comparison to compiled ones (C++, for example). Google's V8 JS Engine is said to make JS faster, but I still see people talk about JS being much less efficient than C++. * * * The reason that I ask this question is to separate fact from biased opinion.   * Is there a difference in available CPU & RAM between a web app and a compiled one?    * Is there a large efficiency difference between a program written in (an interpreted language) JS versus one written in (a compiled language) C++? * * * Edit: I realize that we are comparing apples and oranges here. There are some really well-defined aspects of choosing between C++ (anything compiled) and JavaScript (web) when developing a client application, and this is one side aspect of that decision that I would not want to be misinformed about if it were to come up at any point in my career.


How does team development work?

This is a pretty generic question but one I've been wondering about for a while: is there a standardized, generally accepted, or even just systematic way that people write code as a group? For example, in a project written in C++, does one developer write one class, which he passes off to the next developer with a quick explanation of what each method does?


license and copyright assignment

I'm currently working on a wordpress plugin. My client gives me a specs doc (a powerpoint presentation, if you can call that a specs doc), and I code the requested functionality. Every time I send him code every file containing code starts with these lines:               Author: My Name     Copyright: The_client's_company.com     License: MIT Expat (http://en.wikipedia.org/wiki/Expat_License)      My intention being giving my client complete right to relicense and distribute the code under any other license (as the TOS of the freelancing website requires, plus I know he intends to sell it under a proprietary license), but at the same time giving myself the right to expand and redistribute the plugin under MIT license if I wish to (not that I do). The reason is I am paid only 10USD/hour (this is my first gig) so I want to at least keep the right to reuse parts of the code in other projects or expand it if I want to start a similar project myself when I finish the contract (unlikely, but who knows...) or show it to potential employers. The contract we agreed upon doesn't include any licensing specifications but I've informed him on the emails we've interchanged that although all my work is licensed by default as MIT I'm giving my clients the copyright of the code I produce so they can relicense it at will before distribution. Is this the correct way of achieving that?


Are Blocks Second-Class Citizens in Objective-C (vs. Ruby)?

Feeling slightly witty the other day, I wrote an `eachWithIndex:` method in a `NSArray` category. It has a typedef like this:               typedef void (^processItem)(id item, int index);      and the method looks like this:               - (void)eachWithIndex:(processItem)block {         for (int i=0; i<self.count; i++) {             id item = [self objectAtIndex:i];             block(item, i);         }     }      However, if my block contains a `return` at any point, it doesn't jump out of the calling method (nor the block). Consider this code in Ruby:               def blah         %w{one two three}.each_with_index {|thing, i| puts "#{i}=#{thing}"; return "hello!" if i==1 }         puts "blah does more stuff"     end      when `i` reaches one, the `blah` method will end. This does not happen in Obj-C, and I feel that it should. Are blocks more integrated into Ruby than Objective-C?


What should I consider when deciding if I should use a web service backend instead of traditional MVC?

We're trying to decide what architecture to use for an upcoming web application that will eventually have a mobile portion as well. The core of the project is a social networking web application, and the mobile portion will most likely have a limited subset of the web functionality. The two options we are looking at is either a **complete web service back end** , or using a **traditional MVC framework** for the web application and then developing web services on the side for the mobile application later. Some arguments for web-service-only route is that it would be "simpler", as we would just have to create 1 web service as opposed to creating both a web service for the mobile portion, and additional database functions/calls for the web application. Using this method, the web application will fetch data from the web services using javascript, which would then generate the html page (sounds kind of like what a traditional MVC framework does, but this way would require everything to be done in javascript). I'm not feeling good about the idea of using web services only because it doesn't make sense to me, but I am having trouble clarifying my issues with it. So what should I consider when trying to determine if we should use a complete web-service backend for our project instead of traditional MVC with web services only available when needed for the mobile portion of the app? I'm looking for a comprehensive answer to this question, not many answers each containing one piece of the answer.


What is the most space efficient way to implement a graph data structure?

I typically implement graphs as doubly linked lists but this is fairly space inefficient in my experience as I need k pointers/references for k neighbors so for an undirected graph I'd have ~2k neighbor links within the lists if my math is right. Is there a better way of saving space? I know that some of the links can be made singular if the graph is directed but is there a way to do a better job of this?


Can/Should I put my Git repository on a non-dev machine and keep it synced with the non-version control server?

I volunteer for a website, and well, basically, we don't have version control. We're working to change that, but because of several things, including the fact that I haven't worked with source control before, that's not happening for some time. In the meantime, I'd like to move my working files into source control (probably Git) for the obvious benefits. Here's the thing: there are hundreds of thousands of files on the web server that are user-generated that I don't really want on my dev machine because, well, I pay for my own equipment (it is volunteer after all, so it's not like I can expense a new hard drive) and my dev machine is also my everyday computer and I'd rather not clog it up with a lot of stuff that doesn't need to be here. I do, however, have an empty system sitting around that is perfectly willing to store all of that data. In all likelihood, that system is probably going to host an entire local copy of the site anyway as a backup. So, and I hope this isn't an entirely crazy idea, I'm thinking about putting the Git repository on that machine. I'm not intending to develop on that machine, however. So,   * Is putting your Git repository on a different computer than your dev machine a really bad idea? It should be technically feasible as it's on the same network, and I don't think my IDE will have any problem connecting to it, but that doesn't mean it's a terrible idea. Putting the repository on my dev machine isn't out of the question, but it'd be preferable to put it on the empty one.   * (And I hope that this is related enough to keep in the same question) Because there are other people working on the site, changes are going to happen to the remote site that aren't going to go through source control. Since I'd prefer the two to stay synced, could I create a Git repository on the server, pull and merge changes into my local, and then just upload the changes through FTP? Doing any real version control on the server isn't feasible at the moment (as I said, it's being worked on), but a repository that we don't touch is a different matter. Would this be a feasible plan at all?


What do I need to do to NOT steal "Hello World" code with a GPL license?

In the project, I found a file, `math.c`, with a big GPL header and ...               //------------------------------------------------------------------------------     /// Returns the minimum value between two integers.     /// \param a  First integer to compare.     /// \param b  Second integer to compare.     //------------------------------------------------------------------------------     unsigned int min(unsigned int a, unsigned int b)     {         if (a < b) {             return a;         }         else {             return b;         }     }      OK, cool so I need to get min value and ... **_this file_**!? So I need to open the whole project because of it? Or do I need to reinvent mathematics? I don't believe it's just insane, so the question is: when we can just remove the GPL header? Must I _be a weirdo and do it_?:               unsigned int min(             unsigned int     JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE,     unsigned int hyrthrtRERG            ) {  if     (JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE     < hyrthrtRERG            ) {  return JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE;  }     else {return hyrthrtRERG            ;    } }      Seriously, do they want me to write code like the above?


Benefit of using static inner builder class

During the course of writing the code guidelines for a company I found myself recommending using the Builder pattern from Effective Java, instead of telescopic constructors. However, after thinking about it a bit more, surely a more elegant solution is to just remove the builder class and the also remove the extra constructors with optional arguments. So just have the one constructor with required parameters, normal getters/setters, and comment the code. When implementing just create a new instance of yr object then set values. My original thinking was the benefit came from removing the confusion as to what paramters were optional and what were required; however the true benefit comes from using method chaining/fluent interface. The builder pattern has benefits when you make lots of new instances as the ide can do the leg work and also if there are many (15+) optional parameters. However, is it worth the extra time coding the static inner class, would you recommend using the builder, or is it a waste of time ?


Can a beginner in programming start learning game development?

I'm very new to programming and I'm using Java. I got interested to learn programming because I want to create games. I love playing computer games and I know that game developers make money. I told myself that instead of just playing why not create my own game and probably make some money. I read some articles about game development using java and I learned about JMonkey. I just installed it in my Ubuntu PC. Should I learn first the basics of Java or I can start learning JMonkey and Java at the same time? I know that JMonkey is game engine built using Java and it provides libraries to help developers create Java games efficiently but its kinda advanced for a dummy like me.


Should you exercise TDD on prototype applications?

I'm developing an iOS app, which is a prototype for a customer. They're expecting it to not be of production standard and are happy for a few rough edges here and there. Since this is my first commercial venture into iOS / Objective C (I'm an android developer that is trying to cross-train into iOS), my primary focus has been learning the Objective C language and how to develop the app, and I have not invested any time into learning how TDD can be applied in this environment. My question is, even for prototypes, should you still try to apply TDD and create unit tests?


Is WCF suitable for writing an application which is shared among applications?

I have developed and deployed few ASP.NET applications. Sometimes I want to stop the users from either inserting or updating a record when:   1. Maintenance is going on.   2. Stop operations due to payment delay. In one of my recent application I have implemented this feature to first check the database operations for locked status. If any of the above condition fulfils, database operations like insert and update are not carried out. I now need this feature in all the old applications and the future applications I build. I want to know whether WCF is suitable in this scenario as I want to share methods or an independent locking application among various other applications. Is WCF appropriate for this type of scenario?


Is there any better approach to shortest path finding within a (vehicular) traffic network?

Dear fellow programmers, We're developing software which simulates vehicular traffic. Part of the process called "assignment" is concerned with assigning vehicles to their routes and has to use some kind of shortest-path-finding algorithm. Traditionally, people do this with Dijkstra's, and certain scientific literature seems to indicate that A* and other alternatives don't give any significant improvement, perhaps due to the nature of the graph. Hence, we're using Dijkstra's as well. A small problem arose in that, if you treat traffic links (spans of roads between intersections) as edges and intersections as nodes, you can't get a classic uni-directional graph: when approaching an intersection, where you can turn frequently depends on where you're coming from, whereas in a traditional graph you can take any edge from a node. We resolved this problem quite easily by representing a link-intersection pair (call it "lath") as a node. Since you'd need to traverse a link to get to any subsequent "lath", or point of choice, an edge would then be defined as this traversal, and you get a typical graph. The results then are stored in a simple table, N x N, where N is the number of "laths." Here's the (unavoidable?) drawback. If a typical network for our simulation can have, say, 2000 intersections, it will have somewhere around 6000 links, i.e. N = 3V. Obviously, if counted in terms of intersections (V), we're now up to O(log(3V)*(3V + E)). You might argue that 3 (or 9) is a constant factor, but from the practical standpoint, it does slow things down quite a bit, and increases storage space to 3V x 3V. Does anyone have any idea how we can restructure this to improve performance? Not necessarily any alternative algorithm, perhaps reshape the data structures to fit a graph in some other way?


Would this be considered dependency injection?

Would this be considered dependency injection, or delegation or object collaboration? https://gist.github.com/3428071


Does non-virtual-by-default lead us to composition-over-inheritance?

There are some design guidelines about testable code in “The Art of Unit Testing”. The first one is “Make methods virtual by default”. I’m curious to know your idea about non-virtual-by-default behavior in C#. I’ve read about Hejlsberg opinions but I think one the most important reasons could be that it may lead us to “composition over inheritance” principal. Could “composition over inheritance” be one of those reasons which make non- virtual-by-default preferred over virtual-by-default? **UPDATE** Regarding this subject, please consider test-driven point of view; where we want to write testable code. While we are encouraged to make all members virtual by default (at the mentioned book), we can follow "composition over inheritance" and keep going non-virtual-by-default. Isn't it better?


Google App Engine -- should we use it?

I'm considering using Google App Engine for an online matchmaking (and possibly ranking, not sure) of users in a (currently hypothetical) RTS game. However, I just read this bad review, which has made me nervous. Which problems have they solved (or are planning to solve), which might be an issue for me, and are there any alternatives?


What are the current problems involved in software engineering programming patterns?

can someone suggest me the current problems in software engineering and the research links for it? i have some knowledge on MVVM being a pattern but i would like to know more about others and also current problems as to why people go for the patterns and how they help and what are still current problems involved and the research involved in this field any help is greatly appreciated, Thank you


Strategy while coding

I read in one of the article "45 minutes of coding and 15 min of resting". I started implementing this, Initially for smaller task, I felt very nice, but as tricky and complicated tasks came,I was not able to finish the task in 45 min and it started putting pressure upon me and I stressed out. what would you suggest me on this strategy, Is this good one to apply? or are there any other good ones?


How to evaluate how well one knows functional programming

I've been wondering how to determine if I _know_ functional programming. By know I mean in a Journeyman sense, not a master, but competent enough to do the work. I like languages w/ query/data shaping constructs built in, but is knowing the ins and outs of maps, filters, and aggregates in the form of `Linq`, `Sql`, and `Reactive Extensions` sufficient to claim that one knows functional programming? Or are additional specific concepts and skills required? Edit: I've been working in OO and languages that identify primarily as OO langs for 15 years. As I'm not in an env that is self-identified as functional, there's little to measure against. Is avoiding immutable state and knowing how to use `fold` all there is?


Anyone who has taken 70-515 TS: Web Applications Development with Microsoft .NET Framework 4 exam?

I'm planning to take 70-515 exam and I can't find any training kit for it from MS press at the moment. Therefore, I'm reading the book for 70-562 which covers framework 3.5. I would like to know if someone has taken 70-515 exam and knows if 70-562 training kit can be helpful for the exam 70-515. Are there any resources someone might like to suggest which can help me pass this exam? I would really appreciate any help.


Exception handling class: static or object-oriented?

I am working in a windows service (using VB.Net) for internal use of my department. When ever a certain type of exception (`FooException` for now on) is captured, I follow the same logic:   * Log the exception   * Send an email to someone. In order to reuse code and not to copy-paste the same lines in every `catch FooException` block I have created a `FooExceptionHandler` method inside my `ExceptionHandling` class. So I ended up with a code like this:               FooExceptionHandler(fooException)     {        //log the exception        try        {           //send email        }        catch SmtpException        {           //log  the smtp exception        }     }      My question is about how to organize the code. Should this be a static method? Should all the exception handling class be static? Should it be a singleton? Should it be object-oriented? If the object-oriented case is the best way, should I create a new object in every catch block or is it better to have a class variable?


A question on choosing the next programming language between C/C++ and other languages

I am a java developer (web app and standalone applications) who knows JavaScript, HTML, CSS and has mostly worked on Web applications. I have no knowledge of C/C++ or any other lower level languages. I feel like I should strengthen my CS basics by learning a fundamental language. Should it be C or C++? I am also inclined to learn Objective-C. Does it need basics of C or C++? Or should I go for new languages like Python, Google's Go etc. I know this is a cliche question asked very frequently, but I can use some help here.


Would you use UML if it kept stakeholders from requesting changes frequently?

As much as programmers hate to document their code/system and draw UML (especially, Sequencing, Activity and State machine diagrams) **or other diagramming notation** , would you agree to do it if it kept managers from requesting a "minor change" every couple of weeks? IOW, would you put together visual models to document the system if it helped you demonstrate to managers what the effect of changes are and why it takes so long to implement them? (Edited to help programmers understand what type of answer I'm looking for.) 2nd edit: Restating my question again, "Would you be willing to use some diagramming notation, against your better nature as a programmer, if it helped you manage change requests?" This question isn't asking if there might be something wrong with the process. It's a given that there's something wrong with the process. Would you be willing to do more work to improve it?


Improving ZooKeeper to increase availability

Running Apache ZooKeeper (this applies to PAXOS style system just as well) with 2 members - which is not recommended - does not make sense, because if either   * member1 goes down   * member2 goes down   * there's a network partition between member1 and member2 , ZooKeeper will declare business hours to be over, as there's no single sub cluster with a clear majority of members (in this case: > 1). So running ZooKeeper on 2 members makes it less available than running a single member. Why can't the majority constraint be relaxed so that when the there's a **sub cluster of exactly 50% of members, it is considered the active sub cluster if it contains the eldest member**? (Eldest as of the just before the partition happened, i.e. when the cluster was member-complete) Who's eldest is information ZooKeeper already keeps track of, so implementation looks easy. That way, we don't run into the dreaded split-brain scenario, and the ZooKeeper cluster could stay up in 2 of the 3 cases above, improving availability, especially when running 2 members only. Anything speaking against this?


Algorithm Vs Design

> **Possible Duplicate:**   >  Is it essential to learn algorithms to be a real programmer? This question is, perhaps, related mostly to **web developers** who, like myself, code enterprise applications and use high level languages like **Java, C#** mostly. Due to nature of enterprise web-apps, which essentially do **CRUD** operations, and since we rely heavily on libraries that the language provide, **what is the significance of learning algorithms?** I know the web is filled with articles profoundly stating that "code is algorithm", but when was the last time anyone wrote _quicksort_ algorithm in such an application? I see far more benefits in learning Design patterns and anti-patterns, which are used a lot.


How can I create a set of random numbers based on a total and number of objects?

For example with:   Total population = 400000   Number of villages = 800   The average population is 500 How can I randomize the amount of people in each village using a specified deviation (eg +-50) so that it equals the total population? I came up with a solution using this normal distribution class   Basically I created a normal distribution and used the Probability Density Function to determine the amount of villages at each discrete level (until the population total was hit). This is something I wrote quickly to demonstrate:                NormalDist dist = new NormalDist(500.0, 50.0);      int popX = 500;      int numberOfPopXVillages = Convert.ToInt32(Math.Floor(dist.PDF(popX) * 800)); ;      int totalSum = 0;      do      {          Console.WriteLine(numberOfPopXVillages);          totalSum += popX * numberOfPopXVillages;          totalSum += (1000 - popX) * numberOfPopXVillages;          ++popX;          numberOfPopXVillages = Convert.ToInt32(Math.Floor(dist.PDF(popX) * 800));      } while (numberOfPopXVillages >= 5);      Console.WriteLine(totalSum);      The total sum here is 400000. The algorithm isn't perfect but I'll keep working on it. Thanks everyone.


Sending Whole Data Object As Argument Or Just Required Fields?

Let's say I have a class that just stores data:               ClassData         Field1         Field2         Field3      Now let's say I have a function that uses Field1 and Field2:               public void DoStuff(string field1, string field2){         if(field1 == "something"){              //Do something         }         if(field2 == "somethingElse"){             //Do something else         }     }      vs               public void DoStuff(ClassData data){         if(data.field1 == "something"){              //Do something         }         if(data.field2 == "somethingElse"){             //Do something else         }     }      It seems like this is a type of "more art than science" type thing, but I have a few thoughts also. Passing specific fields shows you the required information right from the get-go, which can make it easier to read and understand the function. Sending just the data object does have advantages because it makes the code look cleaner. I wouldn't be surprised if I'm missing pros and cons for both and would be interested in hearing what you think. Thanks!


Naming convention for classes that represents different versions of the same thing

Let's imagine I have an abstract class named `ProtocolA` that represents the basic operations to work with the protocol **A**. Such protocol is in version 1, but new revisions are expected in the future. Version 2 is coming. How should I name the classes that implements that abstract class for each version? `ProtocolA1` and `ProtocolA2`? Cheers.


what to do with your bin directory

To get off my noob status i am following the Learn python the hard way course. I really like it but at one point it says make a bin directory. In all games and other programs i saw to a bin directory but what does it do?


Avoiding bloated Domain Objects

We're trying to move data from our bloated Service layer into our Domain layer using a DDD approach. We currently have a lot of business logic in our services, which is spread out all over the place and doesn't benefit from inheritance. We have a central Domain class which is the focus of most of our work - a Trade. The Trade object will know how to price itself, how to estimate risk, validate itself, etc. We can then replace conditionals with polymorphism. Eg: SimpleTrade will price itself one way, but ComplexTrade will price itself another. However, we are worried that this will bloat the Trade class(s). It really should be in charge of its own processing but the class size is going to increase exponentially as more features are added. So we have choices:   1. Put processing logic in Trade class. Processing logic is now polymorphic based on the type of the trade, but Trade class is now has multiple responsibilites (pricing, risk, etc) and is large   2. Put processing logic into other class such as TradePricingService. No longer polymorphic with the Trade inheritance tree, but classes are smaller and easier to test.  What would be the suggested approach?


How can I handle Bots in a site that creates a database item every page

I have an eCommerce platform that creates a basket as soon as the user lands on the site if they don't already have one (from session or cookies). It then stores the basket information in session and in cookies to remember what the user has added to their basket for a month. The problem is if they aren't capable of having a session or cookies, such as a bot, then it creates a basket every time they visit a page. This means a bot crawling through the website can easily create hundreds of baskets. One of the options we're exploring is changing our code so that a basket is only created when a user adds an item, and so far it seems the best option, but it's also the most time consuming option as a lot of the code base assumes a basket exists at all times. That would need to be changed so that it checks for a basket and handles a basket not existing. We'd like to find a less intensive solution if possible. Another option we've explored is periodically clearing out the table in the database of all old baskets to help mitigate the issue. However this is just mitigating, and not solving the issue. I'd like to solve the problem if I can. How can I identify if the user is incapable of having a session and cookies so that I can stop the basket from being created? Or is there a better way of dealing with bots in this instance?


Design Issue: Service layer/ trying to maintain RESTful architecture

I'm trying to design a web-application - and after doing a lot of reading on REST + design patterns, I'm at a loss on how to handle my requirements. I think I may be getting caught-up in all the design-patterns, but at the same time want to produce a well-architect-ed design. I have 2 major business-objects, `Customer` and `Order`, with a _Has Many_ relationship. Currently, I have no service layer, and the REST API is in the BL:               GET Customers                         GET Orders     GET Customers/id                      GET Orders/id     POST Customers                        POST Orders     PUT Customers/id                      PUT Orders/id     DELETE Customers/id                   DELETE Orders/id      But things become hard to design when I have to architect for legacy means of user-data input, and well as for the future:   * **Now:** Users upload an **Excel .xlsx** file containing Customer, Order information, which I parse, extract, create `Customer`/`Order` business-objects for, and perform validations. In order to have a pleasant User-experience, I don't save these objects right away, I return them to the User (along with any errors from the verifications) so they may make any needed changes before finally submitting them. (this 2-step submission just adverts the requirement of correcting sources of any validation errors directly in the Excel file).   * **Future:** Customer/Order data will be maintained, and uploaded, through a web service/platform. I don't know how to handle these requirements gracefully, and intelligently. Is this a case where I need to expose a Service Layer that publishes an interface for the soon-to-be-legacy Excel-upload, as well as an interface for the web service? Any design help would be appreciated, as I'm rather new to this type of development and rather not make a major architectural mistake that will come back to bite me later.. Thanks in advance. **edited as comments suggest**


A new i/o library: a good idea or a really bad one?

For a long time I worked almost exclusively with input/output streams in java. However a few years ago I started exploring async I/O as well (e.g. running on jboss netty). However when working in the async I/O world, I could not reuse any of my sync utilities. I also had to start on a rather large library of new I/O utilities and wasn't sure whether to aim for blocking or non-blocking. As things go...I wrote an API on top of the existing I/O which supports both blocking and non-blocking and the utilities are written against that. However because I/O is such a pervasive thing, I am unsure whether it is a wise thing to do. As an example take a Base64 encoder. Yes apache has a sync I/O version and yes java 8 finally has an async encoder. But I needed an encoder that could do both. Same for quoted-printable, deflate,... and of course it should work for sockets (regular & ssl), files,... in single-threaded and multithreaded situations,... I needed utilities to chain together I/O sources, use delimiter-based or fixed-length I/O wrappers,... I needed protocol handlers for http, ftp,... Many of these problems can be expressed in a blocking-neutral fashion or -given enough thought- could support both async and sync, allowing wide reusability. In short: is it wise to introduce an abstraction on top of I/O, forcing basically every library that uses it (directly or indirectly) to use it as well? **UPDATE** At the core are the ReadableByteContainer and WritableByteContainer that -to the discerning eye- will look like a cross between stream I/O and channel I/O.               public interface ReadableByteContainer extends Closeable {         public int read(byte [] bytes);         public int read(byte [] bytes, int offset, int length);     }          public interface WritableByteContainer extends Closeable {         public int write(byte [] bytes);         public int write(byte [] bytes, int offset, int length);         public void flush();     }      One of the utils built on it is the "Transcoder" api:               public interface ByteTranscoder {         public void transcode(ReadableByteContainer in, WritableByteContainer out);         public void flush(WritableByteContainer out);     }      which allows you to do something like:               ByteContainer container = IOUtils.newByteContainer();     container = IOUtils.wrap(         container,         TranscoderUtils.wrapOutput(container, new Base64Encoder())     );     container.write("test".getBytes());     System.out.println(new String(IOUtils.toBytes(container)));      This code will output the base64 encoded bytes of "test". The thing is, the Base64Encoder is capable of encoding the data in an asynchronous manner, it won't block if the output container reports that no data was written nor will it block if the input container reports that no data is available. You can continue the transcoding by calling "transcode()" again. This works both in a jboss netty context where you get the content piece by asynchronous piece and in the streaming world where everything blocks until it can read/write.


Client-server application design issue

I have a collection of clients on server's side. And there are some objects that need to work with that collection - adding and removing clients, sending message to them, updating connection settings and so on. They should perform these actions simultaneously, so mutex or another synchronization primitive is required. I want to share one instance of collection between these objects, but all of them require access to private fields of collection. I hope that code sample makes it more clear[C++]:               class Collection     {         std::vector< Client* > clients;         Mutex mLock;         ...     }          class ClientNotifier     {         void sendMessage()         {              mLock.lock();              // loop over clients and send message to each of them         }     }          class ConnectionSettingsUpdater     {         void changeSettings( const std::string& name )         {             mLock.lock();             // if client with this name is inside collection, change its settings         }     }      As you can see, all these classes require direct access to Collection's private fields. Can you give me an advice about how to implement such behaviour correctly, i.e. keeping Collection's interface simple without it knowing about its users?


How can I move a library inside a project's source tree and compiling static binaries? I want to use a particular tool that utilizes ANCIENT binaries without upgrading it's API usage. This way I can use the old libraries inside the single binary without wrecking the local host environment. I am on nix with netbeans/eclipse/code::blocks. I don't have a problem reading, just looking for a starting point. Any thoughts?


Using an AGPL 3.0-licensed library for extra functionality in an iOS app

I am building an iOS application, and I am planning to incorporate an AGPL 3.0-licensed library to it to provide some _extra (non-essential) functionality_. I’ve got a couple of questions regarding this:   1. Do I understand it right that this still obliges me to publish the source of my app open? If yes, does it have to be open to the general public, or only to those who have downloaded the app?   2. Does this allow me to distribute the app for a fee?


How is encapsulation used for safety?

I am learning OOP. I have studied much about encapsulation but the more I read the more I became confused. I understand we hide (by making private) data and expose it to user of class (other developers) as properties or methods. I also understand by encapsulation we hide details. In an article (http://www.csharp-station.com/Tutorial/CSharp/lesson19) I read: **Abstract from article** When designing an object, you must think about how others could use it. In a best-case scenario any program using the object would be well designed and the code would never change. However, the reality is that programs do change often and in a team environment many people touch the same code at one time or another. Therefore, it is beneficial to consider what could go wrong as well as the pristine image of how the object _should_ be used. In the case of the BankAccount object, examine the situation where code outside of your object could access a decimal Amount field or a string CustomerName field. At the point of time that the code is written, everything would work well. However, later in the development cycle, you realize that the BankAccount object should keep track of an int CustomerID rather than string CustomerName because you don't want to duplicate relationships between information (or some other valid reason to alter the definition of internal state). Such changes cause a **rippling effect** in your code because it was built to use the BankAccount class, as originally designed (with CustomerName being a string), and you must now change code that accesses that state throughout your entire application. The object-oriented principle of Encapsulation helps avoid such problems, allowing you to hide internal state and abstract access to it though type members such as methods, properties, and indexers. Encapsulation helps you reduce coupling between objects and increases the maintainability of your code. **Question** How will encapsulation help when making changes in code and from its rippling effects. For a data member, if I change its type from int to float, (even if I am exposing this using property) I will need to change variable type where I am using already using this code. Kindly guide me how encapsulation will help with such changes. Thanks for this help and guidance.


Strategies for porting application from Win32 API to GTK+

I have a legacy application written in C, using the raw Win32 API. The general level of abstraction is low and raw dependency on <windows.h> is common. I would like to port this application to GTK+. There are any kind of guidelines or best practices on how to do this? I've previously ported a MFC application to Qt, but the application was very abstracted - it draw it's own set of widgets, for example - and initial porting was very straightforward. I've been thinking at first using Winelib to build a native Linux executable and then trying to slowly refactor it into a GTK+ app. Does some one have best practices or previous experiences to share about this?


What are the best tools to help work with large ant files

I just started working at a company that has a very large ant build file that imports lots of other large/small ant files. Needless to say it's giving me a headache trying to figure out what is going on. What are the best tools out there for:   * Getting some kind of concise answer on what is happening   * Visualizing the various targets   * Seeing performance on tasks Can be multiple tools. Any other tips/suggestions?


Is C a regular language?

Are C or C++ regular languages? If not, under which category do we place the programming languages like C/C++, perl, Python?


Executing ajax calls in setTimeout after set intervals?

We develop an application involving a lot of ajax. Such as showing users notifications, updating what they see via ajax while they are on the web page. This update is due to the actions of other users in the application.   1. In the code base we are generating a query inside setTimeout function of javascript. This makes an ajax call.    2. Every call is a separate query to the database.   3. There are many calls on the same page. So we run queries against the database after 15 seconds, no matter if something changes or not. Will this approach work if we are expecting high traffic?


Does this function do one thing only?

Is the following method considered to be doing one thing only? I'm wondering about that since it takes an optional argument.               public function findErrors($name = null)     {         if ($name) {             return isset($this->errors[$name]) ? $this->errors[$name] : [];         }              return $this->errors ?: [];     }      If not, would it be better / matter to have it separated like the following:               public function findErrors()     {         return $this->errors ?: [];     }          public function findErrorsOf($name)     {         return isset($this->errors[$name]) ? $this->errors[$name] : [];     }


What should my redirect URL be for OAuth2.0 in Azure if my application is a local windows application?

I am setting up OAuth2.0 on Azure. I am at the stage where I have been allowed access to the application and a Code has been returned in my redirect URL. My application is a local windows application. When i type my OAuth endpoint address in the browser with the client ID, i successfully get redirected to my redirect URL, and the AuthCode is attached to the URL. Problem: When I have tried doing webrequests and similar strategies (in my C# code, not the brwoser) using my OAuth2.0 endpoint address, I cant seem to get the REDIRECTED url in my C# code. I have seeing some stuff about changing my redirect URL in azure to localhost and listening for a return, but I feel like that brings more variables into the equation. any advice?


Java-Like 'throws'-information in method signature C#

From Java I know that the signatures of methods that can throw exceptions contain a `throws` block, that contains the Exception(s) that might be thrown.   In C# there is no such thing and it is also not common practice to include such info in the XML-Header.   Is there a generally accepted way of drawing attention to potential exceptions or a place to commonly denote them?


How should compound words be handled when coding? Is there a definitive list of compound words?

**QUESTION:** How should you handle compound words when programming? Are there any good lists available online for developers of generally accepted technology-related compound words? I can see how this is highly ambiguous, so should I just use common-sense? **EXAMPLE:** I would be inclined to do this: _filename_ **NOT** _FileName_ **or** _login_ **NOT** _LogIn_ However, the microsoft documentation indicates that _filename_ is not compound. So I wonder, is there a more definitive source? See also, this english.stackexchange discussion  on _filename_. Under the section "Capitalization Rules for Compound Words and Common Terms" located here: Microsoft .NET Capitalization Conventions only offers a limited introduction into the topic, and leaves it up to the developer to use their intuition with the rest.


Create new variable or make multiple chained calls?

What is the best way to get this attributes, thinking in performance and code quality? Using chained calls:                   name = this.product.getStock().getItems().get(index).getName();         id = this.product.getStock().getItems().get(index).getId();      Creating new variable:                   final item = this.product.getStock().getItems().get(index);         name = item.getName();         it = item.getId();      I prefer the second way, to let the code cleaner. But I would like to see some opinions about it. Thank you!


Books about learning programming with C++ as a first language

> **Possible Duplicate:**   >  Recommended books on C++ Is there a canonical book on learning programming with C++ as a first language? I have toyed with Java and Python but when my laptop broke I couldn't program anymore. That was months ago and between now and then I have decided my real first language should be C++. Now my question is what book I should read. Is there a book out there that is both a good introduction to programming for a first time programmer and recommended for learning C++ as a first language?


Jack of all trades, master of none

I've got a question similar to this one: Is constantly looking for code examples a sign of a bad developer? though not entirely. I got off college 2 years ago and I'm currently struggling with a University study. Most likely I'll have to drop out and start working within the next couple of months. Now here's the pickle. I have no speciality what so ever. When I got out of college I had worked with **C** , **C++** and **Java**. I had had an internship at NEC-Philips and got familiar with **C# (.NET)** and I taught myself how it worked. After college I started working with **PHP, HTML, SQL, MySQL, Javascript** and **Jquery**. I'm currently teaching myself **Ruby on Rails** and thus **Ruby**. At my university I also got familiar with **MATLAB**. As you can see I've got a broad scope of languages and frameworks I'm familiar with, but none I know inside-out. So I guess this kinda applies to me: _"Jack of all trades, master of none."._ I've been looking for jobs and I've noticed that most of them require some years of experience with a certain language and some specifications that apply to that language. My question is: **How do I pick a speciality? And how do I know if I'll actually enjoy it?** As I've worked with loads of languages how would I be able to tell this is right for me? I don't like being tied down to a specific role and I quite like being a generalist. But in order to make more money I would need a specialisation. How would I pick something that goes against my nature? Thanks in advance, Rope.


Self-updating application - philosophy

This is a philosophical question. Given a hypothetical desktop application, and a desire to provide automatic updates (rather than forcing people to go to a website, check for an update, download an update, install), which of the two is more of a "best practice" approach?   1. Like iTunes, it checks to see if there is a new version and prompts the user to download the new version. If so, it downloads a full install executable (in this case, a Windows Installer file (.msi)) that installs the full version (not just an upgrade to the previous version - too much to manage if there are multiple versions out there). So, let's say, it's version 10.1.1 - whether you are installing fresh or upgrading, you use the same file. After it downloads, it instructs the user to close the application and run the install file themselves.   2. Similar to the other one, it checks for a new version and prompts user to download it, but instead of just downloading an executable and prompting the user to run it, it actually runs it for them - shutting down the program they have open, acquiring the necessary security to install files. Issues with #2: many issues around closing down program, since the program can open other programs (Outlook and Excel), or what if the user was in the middle of something. Also around security, you need local administrator access to install, what if you don't have it? In later versions of Windows, you cannot just override the person's security. Issues with #1: some people believe this will be too hard, too much effort for the end-user. I would strongly prefer to go with #1 because it will save 80-120 hours on my project, and is simpler to implement and maintain. However, we have people who feel strongly on all sides. What is a best practice for this sort of thing?


What is the industry term for those "earn credit by affiliates" programs in iPhone/Android/etc games?

In iPhone, Android, and other gaming platforms you can sometimes earn credit by installing other games, going to someones website, even signing up for a credit card. For iPhone, for example, there are entire networks set up for this kind of affiliate marketing. What is the industry term for this?


Licensing a project

Can someone clarify the following things for me ? Let's say I want to build a website and add publicity to it so I can make money out of my work.   I would use Html5 for the interface and C# with ASP.NET for the background programming.   I would use Visual Studio as my IDE and SQL server as a database. This is just an example on the top of my head but I don't know where to start for the licenses. Do I need one :   * For VisualStudio and SQLServer only ?   * For VisualStudio, SQLServer and pay some kind of rights for Asp.net ?   * The whole package.. Both VisualStudio, SQlServer plus rights for Asp.net AND C# ? I know this question is a little vague but I really don't know where to start and the opinion of someone with experience int this might give me just the help I need to get started.


Domain Model Examples Website Similar to Databaseanswers.org

When I was trying to understand database design databaseanswers.org was phenomenal. Now I'm trying to understand the Spring Framework and I'd like to know if there are any sites out there that have domain models already created that I could use as a basis for learning Spring.


How were Fortran's original control structures insufficient?

In my Programming Language Concepts class it was mentioned in passing that Fortran's original control structures were insufficient. It was alluded that they were too similar to machine instructions for the IBM 704. Was this the case? What exactly made them insufficient?


MVC and delegation

I am a beginning iOS programmer and use the Model-View-Controller model as a design pattern: my model doesn't know anything about my view (in order to make it compatible with any view), my view doesn't know anything about my model so they interact via my controller. A very usual way for a view to interact with the controller is through delegation: when the user interacts with the app, my view will notify my controller, which can call some methods of my model and update my view, if necessary. However, would it make sense to also make my controller the delegate of my model? I'm not convinced this is the way to go. It could be handy for my model to notify my controller of some process being finished, for example, or to ask for extra input of the user if it doesn't have enough information to complete the task. The downside of this, though, is that my controller would be the delegate for both my controller and my model, so there wouldn't be really a proper way to notify my model of changes in my view, and vice versa. (correct me if I'm wrong.) Conclusion: I don't really think it's a good idea to to have my controller to be the delegate of my model, but just being the delegate of my view would be fine. Is this the way most MVC models handle? Or is there a way to have the controller be the delegate of both the controller and the model, with proper communication between them? Like I said, I'm a beginner, so I want to do such stuff the right way immediately, rather than spending loads of hours on models that won't work anyway. :)


Is a programmer supposed to be self-sufficient?

At my current workplace, we don't have any testers, the rationale for that from the management being: "if we had testers, you wouldn't test your own code at all". This kind of thinking seems to be detrimental to product quality, as while I do test my own code, there are a lot of things that I will miss just for the fact that I know the system inside out and don't know how to use it "wrong". Black box testing doesn't really work as I subconsciously avoid the pitfalls that a dedicated tester would fall into. A lot of my time goes into fixing bugs that have slid into production code and found by the end user. The system in question is large but is developed solely by me. This has also caused some managemental duties to fall on my lap, such as defining schedules and working on specifications. Should these kind of tasks be my responsibility? I see myself strictly as a programmer and nothing else. And if these are my responsibility, to what extent? When is a project so large that it requires testers? Should a programmer have to refine the specification, worry about management of the project or even provide customer support? ### Note Some might have got the impression that I am against widening my responsibilities - that is not the case, I'm eager to get a role that involves more management duties, but currently it is not in my job description. Until I'm officially employed as such or the additional duties start showing in my paycheck, I'm going to think of myself as 'just' a programmer. Unfortunately, as a junior developer, shifting to managerial duties is not going to happen very soon. Excellent answers so far, keep them coming if you have something to add or personal experiences to share!


Web Crawler for Learning Topics on Wikipedia

When I want to learn a vast topic on Wikipedia, I don't know where to start. For instance say I want to learn about Binary Stars, I then have to know other things linked on that pages and linked pages on all the linked pages and so on for the **specified number of levels**. I want to write a web crawler like HTTracker or something similar, that will display a hierachy of the links on a certain page and the links on those linked pages. **I wish to use as much prewritten code as possible.** Here is an example: **Pretending we are bending the rules by grabbing links from only the first sentence of each page** The example archives and "processes" _two levels deep_ The page is Ternary operation ## The First Level In mathematics a ternary operation is an N-ary operation ## The Second Level ### Under Mathmatics: Mathematics (from Greek μάθημα máthēma, “knowledge, study, learning”) is the abstract study of topics encompassing quantity, structure, space, change and others; it has no generally accepted definition. ### Under N-ary In logic,mathematics, and computer science, the arity i/ˈærɨti/ of a function or operation is the number of arguments or operands that the function takes ### Under Operation In its simplest meaning in mathematics and logic, an operation is an action or procedure which produces a new value from one or more input values ## \------------------------------------------------------------------------- I need some way to determine what order to approach all these wiki pages to learn the concept ( in this case ternary operations )... Following along with this example, one way to show the path to read would a printout flowout like so: ![enter image description here](http://i.stack.imgur.com/1fLex.png) This shows that the first sentence of the Mathematics page doesn't link to the first sentence of pages linked on ternary page two levels deep. (Please tell me how I should explain this ) ---> In other words, the child node of the top pages first sentence, ternary_operation, does not have any child nodes that reference the children of the top pages other children nodes- N-ary and operation. Thus it is safe to read this first. Since N-ary has a link to operations we should read the operation page second and finally read the N-ary page last. Again, **I wish to use as much prewritten code as possible** , and was wondering what language to use and what would be the simplest way to go about doing this if there isn't already something out there?


Banking Applications need Auto save?

We are developing a banking application. It's internal project of the bank. The application has to capture huge data to process. So auto save is recommended approach to capture? How to perform validations in case of auto save? And on jsp unload saving the data is correct approach? Which is best way of saving form data in case of auto save? If any network errors occur, how to handle, mean giving end user the data is not saved? I think it's just a feasible solution. Please suggest me optimal solution.


Writing code vs using drag & drop tools

If you drag & drop, you're letting the editor to build code for you. Surely that means you're not really programming. You're building an application that has no proper code logic, correct? I drag simple controls on a web form in .NET, but surely you cannot rely 100% on building an app that way? Though some tutorial books in .NET have you dragging and dropping all over the place. An example, reading from a database using ASP.NET. You can drop SQL controls onto the markup, or you can program the retrieval in the code behind. I prefer the code behind as you have proper control imho. Thoughts?


How to decide the token expiry time in REST web service

I am working on creating a REST ws exposing few API's. A token is required for each API call. I am confused about the expiry time to be set for the token. Security+Performance wise what is the ideal expiry time for token (if there is one)?


Model-View-Controller: who caches the data?

I am building a GUI to interface an embedded device to a PC host. The GUI provides control over the device parameters and displays some feedback from it. The GUI also has to emulate some of the device functionality and present it to the user. I have been advised to use a Model-View-Controller pattern, so that if the device does not acknowledge some command, the the user knows about the ineffectiveness of his actions. Trouble is, I cannot decide which component(s) should cache data. Example: when a value is printed on the screen, the view clearly has to know it. However, the model also has to know it, as it uses it to calculate other values. Furthermore, the controller also has to know it as, for example, the value change could be proportional to a logarithm of the user action. How do I pull this off properly?


Access Token Verification

I have spent quite a few days reading up on Oauth and token based security measures for REST API's and I am currently looking at implementing an Oauth based authentication approach almost exactly like the one described in this post (OAuth alternative for a 2 party system). From what I understand, the token is to be verified upon each request to the resource server. This means the resource server would need to retrieve the token from a datastore to verify the clients token. Given this would have to happen upon every request I am concerned about the speed implications of hitting a datastore like MySQL or NoSQL upon every request just to verify the token. Is this the standard way to verify tokens by having them stored in a RDBMS or NoSQL database and retrieved upon each request? Or is it a suitable solution to have them cached (baring in mind that we are talking millions of users)?


Why Beta versions have so many bugs?

When I worked in Microsoft on MSE antivirus, we had several stages of pre- release: Alpha, Beta, RC. The biggest difference between these stages were bug fixes. Each time we fixed more bugs, and usually updated some minor features. Apple works in the same way. Look here: http://www.techrepublic.com/article/pro-tip-how-to-create-a-bootable-usb- installer-for-os-x-yosemite/ They released a beta of Yosemite OS, but the beta is full of bugs. Why do these big companies work like this? Isn't it better to release a beta version that was tested very thoroughly but one that just doesn't provide all the features that the final version will provide?


Is it a good idea to use a kitchen-sink server for various services?

My (new) development team is setting up its software development environment. I won't describe the whole scenario, since that's another, much-maligned question. Anyway, we're going to have services such as source control (mercurial), a wiki, an issue tracker, a file/document server, DNS and possibly other things. My question: Is it a good idea to put as many as possible as these on a single 'kitchen-sink' server machine? Or is it better to spread them out as much as money, power and server room space allows? **Notes:**   * I know that some things have to go on a different server, like continuous/periodic building, with a lot of crunching involved. I'm talking about the (theoretically) lighter stuff.   * Our team has 4 people, expected to grow to maybe double that within the next couple of years.    * We're not going to be 'hammering' services, as far as I can tell.   * The expected hardware for the server is a plain vanilla PC, ~ $1,000 at most, maybe with an SSD.


What is the proper way to create a cross-fade effect?

When creating an image slider, using a cross fade is one of more popular effects. Various sliders use differing techniques to create such an effect. Major techniques I've found so far are:   * **Method 1:** Use an overlay and underlay `<div>` and fade in and out each other's `visibility`.    * **Method 2:** Create a `<div>` matching the exact size of the slider during initialization, play with its `z-index` property, and then fade each other. Using `method-1`, it needs creating two unneeded and over exploited block elements most commonly a `div`. First the background property is applied to the underlayed-div then the overlayed-div is faded out and subsequently changed in z-index property to be positioned lower that other one. Using `method-2`, it creates only one extra div and now container's background is changed and the overlay div is faded out. Implementing this effect now limits the transition effect that can be build (but _this is not the question in hand_ ). The reason why I believe this could be better is because extra elements will always have to be added to give the effect. Due to this reason, creating effects like that of `nivo-slider` requires creating 12 to 15+ divs to give the effect. Adding up to number of elements to create the element does not seem to be the right way. Are the methods I mentioned above used so much, because there aren't any other ways? There has to be better ways that to create the cross-fade effect. So my question is simple, _Is there a better way to create this effect?_ If yes, What are they?


How to use DI and DI containers

I am building a small PHP mvc framework (yes, yet another one), mostly for learning purposes, and I am trying to do it the right way, so I'd like to use a DI container, but I am not asking which one to use but rather how to use one. Without going into too much detail, the mvc is divided into modules which have controllers which render views for actions. This is how a request is processed:   * a Main object instantiates a Request object, and a Router, and injects the Request into the Router to figure out which module was called.   * then it instantiates the Module object and sends the Request to that   * the Module creates a ModuleRouter and sends the Request to figure out the controller and action   * it then creates the Controller and the ViewRenderer, and injects the ViewRenderer into the Controller (so that the controller can send data to the view)   * the ViewRenderer needs to know which module, controller and action were called to figure out the path to the view scripts, so the Module has to figure out this and inject it to the ViewRenderer   * the Module then calls the action method on the controller and calls the render method on the ViewRenderer For now, I do not have any DI container set up, but what I do have are a bunch of initX() methods that create the required component if it is not already there. For instance, the Module has the initViewRenderer() method. These init methods get called right before that component is needed, not before, and if the component was already set it will not initialize it. This allows for the components to be switched, but it does not require manually setting them if they are not there. Now, I'd like to do this by implementing a DI container, but still keep the manual configuration to a bare minimum, so if the directory structure and naming convention is followed, everything should work, without even touching the config. If I use the DI container, do I then inject it into everything (the container would inject itself when creating a component), so that other components can use it? When do I register components with the DI? Can a component register other components with the DI during run-time? Do I create a 'common' config and use that? How do I then figure out on the fly which components I need and how they need to be set up? If Main uses Router which uses Request, Main then needs to use the container to get Module (or does the module need to be found and set beforehand? How?) Module uses Router but needs to figure out the settings for the ViewRenderer and the Controller on the fly, not in advance, so my DI container can't be setting those on the Module before the module figures out the controller and action... What if the controller needs some other service? Do I inject the container into every controller? If I start doing that, I might just inject it into everything... Basically I am looking for the best practices when dealing with stuff like this. I know what DI is and what DI containers do, but I am looking for guidance to using them in real life, and not some isolated examples on the net. Sorry for the lengthy post and many thanks in advance. EDIT: after reading a bit more, it seems that injection the container itself into objects and making them use the container to find stuff is actually service location, not dependency injection. So my latest idea is to use factories for the stuff that should be dynamically acquired based on something (like getting controllers based on what the router says), and the container would be injected into the factories where it would be used more like a service locator. The non dynamic components would be registered beforehand, and those components would be built by the container and returned fully operational, with all their dependencies filled. So the flow would look like this:   * get Main from the container, Main is injected with Request, Router and ModuleFactory which uses the container to find modules. This is all pre-configured   * Main uses ModuleFactory to create the Module, injected with ModuleRouter, Request, ControllerFactory and ViewRenderer.   * Module uses ControllerFactory to create a Controller, injected with any service that it depends on, and then the Module calls the action on the controller, and sends the result to the ViewRenderer to render the view. Am I getting anywhere with this?


How can you predict the time it will take for two processes in two different machines in a cluster to communicate?

I am trying to develop a computing application which needs a lot of memory (>500gb). Buying a single machine for that is overly expensive. I can, though, buy ~100 small instances on Digital Ocean or similar, divide the memory in blocks and use TCP to emulate shared memory between the instances. Now, my question is: how can I measure/predict the time it will take for two processes in two different machines like that to share information, in comparison to IPC and shared memory? Are there rules of thumb? I don't want exact values, but knowing more or less how much faster one is would be very helpful in visualising the feasibility of this approach.


Is ICCP certification valuable for a programming career?

In looking at various professional societies the AITP lead me indirectly to the ICCP Certified Computer Programmer certification (and others from the ICCP). I had never heard of this program, but both the AITP and, more significantly to me, ACM have members on the ICCP board. Is anyone familiar with this certification? The webpage isn't confidence inspiring to be honest, but looking at it the program seems aimed at those in the Fortune 1000 internal software world. Anyone ICCP certified in some way? Does it make a positive different for a career in software development?


Example(s) of "A subscript ([ ]) expression that does not evaluate to an array" in C

I think I have never seen a [] that doesn't mean array in C. Background:   I was reading about l-values and r-values here: http://msdn.microsoft.com/en- us/library/bkbs2cds.aspx and there it says so. I am curious.


Reusable VS clean code - where's the balance?

Let's say I have a data model for a blog posts and have two use-cases of that model - getting all blogposts and getting only blogposts which were written by specific author. There are basically two ways how I can realize that. **1st model**               class Articles {              public function getPosts() {             return $this->connection->find()                 ->sort(array('creation_time' => -1));         }              public function getPostsByAuthor( $authorUid ) {             return $this->connection->find(array('author_uid' => $authorUid))                 ->sort(array('creation_time' => -1));         }     }      **1st usage** (presenter/controller)               if ( $GET['author_uid'] ) {         $posts = $articles->getPostsByAuthor($GET['author_uid']);     } else {         $posts = $articles->getPosts();     }      **2nd one**               class Articles {              public function getPosts( $authorUid = NULL ) {             $query = array();                  if( $authorUid !== NULL ) {                 $query = array('author_uid' => $authorUid);             }                  return $this->connection->find($query)                 ->sort(array('creation_time' => -1));         }          }      **2nd usage** (presenter/controller)               $posts = $articles->getPosts( $_GET['author_uid'] );      To sum up (dis)advantages: 1) cleaner code 2) more reusable code Which one do you think is better and why? Is there any kind of compromise between those two?


Generic log analyzer that produces reports

About 600 customers use our application. We have very detailed logs for everything that happens in the application, from changes in the data model, memory and CPU/GPU usage to clicks on the UI elements. We want to be able to parse the logs coming from these customers and analyze them to understand how users use our application and what happens internally in the application. Is there a log analyzer that can produce such reports automatically?


How do you find partners for open source projects?

I've created a few open-source projects in the past, and had some success. The process was generally the following: I'd start alone, create something that works, promote it, and finally (maybe) get some contributions. I have less that to contribute to open-source now, but I still have ideas and can still code :) So I wonder if there is a place or a way to meet people (online), discuss ideas and design, and then start working together on the project? The reason I'm thinking about an online way to do this, with strangers, is that while I do have programmer friends, we only very rarely have the same needs and interests at the same time. It seems to me that it would be easier to find such in match in the online global community. Any insight?


Is a project without license public domain?

If a project has no a license or has unknown authors, is it public domain?


'Situations gone wrong' for web apps

I know there's some decent material floating around relating to more specific areas, but wanted to get some opinions from people who have had bad experiences in the past. I have a project where I can have a say on the design of a B2C web app, which has some external API interfaces. UX is crucial as is speed. Not sure what technology will be used at this stage. In designing this application, I want to make sure obvious features are not left out (i.e. ones that make maintenance/development easier). So can you guys tell me about 'situations gone wrong' that could have been avoided had more consideration taken place? Am looking to gather feedback in general, so don't worry if your example is industry/technology specific - so long as it pertains to web. Thanks for reading, I look forward to your responses!


How to get started with this project?

I recently finished my C++ programming class, and I'll start school in september. There is a limited online Parking spot registration and it always gets filled very quickly. I would like to create a code that will quickly access the page and register for me. The question is, how is this feasible? I guess I could use python, or Javascript, but I have no idea how to go on from my C++ class. What should I learn/do to program this code? EDIT: I posted this question on other forums also and I've been receiving a lot of answers like this: you need to use the library ... Sorry if I'm a noob, but I've never used library and I have trouble understanding it. Is it like #include like the library will give me access to many functions by doing #inlude?


How to determine most challenging test-cases to test any algorithm?

While solving any problem, we write algorithms. Some efficient, some not, some work, some fail. But sometimes we end up writing something which is mostly a success when we do a dry test run, perhaps, the way we frame the test data is prejudiced, but the algorithm fails in some other cases. For some algorithms , the nature of data can be diverse and magnitude large, for example like the problem: > Find the maximum subsequence sum of an array of integers which contains both > positive and negative numbers and return the starting and ending indices > within the array. Can anyone tell me is there any specific and generic thumb rule by which we can design the most stringent of test cases to test the correctness of algorithms like this one ?


How to build MVC Views that work with polymorphic domain model design?

This is more of a "how would you do it" type of question. The application I'm working on is an ASP.NET MVC4 app using Razor syntax. I've got a nice domain model which has a few polymorphic classes, awesome to work with in the code, but I have a few questions regarding the MVC front-end. Views are easy to build for normal classes, but when it comes to the polymorphic ones I'm stuck on deciding how to implement them. The one (ugly) option is to build a page which handles the base type (eg. IContract) and has a bunch of if statements to check if we passed in a IServiceContract or ISupplyContract instance. Not pretty and very nasty to maintain. The other option is to build a view for each of these IContract child classes, breaking DRY principles completely. Don't like doing this for obvious reasons. Another option (also not great) is to split the view into chunks with partials and build partial views for each of the child types that are loaded into the main view for the base type, then deciding to show or hide the partial in a single if statement in the partial. Also messy. I've also been thinking about building a master page with sections for the fields that only occur in subclasses and to build views for each subclass referencing the master page. This looks like the least problematic solution? It will allow for fairly simple maintenance and it doesn't involve code duplication. What are your thoughts? Am I missing something obvious that will make our lives easier? Suggestions?


Resurrecting a 5,000 line test plan that is a decade old

I am currently building a test plan for the system I am working on. The plan is 5,000 lines long and about 10 years old. The structure is like this:               1. test title        precondition: some W needs to be set up, X needs to be completed        action: do some Y        postcondition: message saying Z is displayed     2. ...      What is this type of testing called ? Is it useful ? It isn't automated.. the tests would have to be handed to some unlucky person to run through and then the results would have to be given to development. It doesn't seem efficient. Is it worth modernising this method of testing (removing tests for removed features, updating tests where different postconditions happen, ...) or would a whole different approach be more appropriate ? We plan to start unit tests but the software requires so much work to actually get 'units' to test - there are no units at present ! Thank you.


Industry switch to space technologies

I'm a CS grad and have been programming for past 5 years. I like it. As an experienced programmer I'd like to transition more towards the Space industry. **What skills** do you think a programmer would already have/ need to get to make that transition? Also **why** these particular skills and **how** do you see them relating to the Space industry?


Thinking pragmatically about scalability

I was recently asked as an exercise to design a scalable graph. My first intuition was how to seperate the graph and distribute it (sharding,consistent hashing..etc) Turns out my thinking was on the wrong line, I know what scalability is, but it seems it is a bit hard to think about it pragmatically. What is the pragmatic way of thinking about scalability. I know I need high- availability, replication, fault tolerance, but what are some of the common patterns/paradigms needed to implement these key points?


Why do we need to put private members in headers?

Private variables are a way to hide complexity and implementation details to the user of a class. This is a rather nice feature. But I do not understand why in c++ we need to put them in the header of a class. I see two annoying downsides to this:   * It clutters the header from the user   * It force recompilation of all client libraries whenever the internals are modified Is there a conceptual reason behind this requirement? Is it only to ease the work off the compiler?


Starting point for learning natural language processing in Java

Currently I am a high school student and new to the natural language processing field. I am trying to write a Java program that can provide answers that can be understood by humans to the questions that are in natural language. I have looked at Java documentation and Lynda.com site but I am afraid that I am jumping in further than I can reach. I am learning very quickly so I might be going into the deep end. For example I know that I can use the `split` function for minimal parsing but I am unsure where to move past to get actions that I require and I am not getting in enough hours per day to sit down and read all the vasts amount of information. It would be great if there was an entry point for a student like myself that I can take one section at a time. What would be an ideal starting point in terms of CS topics (and documentation) to get myself immersed in this topic?


Is it Considered Good SQL practice to use GUID to link multiple tables to same Id field?

I want to link several tables to a **many-to-many** (m2m) table. One table would be called **location** and this table would always be on one side of the m2m table. But I will have a list of several tables for example:   * Cards   * Photographs   * Illustrations   * Vectors Would using GUID's between these tables to link it to a single column in another table be considered 'Good Practice'? Will Mysql let me to have it automatically cascade updates and delete? If so, would multiple cascades lead to an issues? ![Diagram example of proposed structure](http://i.stack.imgur.com/BR6LX.jpg) ## UPDATE I've read that GUID (a hex number) Generally takes up more space in a database and slows queries down. However I could still generate 'unique' ids by just having the table initial's as part of the id so that the table card's id would be c0001, and then Illustrations be I001. Regardless of this change, the questions still stands.


What are the advantages of the delegate pattern over the observer pattern?

In the **delegate pattern** , only one object can directly listen to another object's events. In the **observer pattern** , any number of objects can listen to a particular object's events. When designing a class that needs to notify other object(s) of events, why would you ever use the delegate pattern over the observer pattern? I see the observer pattern as more flexible. You may only have one observer now, but a future design may require multiple observers.


Collective term for shaking device and using accelerometer of a device

Does anyone know what the collective term for shaking a device to achieve something or using the accelerometer of a device to do something is? Is it haptic technology?


What math skills are required to learn machine learning?

I am interested in taking this online course on machine learning. As it stands my math is very elementary, and I am basically learning math from scratch on khan academy. Programming-wise I have a decent amount of experience, and a good overall understanding. My question is, what math skills are required for me to be able to effectively understand and utilize machine learning?


How do you handle / what do you charge for documentation, training, warranty, changes in scope etc…

I am working with a client right now that wants me to sign a contact with a warranty for a year for no additional charge. As well as any reasonable changes he wants during the contract that are outside of the guidelines for no additional charge while not affecting deadlines. And lastly documentation and training for all staff for no additional charge. Red flags are going everywhere in this contract and I wanted to hear from professionals how you guys handle / what you charge for documentation, training, warranty, changes in scope etc...


Reducing complexity of our custom framework

At our company, we have a custom software application using our own framework. The framework was built in approximately 2002 or 2003, long before I showed up at the company. Majority of the functions in the framework are solid so we still use them as we've never had any issues with them, I'm talking about the database functions and functions to grab get/post parameters and escape data, etc. It used to be just me working on the projects so I never had any issues with the code-base, however we now have up to 6 developers who started working on the framework recently so things have become more complicated. In our current framework have it set up such as:               /cms/     /cms/modules/     /cms/modules/filemanager/     /cms/modules/filemanager/index.php     /cms/modules/pages/     /cms/modules/pages/index.php     /cms/...      Now inside each index file of each module we have the following:               require_once '../../config.php';     require_once '../../database_functions.php';     require_once '../../url_functions.php';      I am finding it more and more difficult to maintain the changes now and now that certain modules are interacting with other modules it is just getting crazy to maintain this among all of our development team. It used to be very simple but now our page module actually integrates other modules into the main module, into placeholders basically so one can put any content from individual modules into the page. The issue comes when we make a change to our gallery module and now I need to make changes on the front-end (html output), the gallery module itself, the database and then debug all the errors that come about in other modules that are currently using the data from the gallery module. It becomes a chain reaction of changes basically. Does anyone have any suggestions of how to streamline things or a better way to control the maintenance of our application? We are still using a very structured way of coding using straight scripting and functions rather than OOP, as I am used to coding in C and I don't like to complicate anything more than necessary. * * * Aside from these issues, we don't use anything like versions in our software right now, we've distributed great work and clients love the software we give out, we just don't have versions on them and no builds or anything, which is probably a big mistake in itself. Any ideas or suggestions or even a link out to somewhere that can help us figure out how to better structure our development process (if that's an issue) would be greatly appreciated.


Fuzzy search for a sub-string without tokens

Let's say I have the following lines:               Lorem ipsum dolor sit amet, (tag) consectetur adipiscing elit.     Phasellus congue nisi vel lorem dignissim tristique. (tag)     Etiam vulputate lacus nec velit lobortis ut adipiscing mauris condimentum. (tag )     Vestibulum quis nulla id nisi ultricies placerat. (teg)     In tempus vulputate ante, quis suscipit nunc euismod in. (teg )     Phasellus iaculis diam in felis pellentesque tristique. (ta g)     (tag Praesent vestibulum sollicitudin velit, non mollis lacus scelerisque in.     Nunc ac erat enim, at lobortis libero. (interesting)      There's supposed to be a tag in each line enclosed in parenthesis. But as you can see the data is very dirty and there's extra spaces inside tags, missing parents, misspelled tags, etc. How would I identify the lines containing "(tag)" or something similar? The output I would expect in the example is to retrieve all lines, except for the last. I need to compare a long string to a shorter sub-string, so something like Levenshtein distance wont work (or will it?). Tokenized techniques seem to rigid, because although I might tokenize everything in parenthesis, what happens when a parenthesis is missing?


How to make a recurring event? Such as an entry in a agenda

I have an entity (model) called Notification, shown to Users of the system. So far, Notifications were created and showed instantly to users when they were enabled, and hidden when disabled or deleted. Also, Users can close/cancel the Notification so they don't see it anymore and that action is persisted in a collection (database table) of Notifications viewed by Users. The system must now implement repetitions of those Notifications, like agendas or calendars in which entries can be repeated daily, weekly, monthly, etc. and also send a email to the User the day before the Notification instance date. Conceptually how it is implemented? How about calculation of repetition? So far, I've been thinking of persisting three new properties on the Notification entity, one for the type of repetition (daily, weekly, etc.), one for the start date(time) and another for the end date(time) and a new collection (database table) where I save "instances" of those Notifications (not instances like class instance, but a more generic concept of a single occurrence of something), with properties like notification id and start and end date(time) of that instance. That way Notifications themselves wouldn't be presented to Users, but the instances of those Notifications. Then, I thought of a scheduled task (cronjob) that runs couple of times a day, generating instances from Notifications collection calculating when those repetitions should happen and also sending email when calculated instance date is tomorrow. Not sure if this is the best way and I'd like to hear recommendations. I started to implement it that way and so far it seems easy, but I'm about to start with the logic of the scheduled task (the hardest part) and I wonder if it will be very complex to calculate the date of the instances based on repetition specification (daily seems easy, add a day to the date value, but how about each third friday of the month?).


Where can I learn more about Low Level Programming

So First of all, I did Graduate from a University with a B.S. in Computer Science, and while I feel I got a multitude of programming experience.....I really missed out on the SUPER low level stuff. I know C pretty well as well as C++, but I basically know no assembly. I don't really know what things like Stack traces are......and for that matter I don't really understand the Stack, Stack Overflow or Buffer overflow or anything like that. Basically anything on the low end spectrum (which I really need to learn). Also I find Hacking/Cracking interesting (from an Educational point) that utilize these low level things (Like Stack Overflow). Where would I learn about things like this? What would be a good way to start?


How should one handle "free projects"? Should one accept them or not?

Ok, as a software engineer, I feel that my skills are valuable in other contexts, for instance, a friend came to me and asked me to setup a website for her research and I did it for free. At first I thought it would put my name out there and give me something to work with and hone my skills in my spare time... But I couldn't stop thinking that I was wasting my time with an unpaid job. Now, a second friend comes to me with the same story: "Could you do it for me? I will put your name there, you know, it will get tons of views... Yadda Yadda..." How do you handle this? Do you charge for services in your spare time, even if we are talking about friends? If so, how would you charge for it, for instance, as a consultant?


Which code snippet would you rather come across?

I was just taking a look at CodeIgniters encryption class and found the following function:               function sha1($str)     {         if ( ! function_exists('sha1'))         {             if ( ! function_exists('mhash'))             {                 // use CI implementation                 require_once(BASEPATH.'libraries/Sha1'.EXT);                 $SH = new CI_SHA;                 return $SH->generate($str);             }             else             {                 // use alternate built in function                 return bin2hex(mhash(MHASH_SHA1, $str));             }         }         else         {             // use built in function             return sha1($str);         }     }      If I was writing this function I would do so like this:               function sha1($str)     {         // use built in function         if(function_exists('sha1'))             return sha1($str);              // use alternate built in function         if(function_exists('mhash'))             return bin2hex(mhash(MHASH_SHA1, $str));              // use CI implementation         require_once(BASEPATH.'libraries/Sha1'.EXT);         $SH = new CI_SHA;         return $SH->generate($str);     }      Which is better and why?