Good approach for hundreds of comsumers and big files

I have several files (nearly 1GB each) with data. Data is a string line. I need to process each of these files with several hundreds of consumers. Each of these consumers does some processing that differs from others. Consumers do not write anywhere concurrently. They only need input string. After processing they update their local buffers. Consumers can easily be executed in parallel. Important: With one specific file each consumer has to process all lines (without skipping) in correct order (as they appear in file). The order of processing different files doesn't matter. Processing of a single line by one consumer is comparably fast. I expect less than 50 microseconds on Corei5. So now I'm looking for the good approach to this problem. This is going to be be a part of a .NET project, so please let's stick with .NET only (C# is preferable). I know about TPL and DataFlow. I guess that the most relevant would be `BroadcastBlock`. But i think that the problem here is that with each line I'll have to wait for all consumers to finish in order to post the new one. I guess that it would be not very efficient. I think that ideally situation would be something like this:   1. One thread reads from file and writes to the buffer.    2. Each consumer, when it is ready, reads the line from the buffer concurrently and processes it.   3. The entry from the buffer shouldn't be deleted as one consumer reads it. It can be deleted only when all consumers have processed it.   4. TPL schedules consumer threads itself.   5. If one consumer outperforms the others, it shouldn't wait and can read more recent entries from the buffer. Am i right with this kind of approach? Whether yes or not, how can i implement the good solution? I was suggested to move the question here as more appropriate place from StackOverflow. **Update:** According to david.pfx comment here is some detailing. Performance is at the first place, ease of maintenance is at the second.


What should developers know about Windows executable binary file compression?

I'd never heard of this before, so shame on me, but programs like UPX can compress my files by 80% which is totally sweet, but I have no idea what the the disadvantages are in doing this. Or even what the compressor does.   * Website linked above doesn't say anything about dynamically linking DLLs but it mentions about compressing DESCENT 2 and about compressing Netscape 4.06. Also, it doesn't say what the tradeoffs are, only the benefits. If there weren't tradeoffs why wouldn't my linker compress the file? If I have an environment where I have one executable and 20-30 DLL's, some of which are dynamically loaded an unloaded fairly arbitrarily, but not in loops (hopefully), do I take a big hit in processing time decompressing these DLL's when they're used?


What exactly do I have to pay attention for when choosing Windows Hosting Provider?

This is my first time choosing a hosting company. It is for a web site made in asp.net mvc3. So I was thinking choosing a provider would be easy since I found this page http://www.microsoft.com/web/Hosting/Home which contains hosting offers. Now hours later, I am still searching. The reason is that as soon as I start investigating about particular company, something stands out that I do not like. Here are some examples what I noticed when checking various companies in more detail:   * **Company "about us" page is lacking in information about their company.** Few of them had just general description what they do and nothing else, while some others had information like company name but had no address.   * **Checking company name in Business Registry Searches gave no results.** Two of the companies I checked had both company name and address but I was unable to find them in the registry.   * **Putting company domain into Google gave mostly results from that domain or web hosting review sites but not much else.** I am assuming that good companies should have search results from other sites too.   * **Low Alexa Traffic Rank.** There was one company which had a site that looked very professional but their alexa traffic ranking was like 2 million. Are there any other factors I should pay attention to when choosing a hosting company? Do I have legitimate concerns or am I just too paranoid?


Maintenance model for external artifacts

When we think about maintaining a software solution holistically, we have to think about things like non-code change control and configuration management, in addition to the actual source code. For example, for maintaining a large web application, tracing: > "Make the following (manual) configuration change to the farm, as part of > deploying this specific xx.yy.zz version of the solution package." I've implemented a fairly good model for this, but now I'm tackling the next largest problem - how do we manage changes in other systems we don't own? Let's take a simple example: We have an ASP.NET application owned by a solution team (let's call them the PLM Team). Their next release includes a change that requires the SAP team (which is under a different maintenance umbrella) to also deploy a change to one of their BAPI endpoints. Of course the actual coordination of the deployment at release time is simple human interaction & coordination, but in terms of the total SDLC:   * How does our example "PLM Team" package & trace this dependency as an artifact, both as an upcoming change and, post-deployment, a managed dependency with requirements they own but an implementation they do not directly control?   * What is the right information to capture about it? How should it be treated differently than non-code configuration items they do control?


Pattern(s) about hierarchical settings overwriting

Assume that you have a hierarchy of organizational units:               - Company     -- Branches     --- Departments     ---- Teams      Lets say I have some settings (for simplicity assume that they have the same properties) for each level of hierarchy:   * Max nr of documents   * Min something else   * Can do X   * Can do Y   * many other properties So, the sub-units can reuse as default the parents settings, or they have only one or two of these settings modified. Same for their sub-units. What would be the proper pattern to follow - both as code structures, as well as db storage to support that, with the idea that each unit's settings can be modified independently, and sub-unit's settings override the default of the parent. We were thinking about key/value pairs, and then lookup for each one going up the hierarchy until we find the right setting, but this can become ugly pretty fast. Another option we were considering is that each unit has it's own record of the settings, and update accordingly when parent's settings changed. I'd appreciate any suggestion of well known approaches/patterns in that regard.


Is maintaining Heavily Ajax-Based Web Apps more difficult?

Maybe I'm doing it wrong, but in my experience, developing and maintaining heavily ajax-based web apps is much more difficult then a "more standard" web app. I'm not talking about an app that uses ajax to load in some data here and there, but the style where the page the server sends out is just a frame, and all the data is filled in at load time. I'd love to hear from those with experience in developing these types of apps. My personal experience is that they take more hours to both build and maintain.


Where have all the programming kids gone nowadays?

**a bit of background:** I come from an environment where we all started to learn programming with Excel VBA and later VB6 (yeah, VB6 - but we were young and it was great fun these days). So to me, it was a completely natural way of getting started with programming. I later worked in a VB-related programming forum where a major part of the community comprised exactly these young amateur programmers. Now of course, VB is a dying language so we made a transition into .NET languages (C# and VB.NET), **but the number of visitors was (and is) steadily declining.** It's these **young programming kids that we'are lacking** in particular. We could have well attributed this solely to VB, but I looked around in other forums and they all seem to face similar problems. **So my question is** > Where are today's programming kids gone? Is .NET "more professional" in a > way that it attracts fewer junior programmers than the older languages (VBC, > Delphi, Pascal, whatever one used to start with) did? Or is it a broader > phenomenon that we've got fewer "new blood" today? Does anyone have similar (or contrary) experience in this points? Where have the kids gone and which languages are they using (hopefully not all Java/Javascript :D )? Or maybe it's the concept of forums that's on the decline?! I'd just want to _collect some thoughts_ here, and hopefully _hard data_ if it should be available. Thanks


LOOP program only need inc and zero

I have 4 different commands in LOOP programming language:                   y=Zero()         y=Val(x)=copy x and put it in register y         y=Inc(x)=x+1         y=Dec(x)=x-1      Finally I also have                   loop n times {         ...         }      How is it possible that there is an equivalent loop program to every other loop program which uses only Inc, Zero and the loop? For me it is not clear how to express the Dec-command using only Inc, Zero and the loop.


Need help on user story with multiple condition

I have the following user story:   * As a registered user i can request for a new license key with the following condition   * When the user request a license key they required to enter some hardware id Should i create another user story base on this condition? example   * As a registered user i can request a new license key only when hardware id is provided. In a situation when i have multiple condition should i create many user story to fit in the condition? thanks


What is early and late binding?

In many interviews I've been asked this question. I found the following answer: > Early binding refers to assignment of values to variables during design time > whereas late binding refers to assignment of values to variables during run > time. I can't understand it without an example. Can anyone give me one?


Why does DirectX use a left-handed coordinate system?

I considered posting on Stack Overflow, but the question strikes me as being far too subjective since I can't think of a reasonable technical explanation for Microsoft's choice in this matter. But this question has bugged me for so long and the issue keeps coming up in one of my projects, and I have never actually seen an attempt at explaining this: OpenGL uses a right-handed coordinate system, where the +Z part of the world coordinate system extends toward the viewer. DirectX uses a left-handed system where the +Z part of the world coordinate extends _into_ the screen, away from the viewer. I never used the Glide API, so I don't know how it worked, but from what I can gather, it uses a left-handed system as well. Is there a technical reason for this? And if not, is there some conceptual advantage to a particular handedness of a coordinate system? Why would one choose one over the other?


Do SQL Devs create SQL queries using SQL Query Designers?

I was just curious if SQL Devs write their code freehand or do they make use of the visual query designer to generate queries? In the majority of the cases, the query designer can create most of non-complex queries, no? (I'm a WinForms dev just now getting started with SQL Server)


Why C# has no monkeypatching?

I was reading about monkeypatching _ dynamically overriding the functionality of classes. C# allows dynamic extending, but no monkeypatching, which I find reasonable. But I wondered why they wouldn't include the feature. Is it because you could hurt other programs running on your machine, or just the feature wasn't considered necessary?


Are "wrapper" and "shim" synonymous?

Are the words "wrapper" and "shim" more or less synonymous, or is there a distinction, perhaps connotative?


A sample Memento pattern: Is it correct?

Following this query on memento pattern, I have tried to put my understanding to test. > Memento pattern stands for three things: > >   1. Saving state of the "memento" object for its successful retrieval >   2. Saving carefully each valid "state" of the memento >   3. Encapsulating the saved states from the change inducer so that each > state remains unaltered > _**Have I achieved these three with my design?_** _**Problem   _** This is a zero player game where the program is initialized with a particular set up of chess pawns - the knight and queen. Then program then needs to keep adding set of pawns or knights and queens so that each pawn is "safe" for the next one move of every other pawn. The condition is that either both pawns should be placed, or none of them should be placed. The chessboard with the most number of non conflicting knights and queens should be returned. **Implementation** I have 4 classes for this:   1. `protected ChessBoard` (the Memento)              private int [][] ChessBoard;          public void ChessBoard();     protected void SetChessBoard();     protected void GetChessBoard(int);        2. `public Pawn` This is not related to memento. It holds info about the pawns              public enum PawnType: int     {         Empty = 0,         Queen = 1,         Knight = 2,     }     //This returns a value that shown if the pawn can be placed safely     public bool IsSafeToAddPawn(PawnType);        3. `public CareTaker` This corresponds to caretaker of memento This is a double dimentional integer array that keeps a track of all states. The reason for having 2D array is to keep track of how many states are stored and which state is currently active. An example: 0 -2   1 -1   2 0 - This is current state. With second index 0/   3 1 - This state has been saved, but has been undone              private int [][]State;     private ChessBoard [] MChessBoard;          //This gets the chessboard at the position requested and assigns it to originator     public ChessBoard GetChessBoard(int);          //This overwrites the chessboard at given position     public void SetChessBoard(ChessBoard, int);          private int [][]State;        4. `public PlayGame` (This is the originator)              private bool status;     private ChessBoard oChessBoard;          //This sets the state of chessboard at position specified public     SetChessBoard(ChessBoard, int);          //This gets the state of chessboard at position specified public     ChessBoard GetChessBoard(int);          //This function tries to place both the pawns and returns the status of this attempt     public bool PlacePawns(Pawn);      **Edit after discussion with Kevin** The way I am trying to apply design patterns to my problems is not correct. In a way it helps me understand "how" to "implement" it. Yes. But then, this is not its ideal usage. I might as well simplify my "learning" problem and use my text book ones. Also refer to this question on programmers.stackoverflow and all the discussions!


Is prototype.js still relevant?

I'm developing a web application which I started on about 2 years ago. It is an AJAX-heavy single page design and prototype solved problems where I didn't want to reinvent the wheel. I am using a couple of third-party tools that depends on prototype, namely okonet modalbox, protofish tooltips, scriptaculous, My own use of prototype is relegated to simple operations such as reading input values and creating elements. My concern started with the lack of updates for prototype and prima facie evidence on the Internet. If you search for something JScript related jquery is mentioned a lot and prototype hardly at all. Lately it seems that jquery is the toolkit of choice and prototype is stagnating. Should I make the switch to jquery?


Relationship between TDD and Software Architecture/Design

I'm new to TDD and have been reading the theory since applying it is more complicated than it sounds when you're learning by yourself. As far as I know, the objective is to write test cases for each requirement and run the test so it fails (to prevent a false positive). Afterward, you should write the minimum amount of code that can pass the test and move to the next one. That being said, is it true that you get a fast development, but what about the code itself? this theory makes me think you are not considering things like abstraction, delegation of responsibilities, design patterns, architecture and others since you're just writing "the minimum amount of code that can pass the test". I know I'm probably wrong because if this were true, we'd have a lot of crappy developers with poor software architecture and documentation so I'm asking for a guide here, what's the relationship between TDD and Software Architecture/Design?


When should I use a CSS class over inline styling?

I have some hidden divs that I show via JavaScript when a button is clicked. Right now, I'm hiding them with by using inline styling (i.e. `style="display:none;"`). This works, but are there general rules or guidelines to follow to determine if I should use inline styles or styling via stylesheets and class selectors?


the decisive difference between LGPL and AGPL

What is the decisive difference between LGPL(v3) and AGPL(v3) ? Both can be used in commercial production, both can also be packed within a payed product. As long as I do not change the source code of these, I am not forced to enclose the source code with my product. So where lies the eminent difference? (Asked this also at http://stackoverflow.com/questions/10996160/the-decisive- difference-between-lgpl-and-agpl, but a user suggested to ask it here.)


How to organize programming exercise

Due to my bad performance on past job interviews, I decided to perform daily programming exercises out of my work. Currently, I am concentrating on algorithms, design patterns, and unit testing in C++ language platform. But I'd like to have balance over more important areas. So if I may, I'd like to know how other programmers organize their programming exercises.


Risks in giving out distribution cert/private key/provisioning profile to freelancer

Are there any risks in giving out distribution certification/private key/provisioning profile to a freelancer? The freelancer needs to build the binary for me to submit (I am okay with this because I don't own the source code of the app), I just want to know if there is any risk involved in sending the distribution cert/private key/provisioning profile to him? p.s. They don't have the iTunes connect/portal login. Updated: The freelancer will build the binary for me, and I will upload for them.


What do I call a non-MVC pattern?

I am finishing my project and in my thesis I am explaining why I used an **MVC** pattern to build my website, and have stated the advantages of designing it this way. However, if I had **not** used MVC and had built my website from scratch with all the functions for data, processing, and display into each page, what would that have been called in terms of architecture? For example, I would have had one PHP file that has all of the code and functions that it needs. Would it have been called "a standard website architecture"?


How do I manage success as an independent contractor?

I'm fixing bugs for a software company as a contractor on a per hour basis (first time for me). Today, in 6 hours I fixed two issues which had been planned at 32 and 40 hours each. The days before (I've been working here a week or so) the pattern was the same. I didn't plan time to fix those issues, and I didn't know what the issues were before signing the contract. I found a JIRA with all planned hours: some of those issues have been waiting to be worked on for years. I signed a contract for two months, but I'm afraid I'm going to run out of work much sooner.


Evolutions in Agile development field

I recently pull up from under ten inches of dust one of my agile book. The book is now six years old; published in 2008. I prefer to keep it anonymous preventing to create a guerrilla of which one will yielded the best book about this subject. For that, I'm totally able to do a simple search from Amazon or Gooble to find the best book. I seen a couple of books about agile released in the last 2-3 years and I'm wondering if it will be a good investment to buy a more recent book than my old one. I mean, is there any great advancements in the last few years in the world of agile that worth to buy a more recent book? Thank you.


Is my class structure good enough?

So I wanted to try out this challenge on reddit which is mostly about how you structure your data the best you can. I decided to challenge my C++ skills. Here's how I planned this.   * First, there's the **Game** class. It deals with time and is the only class main has access to.   * A game has a **Forest**. For now, this class does not have a lot of things, only a _size_ and a _Factory_. Will be put in better use when it will come to SDL-stuff I guess   * A **Factory** is the thing that deals with the _Game Objects_ (a.k.a. Trees, Lumberjack and Bears). It has a vector of all _GameObjects_ and a queue of _Events_ which will be managed at the end of one month.   * A **GameObject** is an abstract class which can be updated and which can _notify_ the _Event Listener_   * The **EventListener** is a class which handles all the _Events_ of a simulation. It can recieve events from a Game Object and notify the _Factory_ if needed, the latter will manage correctly the event. So, the **Tree** , **Lumberjack** and **Bear** classes all inherits from **GameObject**. And **Sapling** and **Elder Tree** inherits from **Tree**. Finally, an **Event** is defined by an _event_type_ enumeration (LUMBERJACK_MAWED, SAPPLING_EVOLUTION, ...) and an _event_protagonists_ union (a GameObject or a pair of GameObject (who killed who ?)). * * * I was quite happy at first with this because it seems quite logic and flexible. But I ended up questionning this structure. Here's why :   1. I dislike the fact that a **GameObject** need to know about the Factory. Indeed, when a Bear moves somewhere, it needs to know if there's a Lumberjack ! Or it is the Factory which handles places and objects. It would be great if a GameObject could only interact with the EventListener... or maybe it's not that much of a big deal.   2. Wouldn't it be better if I separate the Factory in three vectors ? One for each kind of GameObject. The idea would be to optimize research. If I'm looking do delete a dead lumberjack, I would only have to look in one shorter vector rather than a very long vector.   3. Another problem arises when I want to know if there is any particular object in a given case because I have to look for _all_ the gameObjects and see if they are at the given case. I would tend to think that the other idea would be to use a matrix but then the issue would be that I would have empty cases (and therefore unused space).   4. I don't really know if **Sapling** and **Elder Tree** should inherit from **Tree**. Indeed, a Sapling _is_ a Tree but what about its evolution ? Should I just delete the sapling and say to the factory to create a new Tree at the exact same place ? It doesn't seem natural to me to do so. How could I improve this ?   5. Is the design of an **Event** quite good ? I've never used _unions_ before in C++ but I didn't have any other ideas about what to use. * * * Well, I hope I have been clear enough. Thank you for taking the time to help me !


Where to look for a programming partner?

Say that you want to start a new project (I'm talking about a _serious_ project -- e.g if you had an idea that seems good and profitable -- not about something you start just to learn a new technology or just for your enjoyment) but you don't feel like you can do it alone since, for example, you lack the experience or the technical skills to go through all the phases needed to go from the idea to the final product. Say also that you don't simply want to hire someone. You want someone who can be as passionate as you in the job, that is "proficient" in and enthusiast of the same technologies as you are and that possibly has a background similar to yours (e.g. you both are students, you both come from a prestigious univerity or just you're both Star Trek nerds). So, basically you don't want a person to tell what to do (e.g. "implement this and that, slave!") but someone who can be inspiring and bring something new and important to your project. Someone to go with you from the earliest stage -- from clearly shaping the project's philosophy to drawing mockups etc. Someone who agrees to share the outcome of the project, that strongly believes in the idea behind it and is completely 50-50 with you. Now the question is: how to improve your chances of finding this person (or persons)? Where would you look at first? For example, if you had a lot of funds and were looking for someone to hire, you'd maybe post an ad in SO careers or jobs.73signals; if you already had a team and were looking for funding, you'd start a project on kickstarter or indiegogo, or you'd go to some startup event. But if you had to find a good partner (and programmer, of course) for you're project, where would you start looking? Which strategies would you use?


Cache concurrency: ensuring latest version in cache

We have a data service app working on object graphs. We place some complex graphs in a (memory) caching tier as a single data item, so as to avoid the length of time to retrieve every individual data item in disk storage in order to build the entire hierarchy. That means whenever any of the data items change, a re-cache event is triggered - reloading everything in the hierarchy and storing the newer version to cache. Recently we made tweaks to the service to increase its concurrency of asynchronous operations (mostly network I/O), and observed contention behaviour if multiple incoming requests made updates to items in essentially the same object graph. Each update operation is unaware of other concurrent updates. At the storage persistence level, the infrastructure has timestamps on the data rows; allowing us to apply optimistic concurrency techniques, ensuring nobody is writing an outdated version back to storage. A change in any child object causes the root object to increment a version number, thus the re-cache. During such an event, other concurrent updates may happen for any other child object (or even the same), which makes it difficult to tell what a particular version of the root object is supposed to really have (at point of update time). What is worse, and the main concern here, is that due to concurrent thread contention for processor attention, the caching attempt of an older version can happen _after_ the caching attempt of a newer version. Right now we have minimised this behaviour by verifying that the root object's version during a re-cache event still matches the version saved during its own update operation. If the version number is not the same, it means another concurrent update has since changed it further and the re-cache should not proceed - let the last update operation perform the re-cache. That of course _minimises_ the chances but not _eliminate_ outright; it can still be possible for the root object to retain its original version number on re-fetch, and while re-fetching all the children objects, another update happens and by stroke of (ill) luck manages to complete and re-cache before this ongoing re-caching attempt has completed its round. To further complicate the issue, this data service is deployed as a cluster of servers with no knowledge about each other's siblings. Was wondering if there is any effective way to manage the concurrent updates across multiple threads and servers to ensure the cached copy is indeed always the latest copy?


Is Pre-Order traversal same as Depth First Search?

It seems to me like pre-order traversal and DFS are same as in both the cases we traverse from root till the left branch and back to root and then to the right branch recursively. Could any please correct me if I am wrong? Thanks in advance!


How is precedence determined in C pointers?

I've come across two pointer declarations that I'm having trouble understanding. My understanding of precedence rules goes something like this:               Operator             Precedence             Associativity     (), [ ]                  1                  Left to Right     *, identifier            2                  Right to Left     Data type                3      But even given this, I can't seem to figure out how to evaluate the following examples correctly: ### First example               float * (* (*ptr)(int))(double **,char c)      My evaluation:   1. `*(ptr)`   2. `(int)`   3. `*(*ptr)(int)`   4. `*(*(*ptr)(int))` Then,   1. `double **`   2. `char c` ### Second example               unsigned **( * (*ptr) [5] ) (char const *,int *)        1. `*(ptr)`   2. `[5]`   3. `*(*ptr)[5]`   4. `*(*(*ptr)[5])`   5. `**(*(*ptr)[5])` How _should_ I read them?


Why is jQuery released under MIT and not LGPL? What are the benefits of using MIT compared to LGPL for a framework?


How do you deal with the anxiety of not knowing enough?

I just finished college a couple of months ago and im taking time out to improve my knowledge. I love programming but i feel like i dont know enough to be confident if I went for an interview. Last night i was browsing through questions and came across a question that asks interviewees how to work out a linked list. I learned these at college but if i was asked on the spot how to do it i wouldnt know. So that's another thing added to the list of what to learn. This is when the anxiety hit me because i have so much to learn in so little time (at least it feels that way). Upon introspection i think this anxiety is related to my perfectionism even though being perfect isnt rational e.g. Shakespeare and Einstein failed 80% of the time. So the questions are, have you felt this anxiety of not knowing enough? If so, how did you deal with it? I suppose there's a point in time when you begin to feel comfortable in your abilities?


How is the "Pizza picking problem" solved using dynamic programming techniques?

Winkler's pizza picking problem:   * A circular pizza pie of `n` slices, where slice `i` has area `S_i` i.e, the area is different for each pie piece.    * Eaters Alice and Bob take turns picking slices, but it is rude to create multiple gaps in the pie (consider it not allowed).      * Thus each eater is restricted to taking one of the two slices adjacent to the open region. Alice goes first, and both eaters seek as much pie as possible.  How would a dynamic programming algorithm determine how much pie Alice eats, if both Alice and Bob play perfectly to maximize their pizza consumption? My understanding: In a general DP problem, we go forward with finding sub-problems which can be visualized using recursion tree or, more tightly, using a DAG. Here, I'm not finding any lead to find the sub-problems here. Here, for a given set of S_i s, we need to maximize the area of slices eaten by Alice. This will depend on choosing a permutation of Pizza slices out of (n-1) permutations. Choosing a max area slice out of two options available in every n\2 turns Alice gets, will give us the total area of slice for a permutation. We need to find area of slice for all such permutations. And then the maximum out of these. Can somebody help me out on how to go forward?


Are PGP keys as good for certificates as X.509 keys?

I'm working on a decentralized transaction processing system that needs both authentication and general encryption, and I have a design decision to make: should I use PGP or X.509 certificates? While the world tends to use X.509 for authentication (especially in browsers), they are based on the principle of having a _central_ authority vouch for each certificate, meaning the system would need a CA and anyone who wants to participate in the system would need to have their keys signed by that CA. PGP, on the other hand, is based on a "Web of Trust", where parties who want to communicate merely need to have _any_ trusted party in common who will sign both keys. A CA isn't necessary in this case. My overall design goals prefer the Web-of-Trust model, to keep the system decentralized, but I may also have customers who prefer a centralized model, and I don't want to prohibit that possibility. Is there anything stopping the Web-of-Trust principle from working with X.509? Likewise, is it easy and straightforward to mimic CAs in the PGP cryptosystem? Are they interchangeable in practice? (For some reason, this is making me think of the false dichtomy: "I'm trying to bang in a nail, should I use a beer bottle or the heel of a shoe?")


Should I use an interface when methods are only similar?

I was posed with the idea of creating an object that checks if a point will collide with a line:               public class PointAndLineSegmentCollisionDetector {         public void Collides(Point p, LineSegment s) {             // ...         }     }      This made me think that if I decided to create a **Box** object, then I would need a **PointAndBoxCollisionDetector** and a **LineSegmentAndBoxCollisionDetector**. I might even realize that I should have a **BoxAndBoxCollisionDetector** and a **LineSegmentAndLineSegmentCollisionDetector**. And, when I add new objects that can collide I would need to add even more of these. But, they all have a **Collides** method, so everything I learned about abstraction is telling me, _"Make an interface."_               public interface CollisionDetector {         public void Collides(Spatial s1, Spatial s2);     }      But now I have a function that only detects some abstract class or interface that is used by **Point** , **LineSegment** , **Box** , etc.. So if I did this then each implementation would have to to a type check to make sure that the types are the appropriate type because the collision algorithm is different for each different type match up. Another solution could be this:               public class CollisionDetector {         public void Collides(Point p, LineSegment s) { ... }         public void Collides(LineSegment s, Box b) { ... }         public void Collides(Point p, Box b) { ... }         // ...     }      But, this could end up being a huge class that seems unwieldy, although it would have simplicity in that it is only a bunch of **Collide** methods. This is similar to C#'s **Convert** class. Which is nice because it is large, but it is simple to understand how it works. This seems to be the better solution, but I thought I should open it for discussion as a wiki to get other opinions.


What if I can't make my unit test fail in "Red, Green, Refactor" of TDD?

So let's say that I have a test:               @Test     public void MoveY_MoveZero_DoesNotMove() {         Point p = new Point(50.0, 50.0);         p.MoveY(0.0);         Assert.assertAreEqual(50.0, p.Y);     }      This test then causes me to create the class **Point** :               public class Point {         double X; double Y;         public void MoveY(double yDisplace) {             throw new NotYetImplementedException();         }     }      Ok. It fails. Good. Then I remove the exception and I get green. Great, but of course I need to test if it changes value. So I write a test that calls _p.MoveY(10.0)_ and checks if _p.Y_ is equal to 60.0. It fails, so then I change the function to look like so:               public void MoveY(double yDisplace) {         Y += yDisplace;     }      Great, now I have green again and I can move on. I've tested not moving and moving in the positive direction, so naturally I should test a negative value. The only problem with this test is that if I wrote the test correctly, then it doesn't fail at first. That means that I didn't fit the principle of "Red, Green, Refactor." Of course, This is a first-world problem of TDD, but getting a fail at first is helpful in that it shows that your test can fail. Otherwise this seemingly innocent test that is just passing for incorrect reasons could fail later because it was written wrong. That might not be a problem if it happened 5 minutes later, but what if it happens to the poor-sap that inheirited your code two years later. What he knows is that MoveY does not work with negative values because that is what the test is telling him. But, it really could work and just be a bug in the test. I don't think that would happen in this particular case because the code sample is so simple, but if it were a large complicated system that might not be the case. It seems crazy to say that I want to fail my tests, but that is an important step in TDD, for good reasons.


In-Memory Debugger for .NET?

I don't know if "In-Memory debugger" is really what I mean, or if it's even possible to produce, but it's the best name I could come up with... Here's the tool I'm looking for:   * Given a variable name, resolve that name to a reference   * Given that reference, be able to watch the object referenced   * Given the watch, be able to visualise it in a useful way, e.g.      * browse the properties of the object as you can in Visual Studio     * be notified when the object referenced is changed. Here's a use case for this hypothetical tool. I have spent all of today trying to track down an ObjectDisposedException in my C# web app. The object being disposed is the WindowsIdentity of the current user, and there would appear to be a race condition causing the WindowsIdentity to be disposed before it is used. If I could watch a particular memory reference in an intelligent way, rather than a variable in some given scope, I think it would help me pin down the source of this sort of bug more easily. Does such a tool exist for .NET?


What kind of test should be given to Java EE programmers?

I'm looking to hire developers and I wish to test them. I have been especially told by my boss that we should have programmers on board that can consult on banking sector software and I'm to come up with the test. Now I've never done Java EE development in depth and my knowledge of it isn't the greatest but I've not had any trouble understanding what I've read so far. Now I'm wondering how to construct a test to test candidates for Java EE knowledge as well as experience. And if I should make the test more conceptual like logical reasoning and pattern detection etc.


What is the best way to insert range of values into a datastructure

If I have a datastructure which is the fastest way I could insert values into it in a specified range? For example if I had a method:               myDatastructure var=new myDataStructure();     var.insert(2,1000);      it would mean that I get a most optimised way of getting a datastructure holding values from 2 to 1000 in each of index sequentially.


How to write functionally in a web framework

I love Rich Hickey, Clojure and Haskell and I get it when he talks about functions and the unreliability of side-effecting code. However I work in an environment where nearly all the functions I write have to read from the database, write to the database, make HTTP requests, decrement a user's balance, modify a frontend HTML component based on a click action, return different results based on the URI or the POST body. We also use PHP for the frontend, which is littered with functions like parse_str(), which modifies an object in place. All of these are side-effecting to one degree or another. Given these constraints and the side-effecting nature of the logic I'm coding, what can I do to make my code more reliable and `function`-able?


is it programmer's duty to disable directory listing?

Recently I have project in which a directory listing is enabled, due to which some scripts can be seen by outside world. I asked website administrator and he said it's not his responsibility, its the programmer's job. I also asked programmer about this and he said that the script is actually a cron job, and according to him, he has to test the script on webserver as there is a difference between development and production environment, so he placed there to test that. According to him, there was no direct link as he assumed directory listing is disabled and taken care by administrator. Who is the right person to do this?


PHP and Ruby: how to leverage both? and, is it worth it?

As you might have noticed from the title, this is not a "PHP or Ruby", or a "PHP vs. Ruby" question. This is a question on how to leverage PHP + Ruby in the same business. I myself am a PHP developer, I love the language because of its convenience and I specially love the ecosystem of resources that surround it: Joomla, Drupal, Wordpress, Symfony2, Doctrine2, etc. However, the language itself can be a little disappointing sometimes. OTOH, Ruby looks like a very beautiful language and —from studying it superficially in several aspects— I could say it is leaner than Python as a language per se. However, from what I've seen there is pretty much only RoR making noise, and I don't like RoR so much (mainly because its model layer). As Co-CEO and CTO at my company I'm trying to think outside of the box since I want to start to focus on the human side of technology and see if its sane to use both PHP and Ruby. Here are some random thoughts:   * Ruby folk seem to be generally better suited programmers than PHP folk (in terms of averages), I know the previous statement is somewhat baloney because very good and well architected PHP can be written, but I'd say the Ruby programmer culture is better than PHP's.    * The thing about Ruby is that it seems better suited for rapid development, I don't really know if this is only the case for RoR, but I do know that there are certain practices (perhaps not so good) like monkey patching that let business needs be satified quicker.   * From a marketing point of view (yep, sometimes you need to leverage the marketing BS for the sake of your company) Ruby seems better while PHP carries some stigmas.   * PHP 5.4 is bringing traits, and that is better/cleaner than mixins. That could really make PHP as lean as Ruby —or more— for certain stuff. Now, concretely, my questions:   * Would a PHP programmer want to learn Ruby?, I know I do, but conversely, would a Ruby programmer want to learn PHP?.   * What kinds of projects or situations would be better suited for Ruby that are not suited for PHP?.   * What is the actual ecosystem of Ruby?, aside from RoR, I have not seen other hyped technologies/frameworks (I've seen RSpec, but I confess being a total noob on what BDD really consists of and its implications).   * Supposing there are a certain type of projects ideal for Ruby, would there be a moment that its better to move it to PHP?. I know PHP can handle lots of stuff, but I've read that Ruby has its limitations when scaling (or is that RoR?, or is that baloney for both?).   * Finally and most importantly, would it be sane to maintain projects in two languages?, or is that just stupid. As I said, it looks like Ruby is leaner on the short term and that can make a project happen and succeed, but I'm not so sure about that on the long run. I'm looking for insights mainly from people that know well the strengths and weaknesses of the languages —preferably both of them— and Ruby's ecosystem in real practice, meaning: frameworks and applications like the ones I quoted from PHP's ecosystem.


Why is there such limited support for Design by Contract in most modern programming languages?

I recently discovered Design by Contract (DbC) and I find it an extremely interesting way to write code. Among other things, it would seem to offer:   * Better documentation. Since the contract is the documentation, it's impossible for one to be out of date. Additionally, because the contract specifies exactly what a routine does, it helps to support reuse.   * Simpler debugging. Since program execution stops the moment a contract fails, errors can't propagate, and the specific assertion violated will presumably be highlighted. This offers support during development and during maintenance.   * Better static analysis. DbC is basically just an implementation of Hoare logic, and the same principles should apply. The costs, in comparison seem to be rather small:   * Extra finger-typing. Since the contracts have to be spelled out.   * Takes some amount of training to get comfortable with writing contracts. Now, being familiar with Python primarily, I realize that it is in fact possible to write up preconditions (just throwing exceptions for inappropriate input) and it's even possible to use assertions to test again certain postconditions. But it's not possible to simulate certain features such as 'old' or 'result' without some extra magic that would ultimately be considered un-Pythonic. (In addition, there are a few libraries that offer support, but ultimately I get the vibe it would be wrong to use them, as most developers don't.) I assume that it's a similar problem for all other languages (except of course, Eiffel). My intuition tells me that the lack of support must be a result of some kind of rejection of the practice, but searching online has not been fruitful. I'm wondering if someone can clarify why most modern languages seem to offer so little support? Is DbC flawed or overly expensive? Or is it just obsolete due to Extreme Programming and other methodologies?


Is programming as a career in the US being hurt by competition from programmers in India?

I don't want to be offensive; people in India matter just as much as people in the US and also need work. However, I'm one of the people in the US. Are there fewer programming jobs in the US because of competition from India? Are the programming jobs in the US less lucrative because of competition from India? Is programming a good career choice in the US (in terms of being able to actually make a fair amount of money)?


Was Xcode created with Xcode?

I don't want to get too philosophical here (like did God create God?), but how did Apple create Xcode? Would it have been possible for them to use Xcode to create Xcode? Or would they have to use another code program (and what might that be?). In general, how does that work with code editors?


Difference between spring setter and interface injection?

I know how constructor and setter injection works in spring. Normally I use interfaces instead of classes to inject beans using setter and I consider it as interface injection, but in case of constructor we also use interfaces (I am confused). In following example I use `JobProcessor` interface instead of `JobProcessorImpl` class.               public class JobScheduler {         // JobProcessor interface         private JobProcessor jobProcessor;         // Dependecy injection         public void setJobProcessor(JobProcessor jobProcessor){             this.jobProcessor = jobProcessor;         }     }      I tried to find a solution by googling but there are different opinions by writers. Even some people says that spring doesn't support interface injection in their blogs/statements. Can someone help me by example?


How can I make tagging work for the concept of "all"?

There's an approach to organising information that says that hierarchy is a tool of the devil, or at least is overrated. I've embraced this understanding for a data-driven site I'm working on which has a fixed set of admins who create and tag data and a slightly less fixed group of data consumers. It uses tagging and search to inform the data consumers when a piece of information is related to what they're reading or searching for (as opposed to expecting non-1337 admins to maintain an object-style hierarchy). I now face the situation of needing some items of information to relate to "all" others in one respect. I cannot expect content creators to tag their "all" entries with every subject in the domain, and if they did the sheer weight of tags in that domain would drown out the information implied by the other tags on the entry. The options I can think of thus far (all unappealing) are:   * Create an "all" checkbox, which can assign an arbitrarily higher score to an entry when considering relevance    * Make different categories of tags, i.e. one tag field per clearly delineated group of subjects   * Replace tagging with a more traditional hierarchy   * Create magic "all" tags that get handled differently by my code (I can't believe I'm even thinking that out loud) Are there any other approaches that could work? Is one of these a clear winner?


What is a "markdown-formatted" README file on Github?

It's unclear to me what the format is, if there's systematic/command-line requirements for creating it, etc. Basically, just to need to know the specs, and if there's technical steps for generating the README file.


How might a Windows 8 Metro app handle back end database access?

While researching Metro and WinRT I haven't been able to find anything regarding enterprise apps and database access. All I hear about is the front end development. Does anyone have any idea of how a Metro app will access a database server? Will this still be done through ASP.Net and ADO.Net? If not, then does anyone have any idea or guess as to how?


How many ASP.NET developers program using pure OO?

How many ASP.NET developers program using OO (e.g. using get, set)? 6 years ago I developed and maintained a .Net 1.1 Intranet application that had no get/set. So how about today? Worth trying the pure OO route? Thanks, TDG


How to get Object Oriented Programming Concepts?

What is the best way or best resources or tutorials to learn Object Oriented Programming? For instance, when I begin a program with Java and all my code goes into just one class and I can't estimate when I need to create new classes and operate on these classes together.


Naming a sending/receiving module. Does the pattern have a name?

I'm working on a simple piece of functionality (actually a ruby gem, but that is beside the point) which can be used to   * receive and persist incoming messages   * send and persist outgoing messages   * supplies a hook to the implementing code for performing some action based on a received message. Could for example send a reply, but also perform other actions. I'm struggling to find a short and concise name for this functionality. Does this bare resemblance to any named patterns, and if so which? ******* UPDATE ******* To be more specific, what I am actually doing here is receiving and sending SMS. Starting to wonder if perhaps the most appropriate name for this functionality would be an SMS dispatcher. From the Dispatcher page on wikipedia (although it has nothing to do with computing): > Dispatchers are communications personnel responsible for receiving and > transmitting pure and reliable messages Or would using the dispatcher name for this concept cause confusion with other design patterns?


Java: method takes varargs of unrelated types

I have a Java factory method with a varargs array of `Object`s at the end. The array can contain any combination of `String`s and `ScaledJpeg`s. The theory being that an HTML table cell can contain any number of text nodes or `<image>` nodes and it will line-wrap the images as though they were just funny-shaped words.               // constructor     public Cell(TextStyle ts, float w, CellStyle cs, Object... r) {         if (w < 0) {             throw new IllegalArgumentException("A cell cannot have a negative width");         }         if (r != null) {             for (Object o : r) {                 if ( (o != null) &&                      !(o instanceof String) &&                      !(o instanceof ScaledJpeg) ) {                     throw new IllegalArgumentException(INVALID_ROW_TYPE_STR);                 }             }         }         textStyle = ts; width = w; cellStyle = cs; rows = r;         avgCharsForWidth = (int) ((width * 1220) / textStyle.avgCharWidth());     }      In Scala, I might use a list of `Either[String,ScaledJpeg]`. But some day I'll probably make this method allow something else, say another nested `Cell`, but doing so would break existing code that only expected two possible types. At least the way it is, future changes won't break existing code. The current solution works, allows for expansion, and is relatively easy to use, except that it defeats type safety and can only throw an exception at runtime if someone passes something unexpected as a vararg. For instance, I just forgot to add `toString()` to a `StringBuilder` and it blew up at runtime. So already that's a third class to account for (Since `toString()` is defined on every object, I don't want to call it on whatever is passed because doing so for most object types would be an error much further down in the code violating the fail-fast behavior of this example). `java.lang.String` can't implement any new interfaces and that's probably a good thing. Even if I could make a wrapper class, everything about the way text and images are treated by this class is completely different _except_ that they are line-wrapped together the way they would be in HTML (or in a Word doc). As I write this, it occurs to me that I should probably use a Builder pattern, make a `CellBuilder` class that has `addText()` and `addImage()` methods that does away with the varargs constructor. This would encapsulate the underlying List in a way that the user of the API gets 100% compile-time type safety. But out of curiosity, I'm still posting this in case there are other creative and possibly better solutions out there.


How do programmers deal with Project Lead/Managers?

Project Managers/Technical Leads sometimes tend to be over enthusiastic when it comes to software. But during code reviews if instead of functionality of the code the only complain one hears is about formatting/spacing and similar trivial things, when there are far better things to discuss (Among other things I have noticed the sometimes during the so called "reviews" suggestions are made that implementation needs a re-write just because it doesnt use the most happening technology/buzzword) How do fellow programmers deal with such scenarios? or is this just a one off? (or is the fault entirely on me )If you have similar experience and what you did to overcome it? Feel free to share.


Should a developer close a ticket in bug tracking tool?

Should a developer close a ticket in a bug tracking tool? Or should only the scrum master or testers should do it? What are the best practices?


What exactly are Link Relation Values?

From REST in Practice: Hypermedia and Systems Architecture: > For computer-to-computer interactions, we advertise protocol information by > embedding links in representations, much as we do with the human Web. To > describe a link's purpose, we annotate it. Annotations indicate what the > linked resource means to the current resource: “status of your coffee order” > “payment” and so on. We call such annotated links **hypermedia controls** , > reflecting their enhanced capabilities over raw URIs. > > ... **link relation values** , which describe the roles of linked resources > ... **Link relation values** help consumers understand why they might want > to activate a hypermedia control. They do so by indicating the role of the > linked resource in the context of the current representation. I interpret the above quotes as saying that **Hypermedia control** contains both _a link to a resource_ and _an annotation describing the role of linked resource in the context of the current representation_. And we call this annotation ( which describes the role of linked resource ) a **link relation value**. Is my assumption correct or does the term **link relation value** actually describe something different? Thank you


What to look for in selecting a language for Algorithmic/high frequency trading?

If one were a quantitative developer, what factors are considered in language choice? I am talking high frequency trading on the scale of investment banks. I know latency is definitely a factor and maybe readability of code (not sure how much code is altered in which case this would be big). Anyone with more knowledge on this know the pros/cons sought in development?


Local versioning system especially designed for documents

I have to work on some docs, I need a software that can trace all the modifications that I will make to a specific file or project (group of files): is there something like that? The important thing is that I have to do that with a single machine so I do not need a distributed solution, I only have to work with txt files with UTF-8 charset and pdf files.


Software architecture for two similar classes which require different input parameters for the same method

I am writing Java code to simulate a supply chain. The supply chain can be simulated in either an intermediate stocking or a cross-docking configuration. So, I wrote two simulator objects `IstockSimulator` and `XdockSimulator`. Since the two objects share certain behaviors (e.g. making shipments, demand arriving), I wrote an abstract simulator object `AbstractSimulator` which is a parent class of the two simulator objects. The abstract simulator object has a method `runSimulation()` which takes an input parameter of class `SimulationParameters`. Up till now, the simulation parameters only contains fields that are common to both simulator objects, such as `randomSeed`, `simulationStartPeriod` and `simulationEndPeriod`. However, I now want to include fields that are specific to the type of simulation that is being run, i.e. an `IstockSimulationParameters` class for an intermediate stocking simulation, and a `XdockSimulationParameters` class for a cross-docking simulation. My current idea is take the method `runSimulation()` out of the `AbstractSimulator` class, but to put a `runSimulation(IstockSimulationParameters)` method in the `IstockSimulator` class, and a `runSimulation(XdockSimulationParameters)` method in the `IstockSimulator` class. I am worried however, that this approach will lead to code duplication. What should I do? ### Edited Currently, the `AbstractSimulator` class defines the `runSimulation` method which calls other abstract methods that are only defined by the concrete child classes.               public abstract class AbstractSimulator {         public void runSimulation(SimulationParameters params) {             int startPeriod = params.startPeriod;             int endPeriod = params.endPeriod;             for (int t = startPeriod; t < endPeriod; ++t) {                 submitReports(t);                 makeShipments(t);                 demandArrives(t);             }         }         protected abstract void submitReports(int t);         protected abstract void makeShipments(int t);     }      One of the differences between the `IstockSimulator` and the `XdockSimulator` is that in an intermediate stocking configuration, tier 3 facilities submit reports to tier 2 facilities, while in a cross-docking configuration, tier 3 facilities submit reports to tier 1 facilities. Thus the `IstockSimulator` and the `XdockSimulator` have their own implementations of the methods `submitReports` and `makeShipments`. ### What worked for me Thank you for your answers. Inspired by your answers, and after sleeping it over, I came up with my own answer based on refactoring. See below.


Thin client Web browser?

Many times i have heard people saying that a particular hardware to be running a thin client web browser. But from the definition of "thin-client", doesnt all browser qualify as a thin-client? as all they do is rendering the information sent from a remote server minimizing the work at the browser end?


Compiled code spreadsheet-like cell management? (auto-updating)

Okay so I am fully aware how spreadsheets manage cells, they build dependency graphs where when one cell changes it tells all the other cells that are dependent on it that it changed. So they can from there update. How they update I think involves either re-evaluating the formulas stored as strings, or re-evaluating the abstract syntax tree which I think is stored differently and might be faster. Something like that. What I'm looking to do is manage a few variables in my code so I don't have to update them in the correct way, which would be a nightmare. But I also want it much faster than spreadsheets. And since I'm not looking for any functionality as great as are in these spreadsheets, I just figured from that thought point that there has to be a way to have a very fast implementation of this functionality. Especially since I don't have to modify cells after compiling unless that would be an option. I'm very new to programming so I have no idea. One example might be to have a code-generator that generates code that does this for me. But I have no clue what the generated code would look like. Specifically, how exactly would variables inform others that they need to update, and what do those variables do to update? I'm looking for any kind of ideas. Programming is not my job but nonetheless I was hoping to have some kind of system like this that would greatly help me with some stuff. Of course I have been programming plenty lately so I can still program. I just don't have the full scope on things. I'm looking for any kind of ideas, thank you very much in advance! Also, please help me with the tags. I know C# and Java mainly and I'm hoping to implement this in either of those languages and I'm hoping this can stay in those tags. Forcing this into some kind of spreadsheet tag wouldn't be accurate.


How to work in localhost properly

I am using MAMP (just and example) to develop web applications without having to constantly upload and download via FTP. I´m sure this is the correct way to test a project but I´m no sure if I´m doing it right. After I´m satisfied with the project I have to change in every page the MySQL databases and most of the links etc. Is there a workaround this? How should this be used? Thanks in advance!


How to market yourself as a software developer?

I have noticed that this is a frequent issue among _younglings_ from technical areas such as ours. In the beginning of our careers we simply don't know how to sell ourselves to our employers, and random guy #57 (who is a programmer, but not as good as you - technically) ends up getting a raise or a promotion because he knows how to communicate and market himself better than you. Many have probably seen this happen in the past, and most certainly many more will in the future. What kind of skill/ability (either technical, or of other nature) do you think is relevant to point out when doing a job interview or asking for a raise, besides listing all the programming languages and libraries you know?


Verification as QA - makes sense?

Preparing my thesis, I found another interesting discrepancy. While some books say verification it terms of static analysis of work products is quality control (looking for defects), other say it is actually quality assurance because the process of checking is decreasing the probability of real defects when these deliverables will be used for product manufacture. I hesitate as both seems to be correct: it is a way of checking for defects (deviation from requirements, design flaws etc.) so it looks like quality control, but also it is a process which does not have to be done and if done, can yield better quality.


How to generate "language-safe" UUIDs?

I always wanted to use randomly generated strings for my resources' IDs, so I could have shorter URLs like this: /user/4jz0k1 But I never did, because I was worried about the random string generation creating actual words, eg: /user/f*cker. This brings two problems: it might be confusing or even offensive for users, and it could mess with the SEO too. Then I thought all I had to do was to set up a fixed pattern like adding a number every 2 letters. I was very happy with my 'generate_safe_uuid' method, but then I realized it was only better for SEO, and worse for users, because it increased the ratio of actual words being generated, eg: /user/g4yd1ck5 Now I'm thinking I could create a method 'replace_numbers_with_letters', and check that it haven't formed any words against a dictionary or something. Any other ideas? ps. As I write this, I also realized that checking for words in more than one language (eg: english and french, spanish, etc) would be a mess, and I'm starting to love numbers-only IDs again. **UPDATE** Some links everyone should read: http://thedailywtf.com/Articles/The-Automated-Curse-Generator.aspx http://blogs.msdn.com/b/oldnewthing/archive/2008/06/27/8659071.aspx


Relationship between SOA and OOA

Thomas Erl defines SOA as follows in his site: > Service-oriented computing represents a new generation distributed computing > platform. As such, it encompasses many things, including its own design > paradigm and design principles, design pattern catalogs, pattern languages, > a distinct architectural model, and related concepts, technologies, and > frameworks. This definitely sounds like a whole new category which is parallel to object orientation. Almost one in which you would expect an entirely new language to exist for. Like procedural C and object oriented C#. Here is my understanding: In real life, we don't have entirely new language for SOA. And most application which have SOA architecture have an object oriented design underneath it. SOA is a "strategy" to make the entire application/service distributed and reliable. SOA _needs_ OOPS working underneath it. Is this correct? Where does SOA (if at all it does) fit in with object oriented programming practices? Edit: I have learnt through answers that OOA and SOA work with each other and cannot be compared (in a "which is better" way). I have changed the title to "Relationship between SOA and OOA" rather than "comparison".


Interfaces and abstraction: takes more time?

At the company I work for I want to improve the way we write software: designing our applications more `SOLID`. We've been in a new project for a few weeks and I've tried to apply some good practices in its design. For example, loose coupling by programming against interface instead of a concrete class, dependency injection / inversion of control, seperation of concerns etc. This is all meant as a springboard to test driven development in the (far) future. In the application we're developing we need to calculate a score depending on a filled in survey by a user (a survey has categories which themselves have questions / answers). I've splitted the calculations in multiple classes and subsequent interfaces (calculating score of a question, category, survey, etc). Also, in the front-end (ASP.NET Web Forms), I've splitted many parts of pages into seperate user controls. For example: a 'widget' which shows the culumative scores in the application or a widget for showing all files related to the application. These are all seperate user controls. We're now a few weeks in the project and I find that some of my co-workers (especially ones older of age) are complaining about:   * Not being able to find a implementation of a interface directly but needing to 'search' for the implementation   * Needing more time to find the implementation of a particular markup on the front-page They also don't see the point of splitting up seperate functionality into user controls because sometimes (usually) the user control is only used on one page. I, on the opposite, find it to work better since it keeps the code- behind of a page tight and lean. My question is: Do I apply good practices the wrong way or does it simply take time to get used to it? **Note** : Until very recently we developed software with tight coupling (e.g: static classes, never use interfaces, only use user control when necessary).


Code Documentation First?

Has anyone ever tried creating a complete code documentation first, before actually writing the code? I was thinking about this earlier because I thought it would help to write a concrete interface and would make sure your initial design wasn't floored by making you think about how classes interact. Is this a good idea? Has anyone tried it? Ell


Indenting/formatting brackets like { } and [ ]

Is there an application that can easily align/format brackets such as [ ] { and } ? e.g. change               {          {          }         }      into               {       {       }     }


Managed Languages vs Compiled Language difference?

I get confused when people try to make a distinction between compiled languages and managed languages. From experience, I understand that most consider compiled languages to be C,C++ while managed languages are Java,C# (There are obviously more, but these are just few examples). But what exactly is the core difference between the two types of languages? My understanding is that any program, regardless of what language you use is essentially "compiled" into a low-level machine code which is then interpreted, so does that kinda make managed languages a subset of compiled languages (That is, all managed languages are compiled languages but not the other way around)?


selling closed source commercial product in a virtualbox (GPL)

Can I sell a closed source commercial product inside a virtualbox VM? This is extremely useful when you want to deliver server side software to users, and not mess in with different OS's (windows/osx). By reading some of the answers here in programmers, I get that it should not be a problem since my software does not link a GPL library, and that's practically the biggest concern of GPL FOSS. So, if I use GPL software just **bundled** with Closed source software that's fine?


Is it good practice for Azure applications to self-administrate?

In a lot of examples for the Azure platform I'm seeing a lot of self- administration happening: an application will test for the presence of an external system such as a queue or database and create the necessary structures it needs to function. This behaviour seems contrary to a more traditional application's environment being configured by an administrator or a separate setup application acting on behalf of the administrator. So far, the biggest drawback I can observe to this is that the application would need to have some level of administrative rights over the services it is configuring and that could lead to increased vulnerability. However, the Code-First approach in Entity Framework would also seem to suggest a practise of allowing an application to work at an administrator- level on the resources it needs to function. Is this a paradigm I should be expecting to see more of, and are there compelling reasons to consider it as "good practice"?


Help on a Dynamic Programming definition in Cormen

I am reading about `Dynamic Programming` from Cormen.   In the beginning of the chapter it says (relating to the term Dynamic Programming): > "Programming” in this context refers to a tabular method, not to writing > computer code. I can not really understand what this statement means.   I mean, I understand that the dynamic programming algorithms look up solutions, but I get a feeling that this point here defines something fundamental on the Dynamic Programming that I am not grasping.   Any help?


Might starting variables/members with an underscore puzzle the compiler?

I've been taught since high school that defining variables like this: `int _a;` or `int __a;` should be consider bad practice because this would eventually puzzle compilers that use variables starting with an underscore to name temporary variables. As far as I know this is the reason why some people like to move the underscore at the end of the name, like: `int a_;` However, I see a lot of code all around that makes use of underscore-starting variables. And that code builds fairly well with both Visual Studio 2010 and g++ 4.x. So I wonder: is this a non-issue nowadays? Are modern compilers smarter about naming conventions?


Should web browsers include popular web framework libraries?

What reasons are there for web browsers to not have a library of popular web frameworks. For example if a web page included jQuery, why shouldn't the browser have it's own static version, which is separate from the normal cached items? I would imagine if most libraries were preloaded into a browsers cache, before any request was made with a document that included a library, then this would remove the initial request to a CDN and have a potential performance improvement. But if the browser 'preloaded cache' didn't include the library then the browser should request the resource that is included in the document.


What are some common examples of a Hash Table?

I was just wondering if there were some "standard" examples that everyone uses as a basis for explaining the nature of a problem that requires the use of a Hash table. What are some well-known problems in the real world that can see great benefits from using a Hash table? **Also, a little background or explanation as to why the problem benefits from using a Hash Table would be of help!**


What do I need to develop a PHP extension in lampp?

Actually I'm dealing with a trouble in my system, I have to delivery the system to clients and it was built in PHP, JS, ShellScript and SQL. I would like to encrypt the code or obfuscate it from eyes of others! Then someone from the community told me about building my own PHP extension, it sounds to me as a great idea, since it will not be with the main code of the system. But I have a problem doing this way, if a programmer get in the extensions and find it, all the hard work has gone. Then I'm here to ask again about this matter. What is the best way to hide my Business Logic from third parties? I know that there are stuff like IonCube, Zend Guard, and many others. But I'm looking something that I can build myself. Is PHP extension the right way to follow? Or some Half SaaS system, with dependencies (Business Logic) in a remote server? **About the environment** OS: Kernel Linux 2.6.37.1-1.2 - LAMPP (Apache 2.2, MySQL 5.5 PHP 5.3.8) In php generally the extension is located at `/php/ext/` but in lampp I have no idea where it is, I just found a folder `/opt/lampp/lib/php/extensions/` is that right place?


Isolating test data in acceptance tests

I'm looking for guidance on how to keep my acceptance tests isolated. Right now the issue I'm having with being able to run the tests in parallel is the database records that are manipulated in the tests. I've written helpers that take care of doing inserts and deletes before tests are executed, to make sure the state is correct. But now I can't run them in parallel against the same database without uniquely generating the test data fields for each test. For example. Testing creating a row i'll delete everything where column A = foo and column B = bar Then I'll navigate through the UI in the test and create a record with column A = foo and column B = bar. Testing that a duplicate row is not allowed to be created. I'll insert a row with column A = foo and column B = bar and then use the UI to try and do the exact same thing. This will display an error message in the UI as expected. These tests work perfectly when ran separately and serially. But I can't run them at the same time for fear that one will create or delete a record the other is expecting. Any tips on how to structure them better so they can be run in parallel?


Is this a good use of a base class?

I am developing some HW drivers, which access registers. I have a few classes, for example. ClassRegisterBlock1, ClassRegisterBlock2. In each of these classes, they define the bits to manipulate, the register offsets etc and validate the parameters. However all the functions use the same way ofaccessing the HW, via a memory map and then there are common functions like setRegisterBit. I was planning on putting the common functions, like setRegisterBit, CreateMemoryMap etc.. into a base class and then the ClassRegisterBlock(x) inherits from that. Is this a sensible use of base class? as strictly speaking the ClassRegisterBlock is not a kind of RegisterFunctions class. Is there a better way of doing that? I am using c++.


I am looking for a software license which has stronger protection than AGPLv3. The GPL license said that when we distribute the software, we must provide a way for user to download the source code. However there is a loophole in this license, the GPL FAQ said (see below) it is not considered "distribution" if the company uses it as an internal project. Is there any license which require to distribute the source code, even it is only used in a company's internal project? PS, GPL FAQ "Internal Distribution" section: > **Is making and using multiple copies within one organization or company > “distribution”?**   >  No, in that case the organization is just making the copies for itself. As > a consequence, a company or other organization can develop a modified > version and install that version through its own facilities, without giving > the staff permission to release that modified version to outsiders. > > However, when the organization transfers copies to other organizations or > individuals, that is distribution. In particular, providing copies to > contractors for use off-site is distribution.


What is agile methodology?

Can any one explain about the agile methodology in simple sentences?


Unit test coding standards

Usually when talking about coding standards we refer to the code of the program itself, but what about the unit tests? Are there certain coding standards guidelines that are unique to unit tests? What are they?


I am a web developer and i want to take my web app to the cloud.Could anyone take me through the steps involved.Do they like have a lamp installation which they will assign to me or will i continue hosting my data and scripts?. Are there fees associated with listing my app to the salesforce marketplace? Thanks.


When to declare @throws with a Scala annotation - abstract parent or concrete implementation?

In this StackOverflow question I asked about the behavior of the `@throws` annotation in Scala. Now that I understand how it works I want to ask about best practices with using it. Here's a repost of my code from that question:               abstract class SFoo {         def bar(): Unit     }          class SFoobar extends SFoo {         @throws[Exception]         override def bar(): Unit = {             throw new Exception("hi there")         }     }      The problem here is that if I declare a variable as a `SFoo` in Java, but instantiate it as a `SFoobar`, the Java compiler is unable to detect the checked exception and a runtime exception will occur. So my inclination would be to declare `@throws` in the parent class, `SFoo`. But say I have another concrete implementation of `SFoo`:               class SBarfoo extends SFoo {         override def bar(): Unit = {             println("no exception here!")         }     }      In this case, is it appropriate to declare `@throws` in the parent class if one of its implementations does not throw an exception? What is the best practice here? (Sorry for the subjective question.)


Recommendations for finding part-time consultancy work

Although I have a full-time development job, I have occasionally done some part-time paid work in evenings / weekends for various people who have contacted me as a result of open-source projects I have worked on. It's a nice way to earn a bit of extra cash, but obviously it is not always available. My question is, what is a good way of getting your name out there to do some small projects? I have seen a few programmers-for-hire type websites, but I don't know which I can trust or whether there are too many people willing to work for very low prices. Also, being UK based, I would want something which did not assume I have a US bank account.


Working with a restful Api; what resources would you like available to start with?

When working with a web based restful api what resources would you like to work with from the beginning when developing a system against it?   * Web based documentation?   * Working example? Simple? Complex?   * An SDK which abstracts away some of the details and allows in depth development straight away?   * All of the above? With your answers if web sites of examples are available that would be cool. Appreciate all the help in advance.


How to protect a peer-to-peer network from inappropriate content?

I’m developing a simple peer-to-peer app in .Net which should enable users to share specific content (text and picture files). As I've learned with my last question, inappropriate content can “relatively” easily be identified / controlled in a centralized environment. But what about a peer-to-peer network, what are the best methods to protect a decentralized system from unwanted (illegal) content? At the moment I only see the following two methods:   1. A protocol (a set of rules) defines what kind of data (e.g. only .txt and jpg-files, not bigger than 20KB etc.) can be shared over the p2p-network and all clients (peers) must implement this protocol. If a peer doesn’t, it gets blocked by other peers. Pro: easy to implement. Con: It’s not possible to define the perfect protocol (I think eMail-Spam filters have the same problem)   2. Some kind of rating/reputation system must be implemented (similar to stackoverflow), so “bad guys” and inappropriate content can be identified / blocked by other users. Pro: Would be very accurate. Con: Would be slow and in my view technically very hard to implement. Are there other/better solutions? Any answer or comment is highly appreciated.


Headaches using distributed version control for traditional teams?

Though I use and like DVCS for my personal projects, and can totally see how it makes managing contributions to your project from others easier (e.g. your typical Github scenario), it seems like for a "traditional" team there could be some problems over the centralized approach employed by solutions like TFS, Perforce, etc. (By "traditional" I mean a team of developers in an office working on one project that no one person "owns", with potentially everyone touching the same code.) A couple of these problems I've foreseen on my own, but please chime in with other considerations. In a traditional system, when you try to check your change in to the server, if someone else has previously checked in a conflicting change then you are forced to merge before you can check yours in. In the DVCS model, each developer checks in their changes locally and at some point pushes to some other repo. That repo then has a branch of that file that 2 people changed. It seems that now someone must be put in charge of dealing with that situation. A designated person on the team might not have sufficient knowledge of the entire codebase to be able to handle merging all conflicts. So now an extra step has been added where someone has to approach one of those developers, tell him to pull and do the merge and then push again (or you have to build an infrastructure that automates that task). Furthermore, since DVCS tends to make working locally so convenient, it is probable that developers could accumulate a few changes in their local repos before pushing, making such conflicts more common and more complicated. Obviously if everyone on the team only works on different areas of the code, this isn't an issue. But I'm curious about the case where everyone is working on the same code. It seems like the centralized model forces conflicts to be dealt with quickly and frequently, minimizing the need to do large, painful merges or have anyone "police" the main repo. So for those of you who do use a DVCS with your team in your office, how do you handle such cases? Do you find your daily (or more likely, weekly) workflow affected negatively? Are there any other considerations I should be aware of before recommending a DVCS at my workplace?


How to become a JavaScript ninja?

I want to choose JavaScript as my main development field, alongside HTML and CSS to become a developer commonly known as **front-end developer**. But I don't know how to become a JavaScript professional. I've read many books and learned the pieces including data types, syntax, tools usage (like IDEs, Debuggers, etc.), jQuery, etc. But when I look at some sophisticated JavaScript codes including famous libraries, I'm like "I never could write that code". What's wrong here? What step should I had taken that I didn't? I feel I'm missing something here to become a professional JavaScript developer. I also watched training movies, including Douglas Crockford's movies at Yahoo Theater.


How was Git designed?

My workplace recently switched to Git and I've been loving (and hating!) it. I really do love it, and it is extremely powerful. The only part I hate is that sometimes it's too powerful (and maybe a bit terse/confusing). My question is... **How was Git designed?** Just using it for a short amount of time, you get the feel that it can handle many obscure workflows that other version control systems could not. But it also feels elegant underneath. And fast! This is no doubt in part to Linus's talent. But I'm wondering, was the overall design of git based off of something? I've read about BitKeeper but the accounts are scant on technical details. The compression, the graphs, getting rid of revision numbers, emphasizing branching, stashing, remotes... Where did it all come from? Linus really knocked this one out of the park and on pretty much the first try! It's quite good to use once you're past the learning curve.


Git tracks _lines_ of code. Is there something that track _words_?

In git if I change a character in a line the entire line is considered changed. I don't know much but stackexchange seem to track changes in a word-by-word basis in the edit history.   Is there an option to make git like that, or is there anything else that does this?


What cloud technologies should Application Architects know about?

There is so much going on in the cloud, acronyms like PaaS, SaaS, IaaS, (any more?) that I'm losing track of what technologies are important (within each category) how relevant each one is. What are the core cloud technologies that Architects should know about in each category?


Organizing Class Members in Regards to Access Modifier

If we look at typical implementation of a Class, we usually see the private members defined at the beginning and public( mostly functions and Accessors) defined towards the bottom. Now, is this a Industry standard agreed by a lot of people? How about keeping the private members towards the end as updates and additions are usually done to the Public Members(mostly functions), to fix bug or provide enhancement, so we don't have to scroll down towards the end to get to the function definition section. I understand, good IDEs will allow us to Jump towards a specific attribute, but considering other factors, such as Code Review, it may be convenient to have the Public Definitions towards the beginning. What is the most accepted standard for Class Member Organization?


In retrospect, has it been a good idea to use three-valued logic for SQL NULL comparisons?

In SQL, NULL means "unknown value". Thus, every comparison with NULL yields NULL (unknown) rather than TRUE or FALSE. From a conceptional point of view, this three-valued logic makes sense. From a practical point of view, every learner of SQL has, one time or another, made the classic `WHERE myField = NULL` mistake or learned the hard way that `NOT IN` does not do what one would expect when NULL values are present. It is my impression (please correct me if I am wrong) that the cases where this three-valued logic helps (e.g. `WHERE myField IS NOT NULL AND myField <> 2` can be shortened to `WHERE myField <> 2`) are rare and, in those cases, people tend to use the longer version anyway for clarity, just like you would add a comment when using a clever, non-obvious hack. **Is there some obvious advantage that I am missing?** Or is there a general consensus among the development community that this has been a mistake?


Do multiple computer screens reduce productivity?

I was reading the wonderful post of Trent Walton : UniTasking which contains a lot of useful thoughts and ideas, plus some good links to some neat OS X apps. (which I have started using right after I read the blog.) But I noticed a funny notion. Many people talked very negatively about using multiple screens. Onwards to Tom Cunningham's : Stay productive, he actually mentions using only 1 monitor as the first tip to increase productivity. Is this a common belief ? And has anyone done any tests with this ? I work at a software studio, and we have three screens as standard (Macbook 15" + two 21" screens) but due to the fact that I take my macbook with me every day, and set it up every morning, I can easily go an hour or two with only the main screen turned on. So what are your beliefs on this ? Myth, fact or completely up to individual preferences ?


Can anyone explain to me what problem Core Data solves?

Core Data seems to add a needless layer of complexity. If you want to save data created natively by the user in an app why not just use an object and then write the data all to SQLite or back to a server using a RESTful script if necessary. Android doesn't have Core Data (though if it has something similar I haven't seen it.). What the heck is the point of buggy CD except useless needless overhead for people who can't write SQL or CGI scripts?


Is the COCOMO model a good argument when defending a programming language choice?

Currently, I'm following a course on embedded software development. The lecturer has chosen J as an architecture language for model-driven software development. J itself is a very terse programming language and one of his main arguments for this language is its terseness. For instance, this is a Quicksoft implementation in J:               quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)      Another argument is that through such a language and the reduced number of characters, you introduce less bugs and the time to fix bugs is reduced. Since I have a strong software engineering background and through various books like Clean Code, Pragmatic Programmer and others, I feel that these arguments aren't valid. I find that there is a strong movement towards descriptive names and code that reads like natural language (alright, this might only be related to applications with lots of business logic and less math). The question therefore is, can you really argue that usage of a terse programming language will result in less errors and that time to fix a bug is reduced? Also, since the language is terse, the number of lines of code is reduced and you would get a better COCOMO rating. But can this be applied in the first place or does the COCOMO model use the number of lines of code as a way to estimate a project's overall size (project size should be the same whether you implement it in a terse language or in an imperative one, but again, maybe I didn't understand the COCOMO model correctly)? **Update** Thank you all for your answers. Admittedly, I should have stated more clearly that my intention was to get more information on the COCOMO model (again, sorry S.Lott). As such, I feel that Thomas Owens's extensive answer and comments are the best fit for this question. Thanks again! :-)


Best free UML authoring tool

What free UML authoring tools do you use and why is it better than others?


What is a name for a job where you do system analysis, project management and data diagramming?

In the last 4 months I've been able to manage a team and step away from the coding for a bit. I've been planning the system in full (both System Analysis and project managing, alongside action and data diagramming) writing the technical documentation, the code's architecture, keeping track of the other guys doing the actual coding, QA, bug reports and dealing with clients. I had to take two days' training on node.js just to see if it would be suitable for a project we were considering. Is there a name for this job? Project Manager and Systems Architect don't quite seem to have the same stuff, and IT manager seems way off. I only want to know so that I can get some qualification towards it and try to move into this kind of work full-time.


Do companies care about university grades when hiring programmers?

Most of my fellow students that I've talked to claim that aiming for good grades is useless as the companies don't care about them when hiring programmers. To them, it's enough to have simply attended courses which may be important, and that's that. Is this true? Are university grades useless when leaving campus, or do employers ask to see them for an interview?


Transparant OSGi support in modules

I have a bunch of libraries and I have started exposing them as OSGi modules. However there were two requirements:   * no new dependencies   * the modules still had to run in non-OSGi environments The first requirement is easily solved by using DS (declarative services) however the second seems slightly more difficult. I currently have a working solution but I'm not sure if it is a good one. I will explain my methodology using a simple example, any feedback on it is welcome. Suppose you have a service class called MyService. You also have 3 client services A, B and C that each require an instance of the service. OSGi would inject the instance as needed and all would be well. However consider running the module outside an OSGi container. At this point you yourself are responsible for injecting the proper beans and (if necessary) manage the singletons that most osgi services are. So at this point you have to inject the proper singleton into three other objects. This can scale to unmanageable levels fast. My solution consists of reusing the factory pattern:               public class MyServiceFactory {              private static MyServiceFactory instance;              public static MyServiceFactory getInstance() {             if (instance == null)                 instance = new MyServiceFactory();             return instance;         }              private MyService myService;              public MyService getMyService() {             // fall back to SPI             if (myService == null) {                 ServiceLoader<MyService> serviceLoader = ServiceLoader.load(MyService.class);                 Iterator<MyService> iterator = serviceLoader.iterator();                 if (iterator.hasNext())                     myService = iterator.next();                 // if no SPI modules, you could for instance initialize a stub, a default,...                 else                     myService = new MyServiceStub();             }             return myService;         }              public void setMyService(MyService myService) {             this.myService = myService;         }              public void unsetMyService(MyService myService) {             this.myService = null;         }              @SuppressWarnings("unused")         private void activate() {             instance = this;         }         @SuppressWarnings("unused")         private void deactivate() {             instance = null;         }     }      Any code that requires a MyService instance can simply do:               MyServiceFactory.getInstance().getMyService();      It will use an OSGi-managed instance when possible (the private activate/deactivate) or fall back to SPI when necessary. Is this a good solution or are there better ones? Is it a solved problem where I somehow missed the obvious answer?


How do I manage the technical debate over WCF vs. Web API?

I'm managing a team of like 15 developers now, and we are stuck at a point on choosing the technology, where the team is broken into two completely opposite teams, debating over usage of WCF vs. Web API. Team A which supports usage of Web API, brings forward these reasons:   1. Web API is just the modern way of writing services (Wikipedia)   2. WCF is an overhead for HTTP. It's a solution for TCP, and Net Pipes, and other protocols   3. WCF models are not POCO, because of [DataContract] & [DataMember] and those attributes   4. SOAP is not as readable and handy as JSON   5. SOAP is an overhead for network compared to JSON (transport over HTTP)   6. No method overloading Team B which supports the usage of WCF, says:   1. WCF supports multiple protocols (via configuration)   2. WCF supports distributed transactions   3. Many good examples and success stories exist for WCF (while Web API is still young)   4. Duplex is excellent for two-way communication This debate is continuing, and I don't know what to do now. Personally, I think that we should use a tool **only for its right place of usage**. In other words, we'd better use Web API, if we want to expose a service over HTTP, but use WCF when it comes to TCP and Duplex. By searching the Internet, we can't get to a solid result. Many posts exist for supporting WCF, but on the contrary we also find people complaint about it. I know that the nature of this question might sound arguable, but we need some good hints to decide. We're stuck at a point where choosing a technology **by chance** might make us regret it later. We want to choose with open eyes. Our usage would be mostly for web, and we would expose our services over HTTP. In some cases (say 5 to 10 percent) we might need distributed transactions though. What should I do now? How do I manage this debate in a constructive way?