Factory method - when objects need information to get initalized

Lets look on a simple example: assume that I have three classes implemeting `IPersonRepository`: `SQLPersonRepository`, `WebPersonRepository`, `InMemoryPersonRepository`. I also have `PersonRepositoryFactory` class which is simple Factory method pattern implementation - contains `GetPersonRepository` methods which have enum/string as parameter. How could I create Factory pattern (or in other words centralize my object creation) when `SQLPersonRepository` needs dependency for: `SQLConnection` or string to database path, `WebPersonRepository` needs some http settings object and `InMemoryPersonRepository` has no dependencies? I could pass it in Factory constructor or as method parameter but it'd be ugly, unclean and unmaintable especially if I had more `IPersonRepository` implementations.


How to practice object oriented programming?

I've always programmed in procedural languages and currently I'm moving towards object orientation. The main problem I've faced is that I can't see a way to practice object orientation in an effective way. I'll explain my point. When I've learned PHP and C it was pretty easy to practice: it was just matter of choosing something and thinking about an algorithm for that thing. In PHP for example, it was matter os sitting down and thinking: "well, just to practice, let me build one application with an administration area where people can add products". This was pretty easy, it was matter of thinking of an algorithm to register some user, to login the user, and to add the products. Combining these with PHP features, it was a good way to practice. Now, in object orientation we have lots of additional things. It's not just a matter of thinking about an algorithm, but analysing requirements deeper, writing use cases, figuring out class diagrams, properties and methods, setting up dependency injection and lots of things. The main point is that in the way I've been learning object orientation it seems that a good design is crucial, while in procedural languages one vague idea was enough. I'm **not** saying that in procedural languages we can write _good_ software without design, just that for sake of practicing it is feasible, while in object orientation it seems not feasible to go without a good design, even for practicing. This seems to be a problem, because if each time I'm going to practice I need to figure out tons of requirements, use cases and so on, it seems to become not a good way to become better at object orientation, because this requires me to have one whole idea for an app everytime I'm going to practice. Because of that, what's a good way to practice object orientation?


How to deal with a misnamed function in production code?

I've recently come across a Python library on GitHub. The library is great, but contains one glaring typo in a function name. Let's call it `dummy_fuction()` while it should be `dummy_function()`. This function is definitely "in the wild" and most likely used in embedded systems. The first thing that springs to mind is to add a second version of the function with the correct name and add a deprecation warning to the first version for the next release. Three questions:   1. Could the approach above have any unintended consequences?   2. Is there a standard approach to this kind of problem?   3. How long should any deprecation warning be left in place?


How to identify a software development framework?

Based on what information, can we identify something as a software development framework? For example the Wikipedia article of 'software framework' claims it should include support programs, compilers, code libraries, etc. But there are some companies I know of which call a code library 'framework'! What should a certain development environment contain to be considered as a 'framework'?


When can you offer innovation without being off-task?

**When can you offer innovation, without being off-task?**   I can't understand how creative innovation fits in Agile and other methodologies. **People just want what they asked for, right?**   Say you're following an efficient methodology like Agile/SCRUM. When can you offer innovation, without being off-task? Say you're making an app and doing some creative stuff with the UX. The client gave you implicit instructions, and you're staying on track. Imagine you discover an innovation that's not a beta. If you introduce innovations the wrong way, you could appear off-task.


Why does PHP have interfaces?

I noticed that as of PHP5, interfaces have been added to the language. However, since PHP is so loosely typed, it seems that most of the benefits of using interfaces is lost. Why is this included in the language?


Putting audit functionality into the database

Our database does not have any audit functionality.   * It does not records who inserts the record or who who changes it   * It does not keep a history of the changes made   * Nothing can be restored if something goes wrong   * There are many other short comings for example the database does not have any data integrity, anything an be thrown in, no check on different fields, duplicates etc My question is, who's job it is to put this functionality in? An ASP Developer who knows basics of SQL and who interacts with the database regularly. Or an SQL Administrator who's sole job is to work with the databases, optimize it and maintain it? At this point we do not have an SQL Administrator, but can hire one. How big of an undertaking this should be for a developer to fix the above issues?


Can you copyright code under 2 separate entities?

I am wondering if it is possible to copyright a piece of software under 2 separate entities, allowing both entities full right do whatever they want with the software while not allowing one of the entities to be able to revoke privileges to the other? Basically I am working on a team, and not getting paid so it is not a paid for hire situation, and I am probably going to be building a web platform system from scratch in C#. I want to be able to make sure that in the event the team breaks up or I kicked off the team that I will still be able to continue work on the web platform system without any legal issues. It is not that I don't trust the team as I do, but life has taught me to always cover my own ass. Would a better way to handle this be to copyright the code under my name and then just give the team a license to use the code however they see fit? I also know that any advice I receive here is most likely not from a lawyer and even if it is, any advice given may not be 100% accurate according to the law.


QR Codes as Booking Confirmations for Conference?

A client of mine is holding a conference and we have the task of creating a booking system for them. However they have requested that we use QR codes so that on the door, a person can simply present their QR code, be scanned, and boom! they are signed in. This isn't so much of a problem because I thought well I could use a long URL to connect to our DB and sign the person in, mark them as booked in/confirmed, and be done with it. That's all very easy, the problem is then that what if the person scan's the QR code themselves? How do ensure that, only the people who are on the door of the conference have the power to scan the barcodes and sign people in? I am limited really to php / jquery, if I knew XCODE I would write an App but I don't. Thoughts I had:   1. Get the IP of the local WIFI, and only accept requests from that (however that does not stop the public from signing in)   2. Use some variable in $_SERVER[] that I could map as coming from a certain person's phone only.


How to organize MVVM files in solution

I'm fairly new to the MVVM concept but like a lot of the flexibility it gives me so far. However, I'm struggling to find a good way to manage my code. I have several classes that are just sitting in a folder in my solution such as `xxxView.cs`, `xxxViewModel.cs`, `yyyView.cs`, `yyyViewModel.cs`, `zzzView.cs`, `zzzViewModel.cs` you get the idea. It has started to crowd my solution, making it harder to find the files I'm looking for. Is there some standard way to organize these files? Do I create a **View** and **ViewModel** folder to separate and clean up the solution or have people found a better way?


What are the challenges related to typing in writing a compiler for a dynamically typed language?

In this talk, Guido van Rossum is talking (27:30) about attempts to write a compiler for Python code, commenting on it saying: > turns out it's not so easy to write a compiler that maintains all the nice > dynamic typing properties and also maintains semantic correctness of your > program, so that it actually does the same thing no matter what kind of > weirdness you do somewhere under the covers and actually runs any faster **What are the (possible) challenges related to typing in writing a compiler for a dynamically typed language like Python?**


Software Design Stability , YAGNI and Agile

I've met the criterion of good system desing as its stability relative to requirements change.   Small req. changes should raise small changes in design.   Yet I have gut feeling that almost for any somewhat complex software system it's possible to state the set of small changes in requirements which causes unacceptable amount of changes in software.   This feeling is based on personal experience though not very great and the fact that schedules are often broken.   Community can argue against this statement in case of strong disagreement. But the question only has meaning if you agree. YAGNI principle works well against overengineering and Agile methodology brings it to the whole process of software development: system evolves incrementally and this perfectly conforms to stability concept which I started this post from.   But... If we however agree that there are some instability points shouldn't we localize this cases to understand the implications from the very beginning? And how is it possible if we designs system in agile incremetnal manner?! P.S. Itneresting part of the dialog with my colleague:   * Nothing is wrong with incremental software development.   * Do you imagine the costs of changing the architecture of Curiosity's firmware after it landed Mars?   * Hey, but the can and changed the firmware!   * Yes, but before that, they had carefully designed this feature. And if not...that would be the point of no return.


Begin and Finish or Pre and Post in async call pair?

In an async call pair you would rather have a BeginDoSomething & FinishDoSomething or PreDoingSomething & PostDoingSomething pair? Cheers


Current iOS version/device statistics?

The answer to this SO question has become stale: iOS version/device statistics - where can i find? because time currency wasn't part of that question, and iOS version updates have been release since this question was asked. Is there a web site or other publicly available source which keeps a current or frequently updated list of the percentages of iOS devices and OS versions in use, perhaps by continual monitoring of app analytics or web site logs or other means? And what device or OS information are iOS app analytics currently allowed to report, if any? (...assuming an appropriate privacy policy and adhering to such, of course.)


iOS version/device statistics - where can I find?

Since I am developing iOS apps I'm trying to find stats on how many iOS devices there are out there. Preferably broken down into versions: Iphone 3G, Iphone 3Gs, Iphone 4 etc. Also I'd like to know the stats on different iOS versions. After an hour of googling I found out that it is not the easiest thing to find. Anyone got some nice bookmarked links to share?


What are the drawbacks of immutable types?

I see myself using more and more immutable types _when the instances of the class are not expected to be changed_. It requires more work (see example below), but makes it easier to use the types in a multithreaded environment. At the same time, I rarely see immutable types in other applications, even when mutability wouldn't benefit anyone. **Question:** Why immutable types are so rarely used in other applications?   * Is this because it's longer to write code for an immutable type,   * Or am I missing something and there are some important drawbacks when using immutable types? ## Example from real life Let's say you get `Weather` from a RESTful API like that:               public Weather FindWeather(string city)     {         // TODO: Load the JSON response from the RESTful API and translate it into an instance         // of the Weather class.     }      What we would generally see is (new lines and comments removed to shorten the code):               public sealed class Weather     {         public City CorrespondingCity { get; set; }         public SkyState Sky { get; set; } // Example: SkyState.Clouds, SkyState.HeavySnow, etc.         public int PrecipitationRisk { get; set; }         public int Temperature { get; set; }     }      On the other hand, I would write it this way, given that getting a `Weather` from the API, then modifying it would be weird: changing `Temperature` or `Sky` wouldn't change the weather in real world, and changing `CorrespondingCity` doesn't make sense neither.               public sealed class Weather     {         private readonly City correspondingCity;         private readonly SkyState sky;         private readonly int precipitationRisk;         private readonly int temperature;              public Weather(City correspondingCity, SkyState sky, int precipitationRisk,             int temperature)         {             this.correspondingCity = correspondingCity;             this.sky = sky;             this.precipitationRisk = precipitationRisk;             this.temperature = temperature;         }              public City CorrespondingCity { get { return this.correspondingCity; } }         public SkyState Sky { get { return this.sky; } }         public int PrecipitationRisk { get { return this.precipitationRisk; } }         public int Temperature { get { return this.temperature; } }     }


Source code of jar.exe - is it available

This may seem an odd question, but I want to create an executable which runs under Windows written in C++. The program needs to be able to update a jar file even if Java is not installed on the target machine. I have seen the src.zip in the Java JDK folder and the jar folder but this is Java code. I assume jar.exe is written in C or C++? Is it possible to see the jar.exe source code? If so where would I find that?


How to go about working as a Contract/Consultant remotely

I currently have a full-time job, but my company is thinking of turning me into a Contract/Consultant due to the fact that I'm now in a different city and have to work remotely. I know usually Contract positions are hired through agencies, in this case since I'll be dealing directly with my company, I told them that I'm only going to charge the same amount as if I were to get a Contract job from an agency, this way I'm still getting a competitive rate, and my company gets to pay a lower rate (no agency to collect a cut). Some background facts:   1. I have a typical team - some are keener's, others not so much, the tech lead/manager try to do their best to achieve deadlines, which means work load is not always spread out evenly, but this is probably true for any team out there.   2. I enjoy my work so far as a software developer, I have a lot of responsibilities and I'm handed meaningful work most of the time.    3. My team members are mostly young, just like me, ideally I'd like to have experienced senior developers/architects on the team to bounce ideas with, but so far that hasn't happened.   4. Our team produces desktop applications written in c#, this means no web applications are involved, I sometimes wonder if this means I'm "pigeon-holed".  Back to the Contract possibility, I have the following concerns:   1. Would this actually be a good career move? (this is my biggest concern) As our HR pointed out to me, such a Contract position can be terminated once they decide that I'm not needed anymore, or if the company needs to cut budget, after which I'll have to look for new work, will "Contract/Consultant" on the resume hurt my job-searching? (I'll be doing more architectural / design work once I'm in this new Contract role)   2. I'll be working remotely most of the time, I wonder if this would hurt or help my growth to be an architect.    3. Should I be a sole proprietor, or should I get incorporated? What would be the advantage of either?    4. There will not be any medical/dental/other benefits (basics are covered by OHIP Canada), should I look into buying private insurance? If so how expensive would it be?   5. My company is looking at putting on restrictions such as: I will not be allowed to work overtime (cannot charge more than the normal # of hours per day), I will need to pay for all expenses (other than equipment) such as travelling and courses <\- I'm fine with the 2nd one, is the 1st one normal for Contract positions to be ask to complete your tasks but without any overtime? Does the above sound familiar to anyone? Any suggestions/advices you can give me on what I should think about / watch out for?


What are some useful things you can do with Mvc Modelbinders?

It occurs to me that the ModelBinder mechanism in ASP MVC               public interface IModelBinder {       object BindModel(System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ModelBindingContext bindingContext);     }      Is insanely powerful. What are some cool uses of this mechanism that you've done/seen? I guess since the concept is similar in other frameworks there's no reason to limit it to Asp Mvc


Have you ever worked at branding your software?

Clearly, if I want my software to attract enough eyeballs I ought to brand it. Unless of course there isn't any competition. I'd like to understand your thoughts on how to go about branding your software.


Why doesn't Google use GWT in most of its applications?

Google created Google Web Toolkit (GWT) and doesn't use it when building their own web applications. Does this mean GWT is not suitable for building dynamic applications? Or have caching problems? Or have RPC problems? Or are there other concerns that prevent Google from using this technology? `EDIT`: I don't say here that Google don't ever used GWT in any app, but What I am want to say, why they are not using it in a wide range?


How important is working with a team?

I am about to graduate from college with a Masters in computer science. I have a couple of offers that I am considering and to me, the biggest difference between the two jobs comes down to one thing - how important is it for a recent grad to be part of a team of software engineers? Will it help me grow more in terms of a career in software engineering? Will it help me become better software engineer since I can get guidance from the experienced engineers? The first offer is with a small telecom company. I've been interning here for a while and love the people I work with. Also, this is where I live currently and so there is no relocation required. The problem is that I'm pretty much the only software engineer here. Everyone else is either network engineers or system integrators. My goal is to have a career in software development and I am concerned about my opportunity for growth. Mainly, I've been creating internal tools and writing scripts for managing networks. My director says he plans on expanding our software team eventually. Also, not having a software engg team means that stack overflow is pretty much my mentor, not that that's a bad thing. The second offer is actually with a top tech company. Pluses with this offer is that I will be part of a team of software engineers and hope that I will have the opportunity to learn a lot from them. I'm not really sure if that's what will happen since I've never worked in a software engg team outside of college. Cons of this job are:   * have to relocate more than 1600 miles away   * northwest, so not exactly pleasant weather year round. I'm from Texas   * I liked the manager and the other interviewers but no guarantee that I will like the team   * pay including benefits are somewhat lower than at small company What do you think? Please help me out. Thanks.


What features contributed to the evolution of Pascal?

I am compiling a detailed history of the Pascal language, and there are a few details I am missing. There are so many features today that we take for granted. What features significantly contributed to the evolution of Pascal, and why were they significant? I'm looking for language features, not platform or framework features. So like operator overloading or default parameters, but not Linux support or new Rich Text widget. I know there are a few different flavors of Pascal (Delphi, Free Pascal, Oxygene, Quick Pascal, Apple Pascal, etc.) and they introduced the same features at different times and in parallel. That is OK. I'm looking at the Pascal language as whole, and **_when_** the significant milestones occurred (dates, versions, etc.)


Looking for a real-world example illustrating that composition can be superior to inheritance

I watched a bunch of lectures on Clojure and functional programming by Rich Hickey as well as some of the SICP lectures, and I am sold on many concepts of functional programming. I incorporated some of them into my C# code at a previous job, and luckily it was easy to write C# code in a more functional style. At my new job we use Python and **multiple** inheritance is all the rage. My co-workers are very smart but they have to produce code fast given the nature of the company. I am learning both the tools and the codebase, but the architecture itself slows me down as well. I have not written the existing class hierarchy (neither would I be able to remember everything about it), and so, when I started adding a fairly small feature, I realized that I had to read a lot of code in the process. At the surface the code is neatly organized and split into small functions/methods and not copy-paste-repetitive, but the flip side of being not repetitive is that there is some magic functionality hidden somewhere in the hierarchy chain that magically glues things together and does work on my behalf, but it is very hard to find and follow. I had to fire up a profiler and run it through several examples and plot the execution graph as well as step through a debugger a few times, search the code for some substring and just read pages at the time. I am pretty sure that once I am done, my resulting code will be short and neatly organized, and yet not very readable. What I write feels declarative, as if I was writing an XML file that drives some other magic engine, except that there is no clear documentation on what the XML should look like and what the engine does except for the existing examples that I can read as well as the source code for the 'engine'. There has got to be a better way. IMO using composition over inheritance can help quite a bit. That way the computation will be linear rather than jumping all over the hierarchy tree. Whenever the functionality does not quite fit into an inheritance model, it will need to be mangled to fit in, or the entire inheritance hierarchy will need to be refactored/rebalanced, sort of like an unbalanced binary tree needs reshuffling from time to time in order to improve the average seek time. As I mentioned before, my co-workers are very smart; they just have been doing things a certain way and probably have an ability to hold a lot of unrelated crap in their head at once. I want to convince them to give composition and functional as opposed to OOP approach a try. To do that, I need to find some very good material. I do not think that a SCIP lecture or one by Rich Hickey will do - I am afraid it will be flagged down as too academic. Then, simple examples of Dog and Frog and AddressBook classes do not really connivence one way or the other - they show how inheritance can be converted to composition but not why it is truly and objectively better. What I am looking for is some real-world example of code that has been written with a lot of inheritance, then hit a wall and re-written in a different style that uses composition. Perhaps there is a blog or a chapter. I am looking for something that can summarize and illustrate the sort of pain that I am going through. I already have been throwing the phrase "composition over inheritance" around, but it was not received as enthusiastically as I had hoped. I do not want to be perceived as a new guy who likes to complain and bash existing code while looking for a perfect approach while not contributing fast enough. At the same time, my gut is convinced that inheritance is often the instrument of evil and I want to show a better way in a near future. Have you stumbled upon any great resources that can help me?


Assuring Quality and Bug Fix speed in Open Source Python Project

I'm maintaining an open source framework (in Python on *nix platforms if that matters) for the first time in my life. It is pretty much pre-alpha, not much more then a scientific proof of concept, yet. But it is also already used in production by another department because it is the only framework globally that approaches their needs. Now there are two anti polar goals: quality and development speed. Of course I want quality in form of documentation, unit tests, code reviews and some kind of "beta" usage, before I am confident to let a change be used in production. But the development team has dead lines and when they find a bug, which happens rather often in this prototype, then they need the bug fix to be in production very fast. I have currently no working solutions and our ideas diverge. I think this project can't be the only one with that problem. How do other projects solve this? I'm going to post my idea and the dev teams idea as answers for further discussions, both ways are not a solution though, because my idea basically only focusses on quality and their solution only focusses on speed.


How do I view Scala code without all the syntactic sugar?

I have been studying Scala, but what I keep running into is the optimization of syntax. I'm sure that will be great when I am an expert, but until then.. Not so much. Is there a command or a program that that would add back in all/most of the code that was optimized away? Then I would be able to read the examples, for example.


What is "Semantics visibility"?

I'm reading 97 Things Every Programmer Should Know, now I'm positioned in "Apply Functional Programming Principles", and there is a paragraph that says: > ...A leading cause of defects in imperative code is attributable to mutable > variables. Everyone reading this will have investigated why some value is > not as expected in a particular situation. Visibility semantics can help to > mitigate these insidious defects, or at least to drastically narrow down > their location, but their true culprit may in fact be the providence of > designs that employ inordinate mutability... What is the objective of Semantics Visibility in this context? How to apply this approach to solve mutable variables' insidious defects?


Is it worth developing custom shopping cart?

We have handsome library of cakephp modules at my workplace, and we develop custom websites at good pace until the shopping cart comes our way to slow down the process. I have used various ( _Magento, Opencart, Zencart_ ) shopping carts in different project, where we have to merge them with our core cakephp application. Usually very custom requirements make the shopping cart **non-upgradable** and takes **lot of time**. I am thinking to make our own shopping cart ( _quite basic at present, and will we extended as we move on_ ) from scratch so it can adapt the custom requirements easily. Is it worth doing? # UPDATE 24-Aug-11 I continued developing our own shopping cart. Here are my experiences that i want to share with you guys. Benefits   1. New cart is easy to change and extend.   2. It saves time when we have vague or custom requirements, and allow us to directly import modules from our existing code library.   3. No need for dual template implementation for cart & custom website.   4. Single admin panel for our shopping cart & custom website.  Limitations   1. Still not mature enough w.r.t other carts in market.   2. Security concerns. We mostly rely on cakephp security.   3. Lacks functionality Problems faced   1. Developing Shipping/Payment gateways was the real pain. As @davidhaskins pointed out **It saved us significant time which we might have spent hacking standard shopping carts to meet our needs**


Project Dashboards

I'm attempting to create a dashboard so that people not intimately involved with the project can get an indication of project's health. I'm struggling with determining what to put on said dashboard. I think it needs to be brief to be useful, yet complete. The project I'm working on depends on both 3rd party contractors, external hardware and of course my team's effort. Are there any suggestions or guidelines on how to encapsulate it all in a relatively easy manner? Mods, I believe this question falls squarely between _development methodologies_ and _business concerns_ as outlined in the faq. Thank you!


Security in Authentication in single page apps

What's the most secure method of performing authentication in a single paged apps? I'm not talking about any specific client-side or server-side frameworks, but just general guidelines or best practices. All the communications are transfered primarily through sockJS. Also, OAuth is out of the question.


Hash Algorithm Randomness Visualization

I'm curious if anyone here has any idea how the images were generated as shown in this response: Which hashing algorithm is best for uniqueness and speed? Ian posted a very well-received response but I can't seem to understand how he went about making the images. I hate to make a new question dedicated to this, but I can't find any means to ask him more directly. On the other hand, perhaps someone has an alternative perspective. The best I can personally come up with would be to have it almost like a bar graph, which would illustrate how evenly the buckets of the hash table are being generated. I have a working Cocoa program that does this, but it can't generate anything like what he showed there. So the question is two fold I suppose: **A)** How does one truly interpret the data he shows? Is it more than "less whitespace = better"? **B)** How does one generate such an image based on some set of inputs, a hash, and an index? Perhaps I'm misunderstanding entirely, but I really would like to know more about this particular visualization technique. Or maybe I'm mis-applying this to hash tables rather than just hashes in general, but in that case I don't know how it would be "bounded" for the image.


OwnCloud App Licensing

I'm a bit confused about the OwnCloud licensing model. OwnCloud is an AGPL licensed product (at least the open source version is). Does that mean that the only license I can use for an OwnCloud app I write using the API would be AGPL as well? The way I understand it, the AGPL license is so restrictive that no app can be written without it having to be released under the AGPL, which would include custom apps for customers who don't want to spend a small fortune on the OwnCloud Enterprise edition. Somehow that feels wrong, so I might have gotten it all wrong and would be happy if somebody with a clear understanding of this topic could shed some light on this.


Revenue sharing with customer who is unable to pay development fee

I have a potential customer who has an idea for an ipad application but is unable to find sufficient fundings for this. One idea that came up is that I do the work either for free or for a minor fee and then receive a percentage of the income from appstore. How do I decide what percentage is realistic?   How is this affected by the price in appstore and how do I protect myself from the scenario where the customer suddenly decides to offer the app for free?


Have there been disputes when software identifies genders with a boolean?

I remember that in our first programming class with Java, while explaining data types, the following occurred (kinda): > **Professor** : So, what data type would you choose if your program needs to > store the user's gender? > > **Someone** : How about a boolean? You know, true for male and false for > female. > > **Professor** : Sure, that may work, but some people may hesitate about > that. There have been disputes about calling men "true" and women "false" in > the past... > > * _laughter_ * He ended up recommending us to consider chars (like `'m'` and `'f'`) although booleans should be fine. I tried searching a bit if there has been any kind of historical entry regarding a major dispute based on this programming practice with no luck. I'm not asking what data type to use for gender nor if it is fine or not to use booleans. I'm asking if, **historically** , there has been a dispute regarding the usage of booleans to determine the gender in programming because of the apparently "wrong" (I'm not saying it _is_ wrong - I don't care about that) behavior of calling a woman "false" as the professor seemed to suggest. Searching around related questions, the results happen to be only about software efficiency.


codeigniter pagination - how to have multiple sets of pagination links on one view

**Problem** I don't know how to create two sets of pagination links one view. **Background Information** I have a situation where I have parent / child tables that I have to display on the same view - perhaps in two different sections. Each section needs its own set of pagination links. The contents (and therefore, pagination links) in section 2 will change depending on what is selected in the parent section / section 1. The parent is what I call "subcategories" and the child table is "products". SO when the user comes to the first page, all categories are shown. But once they select a specific category, I want to take them to this view that I'm discussing which will show any subcategories... and any products. **Possible Solution** I'm thinking that I need the following methods in my controller:               public function getsubcategories($categoryID)     {         1.  find data yu need to display         2.  set up pagination object         3.  use add_js method to add ajax call to a method "get_products_in_category"              Ajax method to be invoked on document.ready and will return product data.         4.  load view.      }          public function get_products_in_cateogry($categoryID)     {         1. look up products in category         2.  build html to display products.          3.  return string with all html to display product information         ??? can i create another pagination object here???     }      If you have any suggestions on what's wrong with my idea / how I can accomplish this, I'd really appreciate it Thank you. **Edit 1** While waiting for a response, i went ahead and tried a little test... and it doesn't seem to be working. I still have the issue where the pagination links displayed in section 2 actually manipulates the data in section 1. I'm going to move post this question in stackoverflow. Thank you.


Testing all combinations

I need to do some performance measurements inside my application. I want to measure, change some parameters, measure again. There are different algorithms I want to test, and there are various parameters which interact with each other in that the total performance depends on all of the parameters (but the parameters themselves don't influence each other. e.g. if I set x to 5, it will always stay 5 and changing some other parameter won't change x). I think the total number of combinations is quite high, at least enough so that I don't want to manually change everything and test out each possibility by hand. I'm looking for a piece of lightweight piece of software architecture (I dare say a design pattern) that basically enables me to define a set parameter types relevant to an algorithm, the possible values of those types, and that piece of code should then run through all combinations of those types and their values, for each one doing the required stuff (calling some functions to change values, etc.) and then executing the algorithm. Example: An algorithm depends on values x, y and z. x can be either 0 or 1, y can be "hello" or "goodbye", and z can be in the range [0,100]. The solution I'm looking for starts with [0,"hello",0], calls some functions to set the values of those variables, lets the profiling run for some time, then changes to [0,"hello",1], repeat, [0,"hello",2]... etc. This is probably something that people have needed to solve before. How do I solve this elegantly?


Two internships at the same time -- good or bad?

I had no internship a few months ago, so I basically went on a 'resume mailing' spree and emailed a _lot_ of companies that I was interested in working for and that had my line of work. This didn't prove futile until a company accepted me into their internship program but said that I would be working remotely. I had no problem with that, the project was good and I was interested. Now I have another internship at a company that is close to my home and I don't want to miss it at all! I can manage both internships side-by-side. In the day, I will do the internship that is closer to my home and at night (and other times), I can manage the remote internship. My question is -- should I both? I am particularly interested in how two internships at the same time are viewed. Would it look good or bad? PS: Neither is paying me anything, so money is not a factor.


Include GPLv2 licensed data in MIT licensed project

I'd like to include some data from a GPLv2 licensed project in my MIT licensed project. More specifically, I want to use the data from the other project as the training data for my machine learning algorithm and I'd also like to include the trained model in my project. I don't want to include the whole project source code, just those data files. I will not modify them. I also want to have the trained model in my project which I think is derived work? Can I create a folder for those data files, add a copy of the GPLv2 license, make it clear that my project is MIT licensed apart from that folder which contains GPLv2 licensed files? Does the trained model also have to be released under GPLv2? If so, can I also keep it in that folder?


Socket Connection Data Insert

I have been working through a high-performance application where I have identified a bottleneck. The bottleneck is actually when the application must insert messages from a socket, it will record them in a database. The trouble is the speed at which the messages come through are so fast that the application cannot catch up due to poor architectural planning. Clearly, insertion needs to be improved. So here's the question: What is the most optimal format for performing inserts of individual records? I have looked over at this link on high performance inserts revision 4 and found that doing something of this nature would require an extensive restructure in the application compared to its current attempt at concatenating a string together such as this:               INSERT INTO table (col1,col2,col3) VALUES (val1,val2,val3),(val4,val5,val6),(val7,val8,val9)      Does anybody have any have an insight over which is better, **datatable insertion** vs **string concatenation**?


Writing Web "server less" applications

### TL;DR What are the prospects of writing applications which are completely based on a **REST** database server (CouchDB) and web applications which directly access the DB instead of having a web server in between? * * * I recently started looking up some NoSQL databases. MongoDB seems to be a popular choices. I also liked the project. But I personally liked the REST interface of **CouchDB**. So what I wanted to know is if there was the possibility of applications (maybe cached apps in web browser, a chrome extension etc.) which could just just query the database directly with no requirement of a webserver in between. All the computational logic would reside in the client application and the database will do what it does, **CRUD**. Since mostly (I don't know which doesn't) client frameworks support REST quaries, it could be a good way writing applications well optimized for respective framework. These applications though won't be doing complicated computation, but still provide enough functionality which could replace lots of conventional applications. _Are existing resources and projects which would help me move towards writing such applications and also the scope and moving towards developing in this way?_ _Are their any technical/security issues with this?_ * * * This post will help me decide to look into project like CouchDB (and maybe Dive into Erlang later) or stay with the conventional frameworks (like django) and SQL databases. ### Update A specific point of such apps I had in mind is creation of _offline applications_ just by replicating couchdb data on client.


A software design pattern to model runtime-dependent behavior

In a interview I was asked, _Suppose we are going to create a software that runs on both desktop machines and smartphones. Name a software design pattern that could be used to enable the application to create different classes for display at runtime depending on the platform._ I know there are simple solutions to implement this feature in the actual code. For example, in Java I can check the display size and create the suitable class (`MobileDisplay` or `DesktopDisplay` class) for that display. But I don't how this is related to the software design. IMO creating suitable class based on runtime platform is an implementation concern than a software design issue.


REST and RPC in multi-tier API

My team is developing a multi-tier API with scalability and modularity in mind. The public access point of the API is fully REST. However, we are splitting the data access layer as another tier in our architecture and this layer will be on another physical server. We decided that RPC would be a good communication protocol between the public facing API and the private data access layer. We decided to use RPC over REST for the private communication between our tiers because:   * Avoid REST routes duplication between each tier   * Transparency in executing code/functions on different servers    * The communication is private. With good documentation there shouldn't be any problems for the team to understand the communication protocol. My question are:   * Did we miss advantages or disadvantages in the choice of communication protocol for the private communication between tiers?    * What is normally use to communication between tiers in a multi-tier architecture, especially for web APIs?


Is OrientDB document-database? or graph-database?

Some document says OrientDB is document-database, some others talks it's graph-database. What's right?


Solid principles vs YAGNI

When do the SOLID principles become YAGNI? As programmers we make trade-offs all the time, between complexity, maintainability, time to build and so forth. Amongst others, two of the smartest guidelines for making choices are in my mind the SOLID principles and YAGNI. If you don't need it; don't build it, and keep it clean. Now for example, when I watch the dimecast series on SOLID, I see it starts out as a fairly simple program, and ends up as a pretty complex one (end yes complexity is also in the eye of the beholder), but it still makes me wonder: when do SOLID principles turn into something you don't need? All solid principles are ways of working that enable use to make changes at a later stage. But what if the problem to solve is a pretty simple one and it's a throwaway application, then what? Or are the SOLID principles something that always apply? As asked in the comments:   * Solid Principles   * YAGNI


How to keep the trunk stable when tests take a long time?

We have three sets of test suites:   * A "small" suite, taking only a couple of hours to run   * A "medium" suite that takes multiple hours, usually ran every night (nightly)   * A "large" suite that takes a week+ to run We also have a bunch of shorter test suites, but I'm not focusing on them here. The current methodology is to run the small suite before each commit to the trunk. Then, the medium suite runs every night, and if in the morning it turned out it failed, we try to isolate which of yesterday's commits was to blame, rollback that commit and retry the tests. A similar process, only at a weekly instead of nightly frequency, is done for the large suite. Unfortunately, the medium suite does fail pretty frequently. That means that the trunk is often unstable, which is extremely annoying when you want to make modifications and test them. It's annoying because when I check out from the trunk, I cannot know for certain it's stable, and if a test fails I cannot know for certain if it's my fault or not. **My question is, is there some known methodology for handling these kinds of situations in a way which will leave the trunk always in top shape?** e.g. "commit into a special precommit branch which will then periodically update the trunk every time the nightly passes". And does it matter if it's a centralized source control system like SVN or a distributed one like git? By the way I am a junior developer with a limited ability to change things, I'm just trying to understand if there's a way to handle this pain I am experiencing.


JavaScript: Bundle a required, but common, polyfill in my library?

First, here are **a couple of related, but not-quite-the-same** questions:   * Should I include dependencies for which I have the source as projects in my solution?   * Depending on another open source library: copy/paste code or include Now on to **my particular question:** I'm building a small JavaScript library. If run within certain older browsers, part of its functionality will depend on a certain polyfill. For the purposes of an example, let's say this polyfill is the `requestAnimationFrame` polyfill. This polyfill is:   * Well-known: Most JavaScript developers are at least vaguely aware of it.   * Available: Copy-pasteable code snippets of variants of it are all over the place.   * Tiny: It's only a few lines of code, really.   * Endemic: Libraries in the same problem space as mine may have it bundled already. Obviously, if my library were the only library being used in someone's project, and if part of that code could fail without the polyfill in circumstances likely for the developer's audience, it would make sense to bundle the polyfill with the library. But in the JavaScript world, particularly in this library's domain, it's possible that the developer already has the polyfill, and that by bundling it, I could be re-polyfilling `requestAnimationFrame` for the second, third, fourth time over. (This itself isn't really an issue, since most polyfills by their very nature include a pre-check of the namespace. But, I admit, the thought of the _same polyfill_ appearing multiple times in someone's code bothers me like a painting hung slightly crooked.) So what is the sensible thing to do? Include it? Or just leave a note in the documentation that says, "By the way, make sure you have the Polyfill X if you need to support Browser Y"?


Is it legal to distribute a closed source X Window Manager?

I’m doing a thought experiment about making a product on top of Linux. I’m wondering: If you make a custom window manager (akin to KDE, for example) on top of X and you release it, do you have to release it under the GPL (Linux) or MIT (X.org)? Or can you keep it closed source?


Why isn't there a Boolean for x values of a variable?

> **Possible Duplicate:**   >  Would you see any use of a Trilean (True, False, ??) Well first and foremost, I'm not a programmer, I am a civil engineer that does some programming and quite enjoy it. Second and Second most, I'd like to claim rights to this amazing invention and call it TROLLEAN or DASSOUKIEAN. Joking aside, on numerous times I run into variables that can only hold three values (let's cal them True, False, and Other. For example, take a traffic intersection. It could be signalized, unsignalized, or non-controlled (aka no stop signs and no traffic lights). it would be dnice to define `TROLLEAN traffic_light = Other` Other in this case represents non-controlled intersections. Instead I find myself writing a code sequence to define that.


Trying to "combine" similar objects without doing a bazillion comparisons

In this database I have "accesses" - each access can have any number (usually less than 4, sometimes as many as 15) attributes. I also have "tickets" where N users are requesting M accesses, so I've got a sub-ticket table with the NxM "user access requests". Then for the sub-ticket, there is another table with the A attributes for that access (where "A" varies depending on the request). ![enter image description here](http://i.stack.imgur.com/s7QQL.png) So, for example, if I have two users requesting three accesses, and those accesses have 2, 3 and 4 attributes respectively, I have 1 ticket record, 6 sub-tickets records, and 18 sub ticket attribute records. The problem is that I want to quickly group the sub-tickets together, so that when I display them I can find all the ones for one type of access, then all the ones of another type of access, and then the third type of access. I know, each type of access should have been given a unique id somehow, but they weren't, and now it's my burden. I only am allowed to "suggest" database changes, not insist on them. Any suggestions?


Difference between brittle and fragile

When you're discussing a system or a code base, when you use the adjectives 'brittle' or 'fragile' to describe it, what's the difference between those two terms?


What's the protocol for a autoexecuting JQuery plugin?

I have a jQuery Plugin that I use myself which modifies the selected value of select items on a page. In my own code the plugin automatically executes as soon as it is included in the page this code in the plugin file.               jQuery('Document').ready(function(){     jQuery('select').SelectOptions();     });      this automatically executes my plugin on all `select` items on the page. Obviously for people other than myself who might come across this on github I'd like to change this slightly. I still think the idea of auto execute is good but my question is.   1. Don't setup autoexecute at all, let the developer call the code.   2. Call autoexecute on All Select items and let the developer modify the code if he doesnt want that.   3. Autoexecute, but modify my selector called in the plugin js file to modify only select tags with a particular class - such as below .               jQuery('Document').ready(function(){     jQuery('select .selectoptions').SelectOptions();     });      Is there any established protocol for this?


How many are too many nested function calls?

Quoted from MSDN about StackOverflowException: > The exception that is thrown when the execution stack overflows because it > contains too many nested method calls. `Too many` is pretty vague here. How do I know when too many is really too many? Thousands of function calls? Millions? I assume that it must be related in some way to the amount of memory in the computer but is it possible to come up with a roughly accurate order of magnitude? I'm concerned about this because I am developping a project which involves a heavy use of recursive structures and recursive function calls. I don't want the application to fail when I start using it for more than just small tests.


Why has the accessor methods from the JavaBean specification become the standard for Java development?

The JavaBeans Specification describes a JavaBean as > A Java Bean is a reusable software component that can be manipulated > visually in a builder tool Since the majority of the lines of code that are written seem to have nothing to do with being manipulated visually in a builder tool, why has the JavaBean specification been the "way" to write object oriented code? I would like to forgo the traditional getter/setter in favor of Fluent Interfaces all throughout the code, not just in builders but fear doing so since this is traditionally not the way way object oriented code is written in Java.


How did you get started with .NET?

I'm interested how programmers got started with learning .NET development. What books and blogs did you read, podcasts or videos did you watch/listened and what other resources did you use to self learn .NET development. I have to mention that while I am new to .NET I'm not new to programming in general. I've used PHP, Python for a while and Java for about 1-2 months.


What are the commonly confused encodings that may result in identical test data?

I'm fixing code that is using ASCIIEncoding in some places and UTF-8 encoding in other functions. Since we aren't using the UTF-8 features, all of our unit tests passed, but I want to create a heightened awareness of encodings that produce similar results and may not be fully tested. I don't want to limit this to just UTF-8 vs ASCII, since I think issue with code that handles ASN.1 fields and other code working with Base64. So, what are the commonly confused encodings that may result in identical test data?


php + web service

Can someone confirm good performance using PHP + Java webservice (for heavy duty tasks) running on NGINX (or Apache) because PHP is slow in completing some heavy tasks and I want to make a web service in java to communicate with PHP via SOAP or REAT or JSON. The fact I'm asking this question is that I already know PHP at a very good level (and Java and I don't want to start learning ASP or Ruby) and HTML5, CSS3 and I want to develop a big portal that will have increased number of requests (1000 / 2000 request/sec) **and I don't want to code the whole application in Java** (cause PHP has more sense), I only need the heavy work to be done by a webservice. **For my project PHP is slow in doing some Math computation and I/O file access every second. It consume a lot of memory and a lot of CPU. At the rate of 1000 req/s it almost crushes.** Is this a good practice? Is there another solution?


Why are several popular programming languages influenced by C?

The Top 10 programming languages, according to the TIOBE index seem to be heavily influenced by C: **1\. Java** > The language derives much of its syntax from C and C++ but has a simpler > object model and fewer low-level facilities. - _wikipedia.org_ **2\. C** > C is one of the most widely used programming languages of all time and there > are very few computer architectures for which a C compiler does not exist. - > _wikipedia.org_ **3\. C#** > During the development of the .NET Framework, the class libraries were > originally written using a managed code compiler system called Simple > Managed C (SMC). In January 1999, Anders Hejlsberg formed a team to build a > new language at the time called Cool, which stood for "C-like Object > Oriented Language". - _wikipedia.org_ **4\. C++** > It was developed by Bjarne Stroustrup starting in 1979 at Bell Labs as an > enhancement to the C language. - _wikipedia.org_ **5\. Objective-C** > Objective-C is a reflective, object-oriented programming language that adds > Smalltalk-style messaging to the C programming language. - _wikipedia.org_ **6\. PHP** > He rewrote these scripts as C programming language Common Gateway Interface > (CGI) binaries, extending them to add the ability to work with Web forms and > to communicate with databases and called this implementation "Personal Home > Page/Forms Interpreter" or PHP/FI. - _wikipedia.org_ **8\. Python** > Python was conceived in the late 1980s and its implementation was started in > December 1989 by Guido van Rossum at CWI in the Netherlands as a successor > to the ABC programming language (itself inspired by SETL) capable of > exception handling and interfacing with the Amoeba operating system. - > _wikipedia.org_ > > ABC (programming language) Its designers claim that ABC programs are > typically around a quarter the size of the equivalent Pascal or C programs, > and more readable. - _wikipedia.org_ **9\. Perl** > Perl borrows features from other programming languages including C, shell > scripting (sh), AWK, and sed. - _wikipedia.org_ **10\. JavaScript** > JavaScript uses syntax influenced by that of C. - _wikipedia.org_ It appears that most of them borrow their syntax from C and / or are heavily influenced in several other ways, at least in their beginnings. Why?


When calling for a random integer from 1-6, how can I make it gradually get less likely to pick a number the bigger it is?

Like having 1 be the most common number and 6 be the least common number. And everything else just leveling out.


GUI architecture and class naming advice

Problem: I'm working on coding a few light-weight touch-tablet games and often get stuck with difficulties naming my user interaction/interface classes and their relationships with each other (architecture?). I'm rarely satisfied with any of my solutions, thus doubt and change them several times on down the line. For example, I have a board game with these components (among others):   * "HUD" - the HUD frames the view of the game world thus enabling user interaction   * "boardOverlay" - this is invisible and lies on top of the viewed game world. It receives and interprets touches, consequently calling methods in "thinger".   * "board" - maintains all elements on the board.   * "thinger" - the class that gets things done, changes game state. I call it thinger since I dont know what it should be called. Better to have a non-descript name than one that will be misinterpreted. Searching for enlightenment: Now I would like to have general/abstract names/architecture for these components which will likely be used in many other games/apps. But I have difficulty coming up with satisfying ones. I have searched the net many a time for guidelines/advice but I find that all of the sources are language/technology/API specific and seldom like their approach. I don't know the name of this discipline/practice to search for for enlightenment. I have tried "event driven framework", "event driven naming conventions", "GUI architecture", "+oop +GUI +taxonomy"... on and on .... .... with no luck. Question1: Can anyone provide a resource to enlighten me? A technology independent resource that philosophizes about this type of naming and architecture. Extra credit question: It would also be great with a reliable/concise resource discussing practices/disciplines of this context? There are too many different and overlapping usages/interpretations out there. Example: GUI framework, GUI architecture, GUI structure, GUI design - what should the proper usage of these terms be?


Overriding - Access to Members with Reference Reassignment

I have recently been moving through a couple of books in order to teach myself Java and have, fortunately, mostly due to luck, encountered very few difficulties. That has just changed. I read a section on the following under inheritance and the whole superclass subclass setup   * When a new superclass object is created, it is, like all objects, assigned a reference (superReference in this example)   * If a new subclass object (with the defining subclass extending the superclass) is created, and then the superReference reference is set to refer to that instead of the original object, it is my understanding that, since the reference is made for a superclass, only members defined by the superclass may be accessed from the subclass. First - is this correct? Second: If I am overriding a method and therefore have one in the super and one in the sub, and I create a superclass object and then assign its reference, as I did above, to a subclass object, by the principle called something like _Dynamic Method Dispatch_ , a called overridden method should default to accessing the subclass method right? Well, my question is: If a reference to a superclass-object is retooled for a subclass-object and will deny direct `object.member` access to subclass-defined members, only supporting superclass-defined members, how can, if a superclass reference is retooled for a subclass object, an overridden method apply to the subclass- object if access is limited by the superclass-originated-reference


If I use locks, can my algorithm still be lock-free?

A common definition of lock-free is that at least one process makes progress. 1 If I have a simple data structure such as a queue, protected by a lock, then one process can always make progress, as one process can acquire the lock, do what it wants, and release it. So does it meet the definition of lock-free? * * * 1 See eg M. Herlihy, V. Luchangco, and M. Moir. Obstruction-free synchronization: Double-ended queues as an example. In Distributed Computing, 2003. "It is lock-free if it ensures only that some thread always makes progress".


What is a hack?

I often hear co-workers saying to each other, "That's a horrible, horrible hack." What I can take away from that is that it's not good. When I asked them if it works they say "yes, but it's not good". Does that mean it's not a good solution? How is a solution bad if it works? Is it due to good practice? Or not maintainable? Is it using a side effect of code as a part of your solution? It's interesting to me when something is classified as a hack. How can you identify it?


mvc pattern on procedural php

First off, I do not have anything against OO programming (I'd be mad if i believed so). But I was thinking on some sort of procedural MVC pattern with PHP; let me explain better. As we all know, variable scopes, unless they are taken from $_SESSION (, database, redis, etc.) are never global and only refer to a singular execution of a script. For example:               class Car {       this->name = "foo";       function setName($name) { ... }       function getName() { return $this->name; }     }      Where obviously in a more common situation, this data will be taken from the DB, otherwise any object car, per execution, would have the same name. Now, is it not possible to apply MVC pattern on procedural code for simplicity purpose? Imagine a really simple social network like application; I could have a structure like this               *views       -profileview.php       -messageview.php       -loginview.php       -notloggedin.php     *models       -user.php       -message.php     - profile.php     - messages.php     - login.php      where profile, messages and login.php work as controllers and route to the right view; and user and message.php work as the classes, that contain all the functions that are eventually needed by the controllers, such as getUserById($id), postMessage($id, $meesage), etc. I have simplified it a lot but I think you can sort of understand my point. What would you think of such implementation on the long run, and why?


Ensuring conceptual integrity in Python project with multiple programmers

One objection that I have _often_ heard raised against Python that it is difficult to synchronize a team of many programmers on large Python project. Note: that synchronization is _possible_ in such a project does not necessarily entail that it is practical, cheap or easy. There's still n*(n-1) communication channels between programmers, so communication cost grows more or less with square of number of programmers, on average. One thing I liked in Java are interfaces. Sadly, both PEP 245 and even modified Guido's version on interfaces ( http://www.artima.com/forums/flat.jsp?forum=106&thread=87182 ) have not been implemented. I was thinking that duck-typing style limited interfaces (no types, just method names) might be very useful, emphatically not for sake of pychecker, faster code, or forcing (dumb) programmers to follow (smart) architect's design, but as means of easy synchronization between 2+ programmers. So, apart from typical but not working very well suggestion of "more documentation" (nobody wants to write it really), what are your means of synchronization high-level design and conceptual integrity on such large, multi-person projects? (in part I ask because large projects I have participated in never used Python) I heard objections mentioned above in person: At least 3 times when talking to startups (2 Scala startups, so they have slant towards static typing) and at least once within corp when considering various programming languages for projects. On the web: can't remember this now, I have vague memory of reading it on some OO blogs and forums. Static typing guys (Java, Scala) seem to have had big on this point, even though typically static typing and interfaces are usually meant for other things (speed, IDE autocompletion). Note I know TDD defense on this but the problem here is that it is defensive since typically it's one person that writes unit tests. Of course, one could envision 1+ programmers sitting down together and writing unit tests before coding as sort of indirect spec + test but have you seen it done? I haven't. I also feel that unit tests, even written by groups, are not quite (limited) design or spec. They are low level after all. There's a reason (good maybe?) that Java has interfaces in addition to and not instead of JUnit.


C# open source projects

What C# project(s) would you consider contributing to if you were a beginner trying to sharpen your skills in C# and .NET framework ? The project should be (besides all) active and not something less active and/or stagnant.


At which architecture level are you running BDD tests (e.g. Cucumber)

I have in the last year gotten quite fond of using SpecFlow (which is a .NET port of Cucumber) I have used it both to test a ASP.NET MVC application at the web layer, i.e. using browser automation, but also at the controller layer. The first gives me a higher confidence in the correctness of the application, because JavaScript is tested, and improper controller configuration is also caught. But those tests are slower to execute, and more complex to implement, than those just testing on the controller layer. My tests are full functional tests, i.e. they exercise all layers of the application, all the way down to the database. So the first thing before any scenario is that the database is cleared of data, allowing the test to assume that only data specified in the "Given" block exists. Then I see example on how to use it, where they test just exercise the model layer. So what are your experiences with these tools? Which layer of the application do you test?


How to architect a P2P application

[Moved here at the suggestion of SO users (10k SO+)] I'd like to develop a peer-to-peer application. While I have a lot of experience in LOB apps, I'm new to the P2P arena. I've got a rough idea of how things should work but need some more details to fill out my understanding. What I know (believe) I need to do:   * A significant proportion of clients need to enable inbound connections (ala uPnP/NAT rules)   * Nodes should share other known nodes to provide resiliency if any particular node goes down   * Some form of synchronisation/route finding is required for sending data between arbitrary clients   * Possibly some resource sniffing to differentiate between "dumb" clients and and more powerful "super nodes" to handle sync/sharing of node lists and maybe relay messages   * Clients without inbound support should hold open an outbound connection through which they can receive info of nodes to connect to In short, I'm hoping to offer (at first) a chat/messenger service which doesn't rely on a connection to any particular central server. While I imagine I'll need to supply a number of centralised "supernodes" to get things started (or after significant upgrades), these should be optional once a functional P2P network has been established. I can see a slew of problems and don't know how to address them. Mainly how to...   * Authenticate users to other nodes without a central authority to verify   * Co-ordinate which nodes know about which other nodes (min-max number/by latency/???)   * Allow a given user to determine if another user (or node) is online   * Deal with a situation where 2 groups of nodes are physically disconnected (airgapped) and how to resync on reconnection of the groups   * Etc etc I know this is a pretty open-ended question, so while high-level design patterns would be appreciated, what I'm really looking for is a decent guide to how others have handled these problems (and the ones I haven't considered yet).


Testing From A Developer's Perspective

I have a book which mentions: > "There are many types of testing, including unit testing, integration > testing, functional testing, system testing, performance testing, and > acceptance testing". It is often noted that many developers carry out unit-testing only, or no testing at all. From the types of testing above, which ones are to be conducted by the developer? What are the responsibilities of a developer when it comes to testing?


Migration from a complex C++ application to C# a -- good idea?

We currently have a complex VC++ software application, which uses a library like ObjectARX to build the dll. I feel there are many features in C# like Collections, Generics, and other libraries which can be used to build the current application in a better and efficient way. I have been thinking about it, but I am not sure on how to present it to my Supervisor and colleagues. I would appreciate any help, to help me think in the right direction and highlight the points to bring it to the team. Few points that I thought was;   1. With some current examples, implementing it in C# with the features.   2. Highlight the development time is comparatively lesser in C# than C++.   3. Use a Design Architecture.


Could it be possible to add the integer type to the ECMAScript standard?

In JavaScript, every number you will ever use will always be represented with what C programmer would call a `double`. The official type is I believe `number`. If I recall correctly, that fact was mentioned by Google as a "fundamental" problem with JavaScript and one of the reason why they wanted to have clean break with Dart. Now, I can't help but wonder :   * Can the ECMAScript standard just add that type? Would it be possible to do without breaking existing code?   * Anyway, can't a JIT engine watch the integer usage and generate code that is almost as efficient as using a native integer type, by using integer registers and opcodes? In effect : Could it be done? _Why should it be done?_


Code Reviews do they really work in true Agile?

So I started working for a large corp., one of those with 3 letters in the name, and they are trying to become Agile, but have tons of processes, which I don't feel are Agile. The one that has me the most wound up are code reviews. My last job was with a startup that I would say is the most Agile development team I have seen, been on, and/or ever heard of. Anyway, my argument is that Code Reviews are a waste of time in iterative or Agile development where the UX/UI is extreme/intense (think Apple/Steve Jobs perfection). Maybe someone here can help understand before they fire me? Here is my development process and the one at my last startup... very Agile. We do the early feature work to sort development task/todos. We would mock a couple versions up and present to users, team, and marketing to get feedback. We then do another mockup iteration to get one round in from the same stakeholders above. Then we divvy up the work and get started. We have milestones and dates to meet, but we keep plugging away. We have no code reviews during any of this. Several times during the weeks of our development we hold sesssions with the stakeholders again to see if they still agree features/functions/UX/UI are still a fit and on target. As we approach the end of the 8 week iteration cycle QA starts testing, then it goes to alpha users, and finally to beta users. But during the alpha and beta developers are going over the new features and older features making iterative daily or hour changes to the UI to improve the UX. So a feature that was being developed this release, might end up being changed 3 more times the last four weeks to improve and perfect it or add a few tiny features (e.g. make the component a little slicker or smarter). Sometimes the changes might be superficial meaning no CRUD operations are changed or modified, but all UI only changes. So with this type of development process, extreme Agile, wouldn't code reviews be a waste of time? Meaning if I had another developer or two review my code, but then that code changes 3 more times before it goes out the door, because of all the UI/UX improvements, are we not wasting our time for first 3 times they reviewed it the code as that code/component/UI was scrapped? We never had many quality issues with this process and yes if a developer left all the knowledge walked out the door, but we always found smart developers to pick it up and takeover. _**And yes, we have a lot of testers because they may have to retest things 3 or 4 times. Also please don't get hung up on asking why all the UI/UX changes...thats just how things are done... been then thats why the app wins tons of awards for UI/UX and the users will kill for the app. The thought process is if I can make a even a 2% improvement in something because I have an extra hour then do it. Users will be happier, which means more $ or users. And yes, our users are ok with the app changing continuously because thats how its been done since day one so they don't see it as bad or a negative._** Hope this post doesn't come off as pompous, but I just can't see how Code Reviews aren't wasteful. Maybe 2% of all our code in the code reviewed has bugs. Each release we might find 3 bugs via code review. So it ends up being 40 hours of code review per developer per release (4 x 40 = 160 hours) to find 3 to 5 bugs? Chances are 50% those 3 to 5 bugs would have been picked up by QA anyway. Wouldn't it be better to spend that 40 hour per developer adding a new feature or improving the existing ones?


The state of localization in web applications

Given that browsers (Chromium/Chrome thus far AFAIK) seem to be introducing embedded site translations and utilities such as Wibiya and given the amount of work that localizing a site can be (depending on framework, view re-writes, database-driven message localization, etc), does it make sense to put in work to localize sites that are intended for an international market anymore? I'm developing such an application solo and I'm wondering if it's _really_ a worthwhile investment at this point and hoping to hear from others who develop internationally targeted large scale applications. I'm not looking so much for opinions (although those are valuable as well) as factual numbers, i.e. the market share that Chromium and Chrome may have compared to other browsers, which browsers offer native localization, etc. Basically, an estimated percentage of users that I may be factoring out of usability without integrating site-driven localization.


Let a model instance choose appropriate view class using category. Is it good design?

Assume I have abstract base model class called MoneySource. And two realizations BankCard and CellularAccount. In MoneysSourceListViewController I want to display a list of them, but with ListItemView different for each MoneySource subclass. What if I define a category on MoneySource               @interface MoneySource (ListItemView)     - (Class)listItemViewClass;      @end      And then override it for each concrete sublcass of MoneySource, returning suitable view class.               @implementation CellularAccount (ListItemView)     - (Class)listItemViewClass     {         return [BankCardListView class];     }     @end          @implementation BankCard (ListItemView)     - (Class)listItemViewClass     {         return [CellularAccountListView class];     }     @end          @implementation MoneySourceListController     - (ListItemView *)listItemViewForMoneySourceAtIndex:(int)index     {         MoneySource *moneySource = [items objectAtIndex:index];         Class viewClass = [moneySource listItemViewClass];         ListItemView *view = [[viewClass alloc] init];         [view setupWithMoneySource:moneySource];         return [view autoreleased];     }     @end      so I can ask model object about its view, not violating MVC principles, and avoiding class introspection or if constructions. Thank you!


design pattern advice: graph -> computation

I have a domain model, persisted in a database, which represents a graph. A graph consists of nodes (e.g. NodeTypeA, NodeTypeB) which are connected via branches. The two generic elements (nodes and branches will have properties). A graph will be sent to a computation engine. To perform computations the engine has to be initialised like so (simplified pseudo code):               Engine Engine = new Engine() ;     Object ID1 = Engine.AddNodeTypeA(TypeA.Property1, TypeA.Property2, …, TypeA.Propertyn);     Object ID2 = Engine.AddNodeTypeB(TypeB.Property1, TypeB.Property2, …, TypeB.Propertyn);     Engine.AddBranch(ID1,ID2);      Finally the computation is performed like this:               Engine.DoSomeComputation();      I am just wondering, if there are any relevant design patterns out there, which help to achieve the above using good design principles. I hope this makes sense. Any feedback would be very much appreciated.


Java heap space

In Java/JVM, why do we call the memory place where Java creates objects as "Heap"? Does it use the Heap Data Structure to create/remove/maintain the objects? As I read in the documentation of Heap data structure, the algorithm compares the objects with existing nodes and places them in such a way that Parent object is "greater" than the children. ( Or "lesser" in case of min heap). So in JVM, how are the objects compared against each other before placing them in the heap?


Difference between TSimpleRWSync's BeginWrite and BeginRead methods?

I have recently switched to TSimpleRWSync from TRTLCriticalSection. The methods BeginRead and BeginWrite confuse me as wherever I read help, they seemingly do the same thing i.e. acquire the critical section whenever it gets relinquished. As the TSimpleRWSync doesn't allow multiple read threads, there is seemingly no point in having two separate methods either. Is there a special difference between them aside from the contextual one?


Name for Osherove's modified singleton pattern?

I'm pretty well sold on the "singletons are evil" line of thought. Nevertheless, there are limited occurrences when you want to limit the creation of an object. Roy Osherove advises, > If you're planning to use a singleton in your design, separate the logic of > the singleton class and the logic that makes it a singleton (the part that > initializes a static variables, for example) into two separate classes. That > way, you can keep the single responsibility principle (SRP) and also have a > way to override singleton logic. ( _The Art of Unit Testing_ 261-262) This pattern still perpetuates the global state. However, it does result in a testable design, so it seems to me to be a good pattern for mitigating the damage of a singleton. However, Osherove does not give a name to this pattern; but naming a pattern, according to the Gang of Four, is important: > Naming a pattern immediately increases our design vocabulary. It lets us > design at a higher level of abstraction. (3) Is there a standard name for this pattern? It seems different enough from a standard singleton to deserve a separate name. _Decoupled Singleton_ , perhaps?


How do I apply a computer science degree to web development?

I'm a web programmer, but I haven't found many opportunities to take advantage of a formal education in computer science. Maybe I'm not looking in the right places, but it seems to me like most of the web jobs I come across are CRUD, web forms, and data grids. For these jobs a formal CS background doesn't seem necessary, and you could do fine with O'Reilly cookbooks in jQuery, CSS 3, PHP, SQL, or ASP.NET MVC. What kinds of web developer jobs exist that really let you apply your computer science background? Do I need to branch out into other areas of programming to take full advantage of my degree?


Options for implementing aggregate message processing

I am developing a web service in java that requires to do an asynchronous call to a 3rd party app by aggregating about 100 requests or for a minute (whichever happens earlier). Is there any open source framework or known design patterns available to help me in this. I have looked at JMS and Spring-Batch. JMS processes each message (and not aggregate) and Spring Batch provides batch execution but also doesn't provide this aggregation support. I can implement my own queue and handler service to make sure I aggregate the results and process it, but I was looking for solutions like JMS which also takes care of persisting the message/data incase of failure and re-using it once system is back up.


Alternative inheritance paradigms in object-oriented design

My apologies if a variation of this question has been asked before, but due to its nature it is hard to search for. I am having a discussion with a colleague about object-oriented design, and it basically comes down to a choice between two different paradigms. What I had been searching Google for was a discussion between these - as I've seen both discussed. **Paradigm A** Have a small number of classes which answer a lot of public methods, many of which are not applicable unless in certain circumstances. In these cases, they throw a runtime exception. _Example: a mathematical vector class can have any number of elements. This class answers 'Cross', but returns an error if it has anything other than 3 elements._ **Paradigm B** A deeper inheritance tree, with methods only appearing where they are applicable. _Example: the mathematical vector class is specialised as a 3D-vector, with only the 3D-vector answering 'Cross'. 3D vectors are a special case as there are many functions relevant to a positional vector alone (Dot, Cross, Distance, AngleTo, etc)._ ~~I'm not actually asking for opinions on the above (although clearly the second is better!) but where can I find a good discussion on this - and similar - design issues. I can find many beginners' discussions/tutorials on the subject, but I haven't had any luck finding the more in-depth articles.~~ * * * Edit: After a prompt from @JohnDibling, I'll rephrase the question (and add another Paradigm on request): **Paradigm C** Lightweight objects with a suite of functions to interpret them, and throw errors if the provided arguments weren't valid. _Example: all vectors only respond to the most basic requests, and a series of functions like Size(vector), Cross(vector) do all of the work. Cross would throw a (runtime) error if an argument of the wrong size is given._ Could anyone give me specific reasons why A or C might be preferable to B, or point me to an article which discusses this issue in depth?


Fowlers Data Access Layer patterns

Fowler talks about a number of design patterns available for the data access layer e.g. Table Data Gateway, Row Data Gateway, Active Record and Data Mapper. In the book it suggests using Data Mapper with Transaction Script and Active Record with Domain Model. This doesn't seem to be logical to me as Transaction Script classes contain business logic and data logic and domain model separates business logic and data logic. Active Record combines business logic and data logic (like Transaction Script rather than domain model) and Data Mapper separates business logic and data logic (like domain model rather than Transaction Script). What am I not understanding here?


Do you think that GAE alone is enough to justify learning Python over Ruby?

Considering the fact that you don't have to get involved in setting up/buying a server or even buying a domain, do you think that fact alone is enough to choose one over the other? I don't necessarily want to work on Google App Engine, I just find it convenient when it comes to hosting/environment/etc. and wondering if that's a good enough reason to learn python. In any case, I'm not looking for a debate between python and ruby but more on Google App Engine and whether its value is enough to dictate the language you should learn.


Getting through a lengthy book?

This may seen like a weird question, but since we're challenged--as engineers --to constantly adapt to changing technologies, we always find ourselves buried in documentation. That said, we also need to consider that time is of the essence because people want their stuff fixed and improved with little hesitation if any. How do you get through lengthy manuals, books/manuals within a short period of time? Take for example: "The Linux Programming Interface," by Michael Kerrisk, which is roughly 1500 pages in length. How would you get through a monster of a book like this if you're pressed for time while still learning most of the material?


Is virtual machine image a good protection for source code?

We have developed an application that is sold as an online service. After some time we realized that some of customers would need/prefer/require to have it installed locally on their intranet. However the application was developed using scripting language and we wouldn't want to allow clients to access the source code. The question is: What are the technical downsides of distributing application as a virtual machine image?


What maths should I learn to become a better computer scientist?

I'm a self taught programmer, and although I know many people feel math isn't necessary, I find that in many examples of algorithms I come across talk about (what sounds to be) some pretty complex mathematics. I would love to eventually have a solid understanding of the math that a good, university educated computer scientist should know. I don't really remember any math past algebra 2. With that being where I left off, what should my starting point be? What math topics should I research, and in what order? I'm looking to build a curriculum for myself that will be pretty easy to take on from where I left off and continually learn until I have a similar understanding to that of what a university would provide.


What are the roles of a Software Delivery Manager

I have been told about a position that may be open to me - the role of a Software Delivery Manager. From what I understand this role does not already exist within my organisation. To be perfectly honest I'm not quite sure what a Software Delivery Manager's roles are. I have a few ideas and would appreciate some input around whether they are correct or not, or if there is anything missing:   * ensure the quality of the software being delivered   * document the relationships between the components being delivered   * ensure that the delivery of these components does not break other components   * ensure that the components being developed make the best use of the environments they are being deployed in   * being on-hand during software deliveries (though not actually performing the delivery of software, rather giving the Go) I have also been told that the role would include some software development work (which is important to me being a developer at heart!) - is there software development specifically associated with the role of Software Delivery Manager or is this more likely to just be a case of helping the team out when time is short?


Why is DRY important?

Quite simple, why would I want to write code that works for all cases and scalable data when all I need to do is repeat the same process a few times with a few minor tweaks? I'm unlikely to need to edit this again any time soon. It looks like a lot of less work to just go...               function doStuff1(){/*.a.*/}     function doStuff2(){/*.b.*/}     function doStuff3(){/*.c.*/}      And if I ever need to add something...               function doStuff4(){/*.d.*/}      And if I need to remove it, I remove it. It's harder to figure out how to make all of those into one straight-forward pattern that I can just feed data into and deal with all the cases, and make a bunch of changes I don't feel like I'm ever going to have to do. Why be DRY when it looks like a quick cut+paste is going to be so much less work?


Moving to Python (SciPy and NumPy) for Scientific Computing

Just read a presentation about using Python for Scientific Computing. I am currently using MATLAB (student license FTW, which will expire when I graduate soon). So I was wondering **how matured SciPy and NumPy are with respect to relying on them for all the Scientific Computing** I need to do. The advantage is that it's free. I am mainly focused on Signal Processing, Audio, Acoustics kind of computing. I can imagine that the NumPy and SciPy projects are evolving with respect to the support for more complex techniques. So, **how fast are they evolving** , are there large communities behind them? Finally, **are there other solutions**?


Python potential for science applications?

I'm a beginner in programming. I am learning Python as a hobby. However, after reading some things in what concerns, for example, its speed, I asked again myself if I should really learn Python or learn other more difficult language. I am in sciences at school, and have interest in physics and microcontrollers, so a performance-wise language would be needed for, for example, computational calculations, and that. So probably a language like C or C++ would be more handy in terms of future university degree. So, my questions are:   * I saw that Python is an interpreted language, therefore slower (up to 100 times from C++, from what I read at Stack Overflow, which is a lot). Can't it be compiled so that no interpreter is needed and it has high speed? (like C is) I mean, it's what the interpreter does, isn't it?   * Does Python have any chance of being useful for science? How could it surpass it's speed lack?   * Isn't there the possibility of writing a program in Python, and translate it to C++ in order to compile? Therefore having the simple writing of Python and the speed of C++? Are there any Python-to-C++ translators?


Do you write Documentation in a language other than English?

A couple of months ago I moved to Germany. Taking some projects on my own, I've recently had the opportunity to develop with a company-based framework, that was very well documented, but in German. My German is pretty good, however my programming terminology is somewhat lacking. Long story short, I was wondering, how common is it to document code in a language other than English? Sorry to seem English-centeric but it seems like a bad habit.


What is a good IDE for client side JavaScript development?

I recently started learning JavaScript and am looking for a good JavaScript Editor/IDE. I found dozens of them in a Google search but I would appreciate if users who have experience with using such an IDE could recommend one. I want an IDE with **syntax highlighting** , possibly **IntelliSense** and **debugging support** for JavaScipt code. I'm a **Windows 7** user and do just **client-side** JavaScript development. Any suggestions??


What is an untriaged bug?

I am an undergrad studying Computer Science. When I tried reporting bugs to several projects, I came across the classification _untriaged_ a lot. A web search didn't really explain what this means. Could you tell me what an untriaged bug is?


Are there any advantages of using separate RDBMS for reports?

My production database is SQL Server 2008 R2 Express. It has limited features and I am testing it in a production environment. To better handle reporting queries in a highly concurrent environment, I want to use any open-source RDBMS with tables that will be acting as temporary tables to frequently fill recent records and delete them after use. The only problem is that I need to keep two connections for each RDBMS, but I feel, Firebird or PostgreSQL can give me better performance of reports in a highly concurrent environment. What are your suggestions? Is this approach used in any commercial scenario?


Is Agile applicable in product development companies as well?

The following principles of Agile development makes it look like Agile is mostly suited for services companies:   * Customer satisfaction by rapid delivery of useful software   * Welcome changing requirements, even late in development   * Working software is delivered frequently (weeks rather than months)   * Working closely with the client. Often this involves a client representative to be a part of the development team.    * Face-to-face conversation is the best form of communication (co-location) My question is: Is Agile exclusively suited for service oriented companies or do even product development companies (including web based companies) benefit from Agile techniques?


How old is "too old"?

I've been told that to be taken seriously as a job applicant, I should drop years of relevant experience off my résumé, remove the year I got my degree, or both. Or not even bother applying, because no one wants to hire programmers older than them.1 Or that I should found a company, not because I want to, or because I have a product I care about, but because that way I can get a job if/when my company is acquired. Or that I should focus more on management jobs (which I've successfully done in the past) because… well, they couldn't really explain this one, except the implication was that over a certain age you're a loser if you're still writing code. But I _like_ writing code. Have you seen this? Is this only a local (Northern California) issue? If you've ever hired programmers:2   * Of the résumés you've received, how old was the eldest applicant?   * What was the age of the oldest person you've interviewed?   * How old (when hired) was the oldest person you hired?      How old is "too old" to employed as a programmer?      1 I'm assuming all applicants have equivalent applicable experience. This isn't about someone with three decades of COBOL applying for a Java guru job.   2 Yes, I know that (at least in the US) you aren't supposed to ask how old an applicant is. In my experience, though, you can get a general idea from a résumé.


I'm questioning my education choice because they say there's no place for old programmers

> **Possible Duplicate:**   >  How old is "too old"? I'm about to start CS next year. I love both the coding and the mathematical aspects of programming. However, recently I encountered multiple rants about how it's impossible to actually be a programmer over 45, unless you're in a managing position or filling a very specific niche. Any advice? I'm seriously questioning my career choice here, and would be grateful for some input.


Can a developer move into a fast-paced career later in life?

> **Possible Duplicate:**   >  How old is "too old"? Most developers I know pushed really hard to get ahead in their careers early on, then maybe slowed down about 10 to 15 years in to marry and raise a family. I didn't. I had a family early in my career, knowing that children were more important to me than my career. I will be in my early 40's when my children are going to college, and it seems that I might be able to take advantage of the lull in my responsibilities and get ahead at a level of experience where so many developers are slowing down to spend more time with their families. However, I'm also wondering if the effort would pay off that late in life. Specifically, I'm concerned about age-ism, especially as a woman in development. Women are affected by age-ism more strongly in most careers, and development seems to be far more biased towards youth than most fields. I also know the women who are in software development are fairly likely to leave the field at ages 35 to 40, although I wonder if that is related to delayed childbearing in this field more than anything. Can an older developer reap the same benefits of intense work that younger developers receive? Or will I automatically be perceived as "stable" and "jaded" at that age, regardless of my interest in moving ahead and investing lots of time into my career once the kids are grown? Would I be better off planning on starting my own business at that time if I want to make a large investment in my career and have it pay off (financially)? ETA: A little clarification: I expect to work between now and then, and grow on the job. So I would be a very senior SDET by that age. I don't expect to have trouble getting a job at that point; my question is more about climbing the ladder to get promotions and pay increases. I see the work the VP of tech does, and it looks fun - but he got to that point by rising quickly early in his career. Can I make the same rise later in my career? Or will I be limited to the rate of growth in position that I achieve in my earlier career?


Is it ever worthwhile using goto?

Goto is almost universally discouraged. Is this statement every worthwhile using?