title: Who can be called a good team player?

text: Many times you encounter something like "team-worker" or "enthusiast to work in a team" or stuff like that in employment ads which state that they want you to be or become a good member of a development team. Who can be regarded as a good team member? Which qualities of a developer can be regarded as good points regarding to work in a team? Also how can a developer improve his/her teamwork skills (or attributes, if you will)?


title: Python code style - blank lines in long list

text: I'm curious, is there a standard approach to dealing with long lists in the Python community, and in particular, is there any antipathy toward doing blank lines followed by comments to break up a particularly long list, e.g. of tuples, or in a dict, etc.? For example, I'm developing a GUI application in wxPython, and am defining the keyboard shortcut mappings to . Is this fairly Pythonic?               accelerator_table = wx.AcceleratorTable([         # Case accelerators         (CTRL, ord('S'), EventIds.SAVE_CASE),         (CTRL_SHIFT, ord('S'), EventIds.RENAME_CASE),         (CTRL, wx.WXK_DELETE, EventIds.REMOVE_CASE),         (CTRL_SHIFT, wx.WXK_DELETE, EventIds.DELETE_CASE),              # Project accelerators         (CTRL_ALT_SHIFT, ord('S'), EventIds.RENAME_PROJECT),         (ALT, wx.WXK_DELETE, EventIds.REMOVE_PROJECT),         (ALT_SHIFT, wx.WXK_DELETE, EventIds.DELETE_PROJECT),              # Help accelerators         (NORMAL, wx.WXK_F1, EventIds.HELP),         (NORMAL, wx.WXK_F2, EventIds.LAUNCH_MANUAL),         (NORMAL, wx.WXK_F12, EventIds.ABOUT),         ...     ])      The details aren't particularly important, but I'd like to write in a style that will not annoy other programmers along the way, and therefore to decide right now whether this pattern is worth keeping around. **Edit:** Just to clarify: I'm not intending to put anything beyond that single blank line between sections in the list. That seems like it should minimize any confusion on the part of someone reading through the code.


title: Formal study about trends and prevalence of agile vs traditional methodology in the industry

text: Has there been a formal study about the prevalence of agile vs traditional (e.g. waterfall) software development methodology in the IT industry? And how fast the agile share is growing (assuming it is)?


title: Weighing pros and cons for using jQuery for just one widget

text: I have been using html select boxes or textboxes for date input. On submit, the date is validated and if invalid an error is returned. I have avoided javascript calendars thus far, but jQuery datepicker seems to be a popular choice amongst people on SO. I was updating my app and wondered whether to use a Javascript Calendar(jQuery datepicker in particular). It would be a good "feature" for existing users and will fit the "2011" upgraded look of the app. I am not using jQuery or anyother JS library. The scripts in use are "plain" javascript. With jQuery, I will have to include jQuery's library in the universal .js files list or link to Google's copy. Either way it will increase page load time. And I understand that with or without datepicker in place, the validation(and the error handling) stays and that the datepicker widget is for visual purposes only. But UI is an important factor. A positive that I can see is, I might use more of jquery in the future and I will not have to think about page load time and bandwidth issues then. So my question is, is lugging along jQuery the right decision, when I only see one use in the near future? Or should I use a "plain" JS only calendar widget or should I simply stick to the select or text boxes. Wanted to post this on SO, but since the topic is more about programming practices and decision making, I am posting the question here.


title: unique_ptr and references - coding style question

text: I'm pretty sure this is a question purely about aesthetics but I wanted to get all your opinions on it before I start proliferating this type of code in my codebase. Consider the following code:               //Foo.h     class Bar;     class Foo     {         public:            Bar& GetBar(){return *bar.get();}         private:            std::unique_ptr<Bar> bar;     };          //Bar.h     class Bar     {          public:              DoSomething(){//did something...}     };      This allows us to forward declare Bar in Foo.h and avoid having to #include Bar.h. This leads to using Foo's Bar in the following way:               Foo foo;     foo.GetBar().DoSomething();      Personally, I think this would look a lot nicer:               Foo foo;     foo.bar.DoSomething();      To achieve that, I've written:               //Foo.h     class Bar;     class Foo     {         public:             Foo();             Bar& bar;         private:             std::unique_ptr<Bar> bar_ptr;     };          //Foo.cpp     #include "Bar.h"     Foo::Foo() : bar_ptr(new Bar()), bar(*bar_ptr) {}      This allows me to forward declare Bar and use the 'bar.' syntax. Ugly? Not Ugly? The downside is that I have 2 member vars for only 1 object.


title: Which practice is the best for database connection? (PHP, etc)

text: Leave a open database connection throughout the execution of the aplication, or for each time a operation will be executed a new connection will be created? Open throughout the execution: Open aplication -> Open connection; Operations -> use the opened connection -> commit; Close aplication -> close connection; For each time a operation will be executed: Open aplication -> ...; Operations -> create connection, execute operation, commit, close connection; Close aplication -> ...;


title: any good book on Investment banking for IT professionals

text: I have been working as a Java developer for corporate Banking client. Now I want to step into an investment banking domain job. What sorts of resources (books, sites, etc.) can I use to understand investment banking so that as an IT Professional, I can become effective developing software applications for this domain?


title: How to make a random-access archive of text files?

text: I wrote an application that tests the performance of evolutionary algorithms. This application performs a **run** of the algorithm which consists of **several generations**. The data which is produced by my application looks like this:               run1.run             // text file containing metadata     run1_data            // folder containing experimental data        -statistics1      // text file containing some specific statistics        -statistics2             -generation0             -generation10     // snapshot of the algorithm at generation10        -generation20        ...      Once this data is written, **it is never changed**. When I want to **examine** the data, my application reads the **metadata** file (.run), opens the **_data** directory and reads the rest of the data. This was all fine until recently. I now have **hundreds of thousands** of these files and I ran out of inodes on my system and also the loading of the data and copying is extremely slow, even though there are only a few gigabytes. My data seems to be too fragmented, since the files are quite small. My application is written in **C++** and uses the **Qt** library for filesystem operations. I was thiking of using the `<system>` header to issue a `tar` command to archive data after writing and un-archive before reading, but I found out that `tar` must read the entire archive to find the contents. This is a problem for me, since to save operating memory and time I sometimes load only `Statistics1`, sometimes only `generation10`... I was considering to change the format of my data so that there would be **only one file** , which would have something like a **table of contents** at the beginning, followed by **all data files concatenated**. The table of contents would indicate the **beginning and end** of each concatenated file. However I am not sure if this is a good solutions since the `std::ifstream` class that I use to read the files **cannot make random jumps**. I am a beginner programmer and I do not want to waste a lot of time on developing something that would not work so I ask for any advice on how to solve my problem.


title: Responding to app feature requests I'm not going to implement

text: I'm a new app developer and after like 20 downloads of my app (free and ad- free) I already got two feature requests, and I'm not going to implement either. Should I respond to these feature requests and if so, how? I'd prefer not responding at all because I'd rather spend the time to work on my app, but being a new developer, a couple of poor ratings in the app store could hurt my app.


title: Supporting multitenancy

text: What are the typical challenges that arise when converting a single-tenant app into a multitenant app? Security and data isolation strike me as the most significant. What are some others? I'm one of the architects for a fairly significant automation effort, and historically it's just been our company using it. We want to make it possible for others to use it as well. Every time we talk about "making it multitenant", the conversation revolves around keeping users with one tenant away from the data that another tenant owns, and making sure that users with one tenant can't (either intentionally or inadvertently) create impacts in another tenant's environments. What I'm wondering is whether security/data isolation are really the only major concerns here, or whether there are some other major concerns that we're just not thinking about.


title: How to detect the encoding of a file?

text: On my filesystem (Windows 7) I have some text files (These are SQL script files, if that matters). When opened with Notepad++, in the "Encoding" menu some of them are reported to have an encoding of "UCS-2 Little Endian" and some of "UTF-8 without BOM". What is the difference here? They all seem to be perfectly valid scripts. How could I tell what encodings the file have without Notepad++?


title: How to search the web for programming related solutions?

text: I have the impression that Google has become unusable when searching for programming related questions. Example: I'm Googling for               XML-RPC Redstone Cookie      I'm expecting results where all three terms are contained. I don't care for results where one term misses. I guess until some months ago Google just worked this way, i.e. all terms were included. Somehow this feature is gone now (Google apparently thinks it is more intelligent than the user and knows what the user is searching for). So I helped myself putting a + in front of every word. This is, however, a bit cumbersome. And for the last weeks, it even doesn't work anymore in all cases, Google ignores the +. So how do you search for progamming related problems? Do you still use Google? If yes, which techniques do you use to get the right results? Or do you use another search engine? Which one?


title: Massive vehicular network simulator

text: I am interested in making a vehicular network simulator (vehicular network as in vehicles can be equipped with radios and when they come in range they can talk with each other). I want to be able to scale to 1000s of nodes if not more. I am quite frankly torn on how to do, or even which language to use or whether I should instead be using some other piece of software/code. I know that this should depend on a lot of design decisions that I may have, but it would be great if somebody can point me towards the right direction. I was planning to use a multi-threaded architecture, but not sure whether it will add to the complication or make it easier. Also if I go for a multi- threaded architecture, do you think that the Go language will be a good choice? I have a few years of experience in Java, but haven't done any big project, and essentially no experience in Go.


title: Ruby using the Gosu framework: why it runs slow first time?

text: I'm creating a Ruby game using the Gosu framework. All good. Sometimes, when I run the game, it has some kind of slow startup, and probably it will be rather slow during the whole game. So I close it and... open it again. It is very likely that it will startup quickly and the whole game will run smoothly and fast. Why is that? What is this phenomenon? Is it faster because of some cache stored or whatever since the first run? (But why would cache be stored? If the app dies, I would expect no references at all etc...) Ruby, Windows 7.


title: What is the way to go to extract data from websites?

text: I've been thinking about a side project that envolves web data scraping. Ok, I read the Getting data from a webpage in a stable and efficient way question and the discussion gave me some insights. In the discussion Joachim Sauer stated that you can contact the owners of the sites and architect some way to provide the data that I want. The problem I see is that the websites are generally badly created and apparently seldom have changes in HTML (I don't think they will help me), but the data is relevant. I have suffered a lot using those sites so I would like to aggregate and show them in a better way. So, going with scraping, specifically Scrapy (for python), is a problematic approach? I read that parse.ly uses scraping (Python and Scrapy), but in another context. Given my context, there's a better approach than going with scraping? If going with scraping, how to deal with website structure's changes?


title: Can CC0 code use a GPL library?

text: Suppose my code uses (simply links to) a library licensed under the GPL. Can I release _my code_ under CC0 (public domain dedication)? Is my code affected by the copyleft nature of the GPL?


title: use of script tag in different position of page

text: I found that sometimes the script don't run properly when I add script tag in the head section. But when I add script right before the ending tag of body it works fine. What is the difference between adding script in head tag   **OR**   on just before ending body tag   **OR**   right after the control? I found this issue very often when I use JQuery..


title: REST: How to store and reuse  REST call queries

text: I'm learning C# by programming a real monstrosity of an application for personal use. Part of my application uses several SPARQL queries like so:               const string ArtistByRdfsLabel = @"     PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>     PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>     SELECT DISTINCT ?artist     WHERE     {{         {{             ?artist rdf:type <http://dbpedia.org/ontology/MusicalArtist> .             ?artist rdfs:label ?rdfsLabel .         }}         UNION         {{             ?artist rdf:type <http://dbpedia.org/ontology/Band> .             ?artist rdfs:label ?rdfsLabel .         }}         FILTER          (             str(?rdfsLabel) = '{0}'         )      }}";          string Query = String.Format(ArtistByRdfsLabel, Artist);      I don't like the idea of keeping all these queries in the same class that I'm using them in so I thought I would just move them into their own dedicated class to remove clutter in my RestClient class. I'm used to working with SQL Server and just wrapping every query in a stored procedure but since this is not SQL Server I'm scratching my head on what would be the best for these SPARQL queries. Are there any better approaches to storing these queries using any special C# language features (or general, non C# specific, approaches) that I may not already know about? **EDIT:** Really, these SPARQL queries aren't anything special. Just blobs of text that I later want to grab, insert some parameters into via String.Format and send in a REST call. I suppose you could think of them the same as any SQL query that is kept in the application layer, I just never practiced keeping SQL queries in the application layer so I'm wondering if there are any "standard" practices with this type of thing.


title: Methods for efficient knowledge retention and fast study material lookup

text: When I read a book or article about something new, I have two main concerns:   1. Retaining the new knowledge I just acquired   2. Being able to access the new knowledge efficiently later on What are some methods you folks use to annotate what you learn? I recently read _Pragmatic Thinking and Learning_ and one of the things I'm trying out is making notes from books in mind-map format. Another method I'm trying out is tagging important passages in books with labels such as: definition, feature, remember, usage, caveat... It's too early to tell how these will work for me, but I'd like to know what works for you and how you use it. There are other questions asking what tools people use, but I think process is more important than the tool, so that's what I'd like to learn about.


title: How does throwing an ArgumentNullException help?

text: Let's say I have a method:               public void DoSomething(ISomeInterface someObject)     {         if(someObject == null) throw new ArgumentNullException("someObject");         someObject.DoThisOrThat();     }      I've been trained to believe that throwing the `ArgumentNullException` is "correct" but an "Object reference not set to an instance of an object" error means I have a bug. Why? I know that if I was caching the reference to `someObject` and using it later, then it's better to check for nullity when passed in, and fail early. However, if I'm dereferencing it on the next line, why are we supposed to do the check? It's going to throw an exception one way or the other. **Edit** : It just occurred to me... does the fear of the dereferenced null come from a language like C++ that doesn't check for you (i.e. it just tries to execute some method at memory location zero + method offset)?


title: Modern programming language with intuitive concurrent programming abstractions

text: I am interested in learning concurrent programming, focusing on the application/user level (not system programming). I am looking for a modern high level programming language that provides intuitive abstractions for writing concurrent applications. I want to focus on languages that increase productivity and hide the complexity of concurrent programming. To give some examples, I don't consider a good option writing multithreaded code in C, C++, or Java because IMHO my productivity is reduced and their programming model is not intuitive. On the other hand, languages that increase productivity and offer more intuitive abstractions such as Python and the multiprocessing module, Erlang, Clojure, Scala, etc. would be good options. What would you recommend based on your experience and why? EDIT: Thanks everybody for your interesting answers. It's hard to make a conclusion without actually trying since there are many good candidates: Erlang, Clojure, Scala, Groovy, and perhaps Haskell. I voted the answer with the most convincing arguments, but I'll try all the good candidates before deciding which one to pick :)


title: Visual programming for serious software

text: Are visual program control flow diagrams and languages which support that used for larger serious programs? Why not? They seem like a nice overview of the code. In the thread What software programming languages were used by the Soviet Union's space program? a visual language is mentioned (Drakon) and I wondered why such approaches aren't used more often? Is there nothing a visual control flow representation (I don't mean class diagrams etc.) which are 1-to-1 with code can help compared to typing in letters in an editor?


title: Experiments correlating code metrics to bug density

text: I'm wondering if someone has done some experiments correlating code metrics (SLOC, Cyclomatic Complexity, etc) with bug density in Object Oriented applications. I'm not looking for experiments that only prove or disprove a correlation, but on both. I'm not trying to find a silver bullet as I believe that the bug density of a project _might_ correlate to one or more metrics for a given project or team and the correlation can change during the lifetime of the project / team. My goal is to   1. Measure all interesting metrics for 2-3 months (we already have quite a few from sonar).   2. Find one metric that correlates with the number of new bugs.   3. Do a root-cause analysis to check why this happens (e.g. Do we lack a certain design skill?).   4. Improve the skill and measure change for a couple of itereations.   5. Rinse and repeat from 2. If you don't have any experience on this, but remember seeing a paper / blog on this subject, I would appreciate if you can share it. * * * So far I've found the following links with some information about this subject   * Do Bugs Reside in Complex Code? - just the slides from a presentation.   * Changes and Bugs: Mining and Predicting Development Activities - Just slides frmm a presentation. Bottom line the more dependencies, the higher the chances of bugs (I think this is quite a general rule).   * Failure is a four-letter word - A parady about the correlation between bugs and metrics.


title: User Generated Content and Hotlink Protection

text: I have a website that allows for users to paste content (like snippets of code, etc) for sharing. Like Pastebin and Github, I also have a "raw" link that will display the raw contents of those posts. However, some users are posting up code and then using our service as a host for distributing content that violates our TOS (for example, javascript code and then linking to that code from external sites). Running on NGINX and PHP, what is the best way to manage this? I have a feature that when reported, I can disable the raw version of a particular post. However, it is not feasible to monitor each and every post (and then be sure that I understand what is good / what is bad). Is my only solution to disable raw functionality across the board? Should I block the raw versions from sites like facebook (using referrer maybe)? I played around with hotlink protection, but in all truth, it doesn't really appear to work all that well (or it could be just my configuration of it).


title: Modelling network and persistent entity representations

text: I have an app where I need to synchronize some entities (simply download latest versions of entities from server to client). Entity has bunch of text properties and bunch of resource links (referenced by ids, URLs, whatever). For example let `Entity` has three properties:               id: integer,     name: string,     photos: array of photo ids      For now `Entity` is represented by two classes: one for persistent store (I'm using CoreData storage in iOS, you may consider it as ORM if you aren't familiar with iOS SDK) and one for JSON parsing and serialization called `Entity` and `JSONEntity` respectively. `Entity`               id: integer,     name: string,     photos: array of paths for files at local file system     pendingDownloads: object to track pending file downloads for `Entity`      `JSONEntity`               id: integer,     name: string,     photos: array of photo ids      I'm going to use the following algorithm:   1. call server API and obtain array of instances of `JSONEntity`   2. for each retrieved `JSONEntity`     1. find or create corresponding instance of `Entity` that should be updated     2. immediately update `name` property of `Entity` instance     3. associate `pendingDownloads` instance with current `Entity` instance `Entity` instance that have associated `pendingDownloads` object is considered as downloading and can't be used. When application starts:   1. find `Entity` instances that have non-null `pendingDownloads`   2. for each `id` in `pendingDownloads`     1. download photo     2. add local file reference to photo into `photos`     3. remove current item from `pendingDownloads`   3. null-out `pendingDownloads` property   4. notify model that `Entity` finished syncronization As for me the biggest flaw of current approach is that I have to keep two parallel hierarchies of classes - one for persistent store and one for JSON parsing/serialization. I tried to use inheritance: I declared newtork-level (like photo ids) properties in superclass and local-level (like file references) in subclass. But I don't like this approach either - object become overloaded with responsibilities - it have to track both network-level and local-level information. Are there any patterns or approaches to handle this kind of situations? Would be grateful for any thoughts. Thanks.


title: Full production build in source control for easy rollbacks?

text: I want a quick way to roll back our production build in the event of any mishaps - a one-click solution, if you will. My gut is telling me that this is important - and I believe that my gut is correct, but I want implementation advice. My current thought is to start a local repository on our production server, and simply commit the entire production build to the repo - binaries, web assets, everything. When we make an update to the production site, we can commit the changes to the repo. This way, if anything breaks for any reason and we need a quick rollback - it's simply a case of checking out the previous commit. What better methods are available for this type of rollback? I know that there are multiple backup solutions, but a VCS is familiar to work with and provides similar benefits. Am I stepping into a trap?


title: gnu lesser general public license question

text: I have a question about Thingiviews license. I have a site that has to do with 3D Printing, it is not done yet but I was wondering if I would be able to use it on my site, The big reason I am asking is because it will be used to show 3D models that will eventually be made and sold, like shapeways kinda, so I am not selling Thingiview but it would be used to show something that will eventually make money. Thingiview is currently licensed under: > GNU LESSER GENERAL PUBLIC LICENSE and from what I can gather, it seems that what I want to do should be okay, do I just need to give the creator of it credit? I will either way but it seems that is all that is required. Is what I want to do okay (by ok I mean legal)? Also if I want to change it I can do that too right, I have some ideas to add to it. Is there anything I would need to do if I change it a little bit?


title: Are there any scientific studies done on TDD that use total cost of ownership for a product as the measurement?

text: When I was reading the summary of previous work in _Dogsa T, Batic D. The effectiveness of test-driven development: an industrial case study. Software Quality Journal. 2011;19(4):643-661._ it struck me that the measurements used in a lot of studies around TDD are based on things like lines of code, defects and time spent on development. Are there any studies out there that focus on the total cost of ownership for products that have been developed using TDD vs ex traditional development or test-last? I am especially interested in the total cost of acquisition and operating costs.


title: Learning to investigate bugs

text: I'm not even sure how to define this difficulty. It reminds me of the test a couple of prospective employees did on me before I got a job. They would pick an object in the room and then I'd be allowed to ask questions to help myself determine what that object is (much like 20 questions). I was ridiculously good at this (no, I never got high points for humility), so I'd assumed that I'd be really good at troubleshooting bugs... But here's the thing I figured out recently. I'm really good in that situation because it's really easy to see everything that's in the room, thus I can approach my problem with some concept of it's component parts. In essence I "know what I don't know". But with programming I run into a lot of situations where the problem is a complete unknown to me. I know it's broken, but I have no concept of how it might be broken. I've followed all the instructions, I know the technology fairly well... If I'm honest, I feel like I'm just having a hard time imagining things that could be wrong so I can test them and, hopefully, find a solution. How do I go about developing that skill? What do I need to do to help my, apparently, limited imagination come up with ways that my project could possibly be broken? Are there exercises (puzzles perhaps?) that can make me better at this? I'm aware that probably the biggest cure is just experience...but I'm hoping to help accelerate the process if I can. Staring at my computer screen blankly for a few hours at a time is not even kind of fun...


title: Shall I separate the admin part from the rest of the war

text: I built a web-applicationg using struts2. Then I built a small admin interface in the same war. With time the webapp grew and so the admin-interface. Now, I'm thinking to separate the admin interface from the rest of the app in a separate war Is it a good idea ? Is there any performance benefit that I can get due to separation of the admin war and the rest of the webapp. The admin part is mostly about making changes/updations/settings in the database, so it's not affecting the UI of the rest of the app directly. Separating it also ensures that I can make updations to both parts without affecting the other. [UPDATE] I cannot put admin part on local machine. It's a web-app. `Do they use the same classes?` Nope, the entire package is different for admin actions and view is also separate. `How do you update them?` upload war `Do you use application session?` yes of course, although different sessions are used for admin & normal-user.


title: Mocking concrete class - Not recommended

text: I've just read an excerpt of "Growing Object-Oriented Software" book which explains some reasons why mocking concrete class is not recommended. Here some sample code of a unit-test for the MusicCentre class:               public class MusicCentreTest {       @Test public void startsCdPlayerAtTimeRequested() {         final MutableTime scheduledTime = new MutableTime();         CdPlayer player = new CdPlayer() {            @Override            public void scheduleToStartAt(Time startTime) {             scheduledTime.set(startTime);           }         }              MusicCentre centre = new MusicCentre(player);         centre.startMediaAt(LATER);              assertEquals(LATER, scheduledTime.get());       }     }      And his first explanation: > The problem with this approach is that it leaves the relationship between > the objects implicit. I hope we've made clear by now that the intention of > Test-Driven Development with Mock Objects is to discover relationships > between objects. If I subclass, there's nothing in the domain code to make > such a relationship visible, just methods on an object. This makes it harder > to see if the service that supports this relationship might be relevant > elsewhere and I'll have to do the analysis again next time I work with the > class. I can't figure out exactly what he means when he says: > This makes it harder to see if the service that supports this relationship > might be relevant elsewhere and I'll have to do the analysis again next time > I work with the class. I understand that the service corresponds to `MusicCentre`'s method called `startMediaAt`. What does he mean by "elsewhere"? The complete excerpt is here: http://www.mockobjects.com/2007/04/test-smell- mocking-concrete-classes.html


title: How to do dependency Injection and conditional object creation based on type?

text: I have a service endpoint initialized using DI. It is of the following style. This end point is used across the app.                public class CustomerService : ICustomerService     {         private IValidationService ValidationService { get; set; }         private ICustomerRepository Repository { get; set; }              public CustomerService(IValidationService validationService,ICustomerRepository repository)         {             ValidationService = validationService;             Repository = repository;         }                   public void Save(CustomerDTO customer)         {             if (ValidationService.Valid(customer))                 Repository.Save(customer);         }      Now, With the changing requirements, there are going to be different types of customers (Legacy/Regular). The requirement is based on the type of the customer I have to validate and persist the customer in a different way (e.g. if Legacy customer persist to LegacyRepository). The **wrong** way to do this will be to break DI and do somthing like                 public void Save(CustomerDTO customer)         {             if(customer.Type == CustomerTypes.Legacy)             {                 if (LegacyValidationService.Valid(customer))                     LegacyRepository.Save(customer);             }             else             {                 if (ValidationService.Valid(customer))                     Repository.Save(customer);             }         }      My options to me seems like   1. DI all possible `IValidationService` and `ICustomerRepository` and switch based on type, which seems wrong.   2. The other is to change the service signature to `Save(IValidationService validation, ICustomerRepository repository, CustomerDTO customer)` which is an invasive change.   3. Break DI. Use the Strategy pattern approach for each type and do something like:              validation= CustomerValidationServiceFactory.GetStratedgy(customer.Type);     validation.Valid(customer)      but now I have a static method which needs to know how to initialize different services. I am sure this is a very common problem, What is the right way to solve this without changing service signatures or breaking DI?


title: how to fully unit test functions and their internal validation

text: I am just now getting into formal unit testing and have come across an issue in testing separate internal parts of functions. I have created a base class of data manipulation (i.e.- moving files, chmodding file, etc) and in `moveFile()` I have multiple levels of validation to pinpoint when a `moveFile()` fails (i.e.- source file not readable, destination not writeable). I can't seem to figure out how to force a couple particular validations to fail while not tripping the previous validations. Example: > I want the copying of a file to fail, but by the time I've gotten to the > actual copying, I've checked for everything that can go wrong before > copying. Code Snippit: (Bad code on the fifth line...)               // if the change permissions is set, change the file permissions     if($chmod !== null)     {         $mod_result = chmod($destination_directory.DIRECTORY_SEPARATOR.$new_filename, $chmod);         if($mod_result === false || $source_directory.DIRECTORY_SEPARATOR.$source_filename == '/home/k...../file_chmod_failed.qif')         {             DataMan::logRawMessage('File permissions update failed on moveFile [ERR0009] - ['.$destination_directory.DIRECTORY_SEPARATOR.$new_filename.' - '.$chmod.']', sfLogger::ALERT);             return array('success' => false, 'type' => 'Internal Server Error [ERR0009]');         }     }      So how do I simulate the copy failing. My stop-gap measure was to perform a validation on the filename being copied and if it's absolute path matched my testing file, force the failure. I know this is very bad to put testing code into the actual code that will be used to run on the production server but I'm not sure how else to do it. Note: I am on PHP 5.2, symfony, using `lime_test()`. **EDIT** I am testing the chmodding and ensuring that the array('success' => false, 'type' => ..) is returned


title: System response times --- A good Service Level Agreement?

text: In order to view system performance, I have been asked by management to give page response times for a few key pages. I want to make sure I am giving a good picture of the overall health of the system, and not just narrowing in on a single measurement. So my question is: **When developing software, what metrics would you provide to your stakeholders to indicate a system that is healthy and running well?** (if it is not running well, that should also be evident! Not trying to hide/obscure any problems.)


title: Crappy school, what to do?

text: I started programming fairly late. I am 24 years old and about to graduate from a local public university with a really poorly designed curriculum and teachers. Most of the work felt like busy work, and no matter how much I try, it all feels like a waste. I know what a good curriculum looks like. I know what books I should read, but alas it's not so in my university. There is no way at this point that I can catch up to those graduating from places like MIT. My question and this is a serious one: what do I do? Do I just postpone learning the theory I would have learned until later and focus on software engineering skills? How important is the theory in terms of landing a job in New York? Any particular things I should focus on to land a software engineer job? I am very motivated and I just wish someone would give me the time and a chance.


title: What do you call "X <= $foo <= Y" comparison?

text: While writing a Perl statement like `if ( $foo >= X && $foo <= Y )` yet again, I wondered why many programming languages do not support the more comfortable form `if ( X <= $foo <= Y )` and what this is called. I came up with "3-legged comparison" but no results when searching for it. By the way there is also the "element-of-set" form `if ( $foo in X..Y )` which I only consider more readable when provided via a short keyword. Is there a term for `X <= $foo <= Y` comparison? Which languages support it?


title: Pair programming remotely with Visual Studio?

text: What tools exist to facilitate pair programming with Visual Studio when the programmers are not in the same physical location? At the moment we are thinking voice (Skype?) plus remote desktop (VNC? TeamViewer?), but it would be good to know of other suggestions and experiences. Also, is there anything more integrated with Visual Studio? A bit more background: we are two experienced developers with who have collaborated well for a long time on a large mature project (ASP.NET, Windows Forms and SQL Server). However we are not usually working on the same part of the code base at the same time. We intend to spend some weeks doing substantial refactoring and it would be ideal if we were able to do this work with a pair-programming approach.


title: How do you make CS students and future programmers aware of the various software licenses and their nuances?

text: To be specific: How would you include it as part of curriculum? Would it be too boring to just introduce them as a pure law subject? Are there any course structure available or can we derive one? What are the books that could be used? I would like to see that - after going through the course - candidate is well aware of "what software licenses are and what they are good for". Various implications of not knowing it in it's proper sense. What licenses they should use for their own code. What to consider when they are trying to use certain libraries or tools in their project and gauge risks/rewards associated with it. The idea is to let them make informed choices when they are professionals/practitioners in field of programming and not make them substitute for a lawyer or even a paralegal who is going to fight the case or draft things.


title: What are the main differences between FUML and the Executable UML profile?

text: I'd like to know what are the main difference between the Foundational Subset for Executable UML models and the Executable UML profile (which followed the Schlaer-Mellor methodology). Thank you


title: Mixing languages in .Net

text: I know that .Net provides the feature to mix several languages within the same application (there are some constraints of course, but this is not essential). Theoretically, this might be done because the languages supported by .Net do not fully expose all the features it can provide. IL does of course. So when you need a feature that the current language doesn't provide, you could write it in another .Net language. The whole code would be translated into IL, and so you would gain more features. From my personal experience, I was writing a project in C# and needed to integrate a small project written in C++ under .Net. When I consulted with some more experienced programmers, they said that it would be much easier to "translate" the C++ code into C# than integrate it. Since I had little time, it was what I did, and it was quite easy (the project was quite small). So my question is, has anyone experienced a real-life situation when mixing languages is an absolute necessity?


title: Is Non-Deterministic Resource-Management a Leaky Abstraction?

text: From what I can see, there are two pervasive forms of resource-management: deterministic destruction and explicit. Examples of the former would be C++ destructors and smart pointers or Perl's DESTROY sub, whilst an example of the latter would be Ruby's blocks-to-manage-resources paradigm or .NET's IDispose interface. Newer languages seem to opt for the latter, perhaps as a side-effect of using garbage collection systems of the non-reference-counting variety. My question is this: given that destructors for smart pointers or reference- counting garbage collection systems -- almost being the same thing -- allow implicit and transparent resource destruction, is it a less leaky abstraction than the non-deterministic types which rely on explicit notation? I'll give a concrete example. If you have three C++ subclasses of a single superclass, one may have an implementation that doesn't need any specific destruction. Perhaps its does its magic in another way. The fact that it doesn't need any special destruction is irrelevant -- all of the subclasses are still used in the same way. Another example uses Ruby blocks. Two subclasses need to free resources, so the superclass opts for an interface that uses a block in the constructor, even though other specific subclasses might not need it since they require no special destruction. Is it the case that the latter leaks implementation details of the resource destruction, whilst the former does not? EDIT: Comparing, let's say, Ruby to Perl might be more fair since one has deterministic destruction and the other hasn't, yet they're both garbage- collected.


title: Is there a manageable way of keeping track of loose code?

text: I program simple tasks everyday, but I have a hard time finding the scripts, and code snippets I write. Is there an manageable way to keep track of this sort of thing?


title: Should we write detailed architecture design or just an outline when designing a program?

text: When I'm doing design for a task, I keep fighting this nagging feeling that aside from being a general outline it's going to be more or less ignored in the end. I'll give you an example: I was writing a frontend for a device that has read/write operations. It made perfect sense in the class diagram to give it a read and a write function. Yet when it came down to actually writing them I realized they were literally the same function with just one line of code changed (read vs write function call), so to avoid code duplication I ended up implementing a do_io function with a parameter that distinguishes between operations. Goodbye original design. This is not a terribly disruptive change, but it happens often and can happen in more critical parts of the program as well, so I can't help but wondering if there's a point to design more detail than a general outline, at least when it comes to the program's architecture (obviously when you are specifying an API you have to spell everything out). This might be just the result of my inexperience in doing design, but on the other hand we have agile methodologies which sort of say "we give up on planning far ahead, everything is going to change in a few days anyway", which is often how I feel. So, how exactly should I "use" design?


title: Doubt regarding search engine/plugin(One present on the website itself)

text: I am new to web development and trying to study various types of websites as case study. Right now my focus is on how search engines works for an eCommerce website. I know basic functioning for a search engine, i.e. crawl web pages, index them and the display the results using those indexes. But I got little confuse in case of an eCommerce website. Don't you think that it would be better if a search engine instead of crawling the web pages containing products, it should directly crawl the database and index the products stored in the database? And when a user search for any product, it will simply give us the rows of the table which matches the user query? If this is not the case, can someone please explain how the usual method works on eCommerce website?


title: XMPP— openfire, PHP and python web service

text: I am planning to integrate real time notifications into a web application that I am currently working on. I have decided to go with XMPP for this and selected openfire server which I thought to be suitable for my needs. The front end uses the strophe library to fetch the notifications using BOSH from my openfire server. However the notices are the notifications and other messages are to be posted by my application and hence I think this code needs to reside at the backend. Initially I thougt of going with PHP XMPP libraries like XMPHP and JAXL but then I think that this would cause much overhead as each script will have to do the same steps like connection, authentication etc. and I think this would make the PHP end a little slow and unresponsive. Now I am thinking of creating a middle-ware application acting as a web service that PHP will call and this application will handle the XMPP service. The benefit with this is that this app (a server if you will) will have to connect just once and it will sit there listening on a port. I am also planning to build it in a asynchronous way such that it will first take all the requests from my PHP app and then when there are no more requests; go about doing the notification publishing stuff. I am planninng to create this service in Python using SleekXMPP. This is just what I planned. I am new to XMPP and this whole web service stuff and would like to take your comments on this regarding issues like memory and CPU usage, advantages, disadvantages, scalability issues, security etc. PS:-- also if something like this already exists (although I didn't find after a lot of Googling) Please direct me there. EDIT --- The middle-level service should be doing the following (but not limited to): 1. Publishing notifications for different level of groups and community pages. 2. Notification for single user on some event. 3. User registration (can be done using user service plugin though). EDIT --- Also it would need to create pub-sub nodes and subscribe and unsubscribe users from these pub-sub nodes. EDIT -- Working with Twisted-Python to develop the REST API part now(had to chose between XML_RPC and REST) will keep updating this question as I go along. Also I want to store the notifications and messages in a database (openfire doesn't). Would that be a good choice?


title: MVC two models required?

text: I've been doing software for a long time, but almost all of it has been back- end centric. I recently decided to learn Swing and tried to apply MVC principles. I realize that in Swing the View is handled for you by the components you add to the window/frame/panel, and the Controller is your code responding to the events. However, when it comes to Model I quickly found that I needed TWO models. One is the back-end model representing the underlying data universe. That model is completely unaware of the UI and the fact that it's even being displayed. The second is a version of the model with additional attributes governing display- related aspects. For example, the project I chose was a tool that cross-references the database instances, schemas and tables in a huge enterprise application containing 140 db instances, several hundred schemas and thousands of tables. Sometimes when looking at unfamiliar code you have a table name but finding which instance and schema it's in is a chore. The tool displays 3 columns: DB Instance, Schema and Table, and each column contains only unique names. When you click on a table name (for instance) the schema and instance columns get filtered showing where that particular table occurs. Clicking on a schema name or instance name results in similar filtering behavior on the other two columns. ![Schema Crossreference Tool UI Sample](http://i.stack.imgur.com/tFWme.png) I have a backend model containing a three-level tree (Instance, Schema, Table) but this is inappropriate for the UI I want to display. So I have a second "display-model" that is built from the backend model, and backs the three columns. That is where I store flags indicating which entries are visible based on user input. The two models are significantly different in structure, and the display-model entries contain references to the backend-model entries. In a sense the display-model entries are adapters that allow the backend-model entries to be handled in a display-appropriate way. I haven't run across any references to this, but my gut feel is that this must be a very common problem. Has anybody else run into this issue, and what are the "accepted" UI programming ways to accomplish the objective?


title: Does using a wrapper class for pointers make sense?

text: In C++, pointers generally have a lot more functionality associated with them than is really necessary. A class template that wraps a pointer and removes most of the less-used features (arithmetic, indexing, deletion). Each function could then decide how powerful a pointer it requires and take the appropriate type. Would using such types make sense in an actual project, though? Are errors caused by unintentional arithmetic/deletion common enough to justify the additional effort? To clarify: I am considering this as a system alongside existing `weak_ptr`, `shared_ptr`, `unique_ptr` -- those three are great when ownership is involved, but sometimes non-owning nullable or reseatable references are useful.


title: Is nesting typedefs a good style?

text: Let's say I have a namespace `my` and this namespace contains a class `foo`. What should I prefer nesting typedefs into my class or hold it in my namespace?               namespace my {          class foo {       // some stuff            // nested one       typedef bar my_foo_bar;          };          // or namespaced one     typedef bar my_foo_bar;          }      Looking at the std-libs most things are the namespace variant. (maybe a bad example but...) istream is not nested in iostream (at this point I only mean the way of using -> std::fstream, std::istream, ...), so I can use it directly. but also the list of possible functions is quite huge in std:: I could do both. The first variant is more encapsulated but also if I have to much inheritance I have to type a lot (my::foo::inh::and::so::on) if I won't use `using [namespace]`. First I thought the nested variant is more nice because of the encapsulation of what I want to have in the same "group". I also could do a new namespace inside my, but then I have also to type every time the new namespace (also without using [namespace]).


title: What to look for in a training course

text: My development team is looking to expand into some new areas that we don't currently have direct skills for. We're trying to evaluate the available training courses, but there's not much depth of differences that you can plumb from a webpage or two and a brochure. So the root of my question is what should we be looking for while selecting a training course? I think the best approach at this point is to send an RFC (request for comment) to the firms we've identified and ask the following:   * syllabus of coursework   * amount of hand's-on-work versus lecture   * preparatory references they recommend   * instructor biographies   * rough estimates of number of students trained*   * amount of time in training*   * amount of time in training on _this_ subject*   * results of end-of-class student satisfaction surveys   * expected student background   * general class size   * how they tailor the course to the individual student's needs *No, these aren't great measures for the quality of a courses but I struggle to identify a more relevant metric. **The Real Question(s) -->**   _What else should we be asking about or investigating?_   _Is there a superior approach to evaluating training courses?_ This question is perhaps the closest to answering my question, but it didn't gain much traction. In addition, it seems oriented towards how to design the course instead of what to look for. This question is related, but the person asking the question didn't appear to want the training. That's definitely not our situation - we have a known skills gap and we're looking to close it. The links from this question didn't really have any content that met my needs. This question and this question are related to the training (iOS development) we're particularly interested in. The questions are slightly stale, which is part of why they are off topic for P.SE. One nugget that I liked from these two questions was to purchase and review books published by the training firm if they're available.


title: Guidelines for returning collections from public functions

text: ## The Problem Imagine you have a function in a public API that needs to return some kind of collection. Its type is something like               foo :: a -> b      where `b` is some kind of collection. As far as I can see, there a three major kinds of collections -- at least those are the ones used most often:   1. Sequences (order matters, there might be duplicates)   2. Sets (order doesn't matter, no duplicates)   3. Maps (elements are key-value pairs, order doesn't matter, no duplicate keys) What should you use for `b` in these three cases?. I have considered three alternatives, but there might be more. * * * ## A. Just return a list In this alternative, you just return lists for everything:   1. `foo :: a -> [c]`   2. `foo :: a -> [c]` (and document that there are no duplicates)   3. `foo :: a -> [(k, c)]` (and document that there are no duplicate keys) The advantage of this is that the client can construct any collection they want from the returned list. The disadvantage for 2 and 3 is that   * the type does not have the "no duplicates" guarantee and that the client has to do more work to get a set/map out of it   * construction of the list in 2 and 3 might be less efficient, because something like a `union` for sets is obviously faster than for lists   * you might construct an intermediate list (depends on the problem at hand). ## B. Return a concrete type matching the guarantees In this alternative, you return a type that precisely matches the guarantees you are giving:   1. `foo :: a -> [c]` (or maybe `foo :: a -> Data.Sequence.Seq c`)   2. `foo :: a -> Data.Set.Set c` (lazy or strict?)   3. `foo :: a -> Data.Map.Map k c` (lazy or strict?) The advantage is that the type accurately describes the guarantees you want to express and that the client doesn't have to do any extra work. The disadvantage is that you're locked into a particular implementation. If you just want to switch to a different set implementation, you break the public API. That might be a good thing in case of a switch between lazy and strict, because those can matter for correctness of the calling code. But in general you want to be able to swap implementation without your clients noticing. ## C. Let the client decide In this alternative, you just constrain the return type with a type class and let the client decide on the concrete type:               1. `foo :: Sequence b c => a -> b`     2. `foo :: Set b c => a -> b`     3. `foo :: Map b c k => a -> b`      (The names I used are from collections-api, but it doesn't really matter.) The advantage of this is that the client can choose which collection type to use. The disadvantage is that you have no control over the collection you construct anymore. This means, e.g., that you cannot assume laziness or complexity of inserts. Another problem is that the client can get ambiguous types, e.g., when they immediately fold the returned collection:               Data.Foldable.fold (foo whatever)      Now `b` is ambiguous. * * * Are there any other alternatives? What would you recommend? I **don't** want `foo` to be able to return a different kind of collection on every call. The three cases considered are completely separate. In each case the question is "if I have a function that needs to return an X, what type should it have?" where X can be a sequence, set, or map (or any other kind of collection you can think of).


title: Should duck typing affect naming conventions?

text: I'm a C++/C# developer and recently I've started to learn Python. I think I understand the concept of duck typing right now except for one thing. When I'm coding in C++ or C# I sometimes create completely unrelated classes that have similar methods with similar signatures, for example: Create(), Open(), Close(), ProcessData(), etc. It's not a big deal in C++ or C# (unless you want to mess with C++ templates), but in languages with duck typing like Python this could cause a disaster. Consider the following example:               class DbTransaction:         def rollback(self):             pass          class SourceControlChangeset:         def rollback(self):             pass          def rollback_transaction(transaction):         transaction.rollback()          transaction = DbTransaction()     changeset = SourceControlChangeset()     rollback_transaction(transaction)     rollback_transaction(changeset) # Oops!      Maybe be example is a bit artificial, but I think this could happen pretty easily in a big project with many classes. What should I do in this situation? I think that type checking is not "pythonic" so my only idea is to change naming convention for class methods like this:               class DbTransaction:         def rollback_transaction(self):             pass          class SourceControlChangeset:         def rollback_changeset(self):             pass      Any ideas?


title: Should a lexer un-escape strings?

text: Is it a lexer's job to undo any escaping done to a string literal? For example:               "Me: \"Hello World!\""      Becomes:               Me: "Hello World!"      Should this conversion be done inside the lexer? I am guessing it should, because it'd allow for a more abstract and modular design. You could add ways to represent strings and you won't have to update every component.


title: Who should be responsible for writing/updating design specifications in an agile team

text: I work as part of a scrum-like Agile team and a while ago, one thing we identified that the team should do is maintain good set of design documents for our code base. Because we are agile and do have good amount of discussion and communications, our designs are kept at a high level and are generally used for describing general layout of modules, including main classes and some of their interactions and. We also found them useful for discussion starting points since and also for reminding people that design needs to be considered before you jump into code. So far, it was expected that everyone will update design specs on as needed basis. Design leads for each team are responsible for giving people advice on design in general, on what to update in the SDSs and also for reviewing the specs to make sure everything stays consistent. The issue I'm seeing is that while everyone, especially new members find design specs very helpful when learning new components or even going back to components they haven't touched for a while, most people only update the docs for the sake of updating them (i.e. they are told they must do it and so they do it). So that we end up with one-liner descriptions which sometimes aren't even full sentences and when I tell them this needs to be updated and filled in, they add more but again, only because they are told. So now one-liners become 1.5 lines and there's still nothing helpful written down. Obviously different team member skills/strengths will be different. So the question is, should certain team members on an agile team simply not be responsible for design and be reduced to just a coder? Or should it be design leads role to go back to those team members and make them rewrite the specs as many times as necessary (and this is really becoming painful) until they pick up enough skills to produce what's expected? My basic guideline that I suggest to everyone: if you were sitting in a meeting or making a presentation about class diagram X, what would you say if your audience needed to know how your code works. Instead, half the time they simply restate what I can already see in the class diagram. "Class X implements interface Y". That would be entire class description. **Amendment:** I work for a large corporation with a very healthy appetite for outsourcing/contracting. The team I'm on has permanent members, it also has permanent members who are very new to the team (from recent merger). And we have contractors from India and Poland who will most likely be reassigned to other project after the current release. So different members have different buy-in at this point. Documentation is definitely important to those of us that have been on the project in the last release and will be on the project in the next release.


title: Getting graduates up to speed?

text: This question got me thinking about how comapnies deal with newly-hired graduated.   * Do experienced programmers expect CS graduates to write clean code (by clean I mean code easily understandable by others -- maybe that is too much to expect?)   * Or do significant portion of graduates at your place (if any) just end up testing and fixing small bugs on existing applications?   * And, even if they do bug fixes, do you end up spending double the amount of time just checking they did not end up breaking anything and creating new bugs? How do you deal with such scenarios when pair programming and code reviews are not available options (for reasons such as personal deadlines), and also what techniques did you find to get fresh graduate up to speed? Some suggestions would be great.


title: Agile project management, agile development: early integration

text: I believe that agile works if everything _is agile_. In software development area, in my opinion, if team members' code is integrated early, code will be more in sync and this has a lot of pros:   * Early integration helps team members to avoid painful merges.   * Encourages better coding habits, because everyone makes sure that they don't break co-workers' code everyday.   * Both developers and architects ( _code reviewers_ ) may detect bad design decisions or just _wrong_ development directions in real-time, preventing useless work. Actually I'm talking about getting the latest version of code base and checking-in your own code to the source control in a daily basis. When you start your _coding day_ (i.e. you arrive to your work), your first action is updating your code base with the latest version from the source control. In the other hand, when you're about an hour to leave from your work and go home, your last action is checking-in your code to the source control and be sure that your day work doesn't break the project's build process. Rather than updating and checking-in your code once you finished an entire task, I believe the best approach is fixing small and flexible personal milestones and checking-in the code once you finish one of these. **I really believe that this coding approach fits better in the _agile_ project management concept**. **Do you know some document, blog post, wiki, article or whatever that you can suggest me that could be in sync with my opinion?**. And, **do you find any problem working with this approach?**. Thank you in advance.


title: Can Excel be a strong development platform?

text: We are a group of enthusiast engineers who are developing a series of application using Excel as our front end. We are using VBA but plan to start doing in VB.net. Some people in IT have questioned the wisdom of using Excel as a platform because it crashes, it's unsafe, difficult maintain, slow, etc.


title: Separation of development responsibilities in a new project

text: We have very recently started a new project (MVC 3.0) and some of our early discussion has been around how the work and development will be split amongst the team members to ensure we get the least amount of overlap of work and so help make it a bit easier for each developer to get on and do their work. The project is expected to take about 6 months - 1 year (although not all developers are likely to be on and might filter off towards the end), Our team is going to be small so this will help out a bit I believe. The team will essentially consist of:   * 3 x developers (All different levels i.e. more senior, intermediate and junior)   * 1 x project manager / product owner / tester   * An external company responsbile for doing our design work General project/development decisions so far have included:   * Develop in an Agile way using SCRUM techniques (We are still very much learning this approach as a company)    * Use MVVM archectecture   * Use Ninject and DI where possible   * Attempt to use as TDD as much as possible to drive development.   * Keep our controllers as skinny as possible   * Keep our views as simple as possible During our discussions two approaches have been broached as too how to seperate the workload given our objectives outlined above. **OPTION 1** : A framework seperation where each person is responsible for conceptual areas with overlap and discussion primarily in the integration areas. The integration areas would the responsibily of both developers as required.               View prototypes (**Graphic designer**)              |               - Mockups                    |     Views (Razor and view helpers etc) & Javascript (**Developer 1**)              |               - View models (Integration point)              |     Controllers and Application logic (**Developer 2**)              |               - Models (Integration point)              |            Domain model and persistence (**Developer 3**)      **OPTION 2:** A more task orientated approach where each person is responsible for the completion of the entire task (story) from _view_ -> _controller_ -> _model_. **QUESTION:** For those who have worked in small teams developing MVC projects how have you managed the workload distribution in this situation. I can't imagine the junior would be responsible for building parts of the underlying architecture so would given them responsibility for the view make sense considering we are trying to keep it simple?


title: Is there a way to develop desktop software using PHP?

text: I have to develop a real estate marketing CRM software for my client - where the application is installed on desktop but can also be accessed from web. 2 reasons why they want the application to run from desktop :   1. So that it can work with/without internet connection   2. They don't want their complete data to be online  They want to access few of the data like property listing & inquiries (managed from desktop application) from their website through secure login & password. The data that is entered in desktop application should be automatically synchronized with the website application. I was wondering if there is a way to develop this kind of software using PHP & MySQL. If yes, it will be great if anyone can provide me the referral link.Else please suggest, which language should I use.


title: Binding in the view or the controller?

text: I've seen 2 different approaches with MVC on the web. One, like in ExtJS, is to bind the callbacks to the view via the controller. Finding every element on the view and adding the functionallity. The other, like in angular.js and in the lift framework, is to bind in the views and just write the functionallity in the controller. Which is better and cleaner? The ExtJS approach has dumb views and all the logic in the controller which seems clean to me. I had problems with global IDs for GUI-elements or relative navigation to GUI-elements in this approach. When I changed the view, the controller couldn't find the buttons anymore or I had multiple instances of one button with the same ID on a single application, because of the global ID. But I solved this with IDs that are only global in a view and can be on the application multiple times. So I could mess with the (dumb) views layout and design and the functionality wouldn't break. The angular.js approach with the bindings in the view doesn't have the problem with global IDs. Also, the person who changes something in the view layout has to know the IDs anyway, so the controller can put the data at the right spot. So if I write                     for angular.js and implement `doThis()` or                     for extjs and find the element with the local id and add `doThis()` as the handler on the controller side, it seems to not be so different. The only thing is, the second one has one more layer of indirection, which seems cleaner. The first one seems less effort.


title: Understanding the static keyword

text: I have some experience in developing with Java, Javascript and PHP. I am reading Microsoft Visual C# 2010 Step by Step which I feel it is a very good book on introducing you to the C# language. I seem to be having problems in understanding the static keyword. From what I understand this far if a class is declared static all methods and variable have to be static. The main method always is a static method so in the class that the main method exists all variables and methods are declared static if you have to call them in the main method. Also I have noticed that in order to call a static method from another class you do not need to create an object of that you can use the class name. What are the advantages of declaring static variables and methods? When should I declare static variable and methods?


title: is there any future with computer programming without the knowledge of science?

text: my main subjects are commercial studies and computer **applications**.I dont have knowledge of science. Is there a good career which involves both the subjects.


title: Using all the parameters of a function

text: Code Complete (2nd ed.) says: "If you pass a parameter to a routine, use it. If you aren't using it, remove the parameters from the routine interface." However, in the past I sometime had to do that. Consider the following example: Assume that we have an abstract base class called `Food`, containing a pure virtual function called `getEaten`. We derive two separate classes from it:               class Apple : public Food     {         void getEaten(const Utensil &utensil);         // otherstuff     };      and               class Soup : public Food     {         void getEaten(const Utensil &utensil);         // otherstuff     };      When we call `mySoup.getEaten(spoon)`, the function makes use of the `spoon` parameter in order to perform the action. However, an apple does not need a utensil, and in those cases I have to send a dummy utensil to `myApple.getEaten(emptyUtensil)`. Yes, this is ugly, and has the overhead of unnecessarily creating and passing a dummy object. I can generalize the problem like this: "When we have two concepts, which are represented as two classes, have the same action applied on one of them, and one needs more information than the other when requesting to execute those actions, I tend to pass dummy information to the less information requesting objects." So my questions are: 1) How can we change the design of this somewhat silly example, so that we don't need to pass the dummy utensil? 2) If there is a nice simple solution to the first question, would there be a way to generalize it to the generalized problem above (like solutions as "in those cases create a new x such that it interacts with the less informating demanding class like this" etc.)


title: Git: Branch or Fork?

text: I have game project that will have two versions:   1. A simple version of the game, the core   2. An advanced version of the game. I have the 1st version in my public repository and only I will be working on it. As for the 2nd version, me and two friends of mine will work on it. The crucial part is I want the two versions stay in my repository. I though I might use branches for this, but considering this question and its answer, it's not good practice to do so in terms of versioning. As far as I've found out, forking your own repository is not possible. What are my options here? How can I keep both versions in my repository?


title: Web Usage Policies at "Best Companies to Work For"

text: For any company that has made it onto a "Best Companies to Work For" list* in 2010 that hires programmers, what restrictions on web usage do they have in place? Does that company view unrestricted internet access as a benefit to their employees even if they might use it for non-work related reasons? If you can provide a link to back up this information, even better. (* I don't want to promote any specific publication, but they are easy enough to find.) My hypothesis is that a company that aspires to be one of the best needs to provide fairly unrestricted internet access and I'm trying to test it.


title: What is the Loopback Pattern?

text: I was reading this blog post about Hexagonal architecture and at the bottom it says: > The Loopback pattern is an explicit pattern for creating an internal > replacement for an external device. When I google for "Loopback pattern" I don't find any details about it. Does anyone know what the author is referring to? For curiosity's sake, I'd like to know how to implement this.


title: What should happen at the start of a software project startup?

text: ## A quick introduction My college semesters include a 8 week project working for an actual company with a software need in order to get some much needed practical experience. I have just started such a project with 5 other students. We're required to spend roughly 40 hours a week per student on this project. We're working with SCRUM as the software development method, this was assigned by our teachers. ## The question Day one of the project just ended which has created some questions for me as to how to start a project in the 'real world'. Our first day included working on a project planning document (not sure what the English term is), creating a appointment with the company for an introduction and the opportunity to start specifying the requirements and setting up some standards for the behavior within the group. However these items didn't take that long to finish. We've made some concrete plans for tomorrow and the day after we'll meet the company. This still leaves several hours of 'work-time' unspent. Is it usual not being able to fill every hour of a day for work at the start of a project or are we simply too inexperienced to see what work needs to be done at this stage of a project, or are we, perhaps, going through the above list too fast? How does this work in the 'real world'? Do you spend your time wondering 'what should I do now', or do you have a clear view of what you're supposed to do at that moment?


title: is jargon related to a frameWork (concept)

text: If this is not the right place to ask this question please inform where it would belong, to change it... I have a doubt for the correct word or concept in english language [not my native], about the relationship of > language to framework for example i work with > objective C, with the cocoa touch frame work || python with the django frame > work My comparison is between natural languages and formal languages, So would be in a natural language > english and the frame work a [computer, it]jargon? Does this make sense? Or what other concept would be the relationship between natural language - framework?


title: Why the current enthusiasm for Functional Programming?

text: I've been hearing a lot of enthusiasm about functional programming languages lately, with regards to Scala, Clojure, and F#. I've recently started studying Haskell, to learn the FP paradigm. I love it, it's really fun, and fits my math background. But will it ever really matter? Obviously, it's hardly a new idea. Here's my questions:   1. What has contributed to the recent FP enthusiasm? Is is merely boredom with OO, or has something changed to make FP more needed than before?   2. Is this indicative of a FP future? Or is this a fad, like object orient databases? In other words, can anyone help me understand where this comes from and where it might be going?


title: JavaFX - the right way to use Properties with domain objects

text: JavaFX has provided a bunch of new Property objects, such as `javafx.beans.property.DoubleProperty` which allow you to define fields which can be automatically observed and synchronised. In many JFX examples, the MVC model class has a number of these Property fields, which can then bind automatically to the view. However, this seems to be encouraging us to put JFX properties into our Domain objects (if you assume that the Model class is going to be a domain object), which strikes me as a poor separation of concerns (i.e. putting GUI code in the Domain). Has anyone seen this problem being solved in 'real life' and, if so, how was it done?


title: Repurpose MySQL as a mutex

text: My application needs to perform an operation once every 10 minutes, but that operation is triggered many times more frequently. Occasionally it is triggered three or four times a second in different processes, and that's the main thing I want to avoid. It's Django, and at first I used the `django.core.cache` feature, but I am still getting more than one worker performing the operation simultaneously. I have Redis also, and know that WATCH and MULTI can be used to prevent race conditions, but the django-redis library doesn't support them. This is my solution; please comment on how well (or not) it prevents multiple workers (processes) from performing the operation simultaneously:   1. Have a MySQL table with fields `when` and `uuid` and just a single row starting with both NULLs.   2. When a worker is told to start the operation, it quits early if `when` is less than 10 minutes ago.   3. Otherwise, generate a UUID and store it in the table, updating `when` to `NOW()` in the same query.   4. Then, select the row and quit early if `uuid` doesn't match the one just generated.   5. Otherwise continue with the operation This relies on MySQL enforcing the order of reads and writes and enforcing that only one query access the row at once, which may be invalid assumptions. Any alternative ways of keeping Celery processes from running a task simultaneously would be just as helpful.


title: What is the difference between debugging and testing?

text: Introduction To Software Testing (Ammann & Offutt) mentions on p.32 a 5-level testing maturity model: **Level 0** There’s no difference between testing and debugging. **Level 1** The purpose of testing is to show that the software works. **Level 2** The purpose of testing is to show that the software doesn’t work. **Level 3** The purpose of testing is not to prove anything specific, but to reduce the risk of using the software. **Level 4** Testing is a mental discipline that helps all IT professionals develop higher quality software. Although they don't go into much further detail. What are the differences between debugging and testing?


title: C++ Data Server and J2ME client communication

text: I am working on a robot that has some AI built in. However, the mandated robot controller does not have the power to do the work onboard. This means that I need to use a co-processor. I am writing all of my AI in C++. This will also be a TCP server. I have an idea for the protocol. The C++ server receives commands and only sends back values when absolutely required. The String for a basic command would be:               REQUEST DATA PUT data storename ENDREQ       The C++ server would parse the request and store data under the reference of storename. To read data from the server:   The Java request would be:               REQUEST DATA GET storename ENDREQ      The server will reply with:               data      I will be using TCP for the transmission of data because it seems much more robust and easy to implement using the libraries that I am using. I am not too knowledgeable when it comes to Java, especially with J2ME. How to implement the Java side? CHANGE: It is quite easy for me to implement a web server on the C++ side, so please feel free to use HTTP for the protocol!


title: Why is Throwable initCause designed to be called only once?

text: I find it really odd that the `initCause` method of Java's `Throwable` class can only be called once, or even not at all (if the constructor accepting a `Throwable` was used). This makes exception chaining not as easy as I think it should be.               private Throwable cause = this;          public Throwable(String message, Throwable cause) {         ...         this.cause = cause;     }          public Throwable getCause() {         return (cause==this ? null : cause);     }          public synchronized Throwable initCause(Throwable cause) {         if (this.cause != this)             throw new IllegalStateException("Can't overwrite cause");         if (cause == this)             throw new IllegalArgumentException("Self-causation not permitted");         this.cause = cause;         return this;     }      It leads to ugly boilerplate code that has to take care of edge cases where the method _may_ have already been called, but the part of the code where you want to call it again, you're not sure. What is worse is that the `getCause` method does not correctly tell you whether `initCause` method had been called or not. This is because someone else could have called `initCause(null)` and this would make `getCause` to return `null` while at the same time have `initCause` fail with `IllegalStateException` (because `null != this` is true). The result is a boilerplate code as follows:               try {         exp1.initCause(exp2);     } catch (IllegalStateException ise) {         // do something or ignore     } catch (IllegalArgumentException iae) {         // do something or ignore     }      Whereas I should be able to simply call `exp1.initCause(exp2);` without caring whether it's the same exception or the method had already been called (and let the method take care of what to do if either of the condition was true; _for example_ simply ignore the new cause). **What is the reason behind such an odd design?** **_Edit:_** I would like to clarify that I don't have a problem with the cause being immutable. My problem is that, ensuring such immutability is not violated is made a burden for the programmers, rather than being handled automatically by the implementation. It would have made more sense to me if the cause was implemented as follows:               private Throwable cause; // null means no cause          public Throwable(String message, Throwable cause) {         ...         this.cause = cause;     }          public Throwable getCause() {         return cause;     }          public synchronized Throwable initCause(Throwable cause) {         if (this.cause == null)             this.cause = cause;         return this;     }      Or even if the **original** implementation was kept, a handy method could have been added:               public boolean hasCause() {         return (this.cause != this);     }      So that I could reduce the boilerplate code to simply:               if (!exp1.hasCause()) exp1.initCause(exp2);      I would also like to clarify that this is not a question of which Java version I should be using, or whether I should continue using versions of Java that have reached their support's end-of-life. There are many reasons why older versions of Java continue to be used other than _"lazy to upgrade"_ or _"don't care about security"_. `:)`


title: Should Multiple Data Items be in Multi Unit Test Methods?

text: I often want to have the same unit test applied to data multiple items that are roughly equivalent (two non-empty strings). Currently I implement these in multiple unit test methods, with names like `MethodNonEmptyValidString1` and `MethodNonEmptyValidString2`. This has a bit of a code smell to me. Is it better to have the multiple data items in one method with multiple asserts? Is there another design pattern that models this more accurately?


title: mysql, one connection vs multiple

text: On nodejs with node-mysql, should I create one connection for the service like this:               var client = mysql.createClient({         user: 'user',         password: 'pass'     }); // Create a new mysql Client     io.sockets.on("connection", function (user)) // when a user enters     {         result = client.query('check user'); //check for user on DB         if (result) {             user.on('do stuff', function (data) // set to do something on ask             {                 client.query('some stuff'); //run the mysql client to work             });         } else {             user.disconnect();         }     });     }      or or for each user like this:               io.sockets.on("connection", function (user)) // when a user enters     {         var client = mysql.createClient({             user: 'user',             password: 'pass'         }); // Create a new mysql Client when the users enters         result = client.query('check user'); //check for user on DB         if (result) {             user.on('do stuff', function (data) // set to do something on ask             {                 client.query('some stuff'); //run the mysql client to work             });             user.on('disconnect', function (data) {                 client.close();             });         } else {             user.disconnect();             client.close();         }     }      What I'm asking is:   * is the first one faster because the connection is always open and on the second one it needs to create every time a user connects?   * is the first one slower because if many users are asking for queries he only does one at the time, and on the second one each one have his own client and can make multiple connections at the same time?   * is the second one heavier for the node server and for the mysql because it needs to have 1 client for each user?   * is the first one heavier because it never closes the mysql connection, and after some queries may have some memory leaks?   * or should I create and close a mysql connection for every query? PS: the application connected to the node server will have a big number of users, connected during a long period of time, but will have a very low number of queries, but the users probably will ask for queries at about the same time.


title: Content CDNs and dynamic content

text: I am curious as to how dynamic web applications play with content delivery networks such as cloudflare, amazon cloudfront, etc. I understand the concept of a cdn obtaining a cache of your static pages and then serving those pages from their various servers relative to where the request is coming from. However when it comes to applications that are database heavy that require user sessions, allow for searches, and other user interaction is a cdn still useful? If the answer is yes, does the cdn crawl your server and create caches of all of the pages that could be created dynamically? If this is true then how is sensitive data handled? (For example if your application is pulling profile information specific to a user that only that user should have access to.)


title: How to avoid redundant code in designing inheritance in C++

text: Say I have a Base class called `Car` and it has 3 derived classes say `Ford`, `Honda` and `Audi`. The issue is, all three derived classes have exactly same code but minor difference in calling member functions of their respective engines (these engines have separate class). For example, `Ford` class calls code which is exactly same as other two classes but do call something like `ford_engine-> start()`, `ford_engine->clean()` etc.               //ly  honda  calls   honda_engine->start()   honda_engine->clean();          //ly  Audi calls audi_engine->start()  audi->clean();      Now here the issue is, it has redundant code in all three places with minute difference. How can I have code at one place, most probably in base class and all derived classes use same code?


title: What licenses are compatible with MASM32's license requirements?

text: The MASM32 documentation clearly states that the GPL violates MASM32's license, and therefore cannot be applied to projects built with MASM32. > The MASM32 project **cannot be used to create open source software** or any > other project under any form of licence that requires the user of the MASM32 > project to surrender the rights they are afforded under the MASM32 licence. > In particular the MASM32 licence completely excludes projects licenced under > the GNU organisation's published GPL licence and/or variants. However, no guidance is given on what licenses _are_ MASM32 compatible. My best guess based on the general push for freedom and not restriction in the MASM32 license is that the MIT license would be compatible. However, I'm not a lawyer. Anyone else gone down this path already and figured out which licenses are able to be used with MASM32?


title: Can each mobile app have its own client account for payments? (Windows Phone, Android and iPhone)

text: My company has many clients wanting mobile applications and having the payments come into our account and then sorting the payments would be a real pain. So can a company have a main account to publish applications (free and chargeable) and still have some sort of client account for each app (so they could view sales and receive full payment directly)? I would like to know for Windows, Android and Apple please.


title: When does one NO longer need to RENEW his Commercial off the shelf products (COTS) License?

text: Let's assume that someone buys "off the shelf" a Social Network (License) with all the core social network features needed, for a one off payment of 500$, and then a renewal fee of 250$ per each following year (of continued use). Then, the inhouse graphic designers and web developers modify the webpages (template) layout, the colours; and they adapt (change) the coding to their own needs. Over time additional plugins and other webpages are added and the original language becomes a smaller proportion than the originl 100% (of the COTS). When can a web development Team claim Copyrights "ownership" of their enlarged "coding" and stop paying the renewal fee to the Company from which they bought the COTS product? When is the line crossed between "It was yours on Day 1....but... it's mine now, as it looks to different from what I bought from you"? Do you have a ratio in mind, for example, old coding 30% new 70%? or how else could you possibly justify not paying whoever sold you that License and is chasing you for the yearly renewal?


title: Cataloging events, projects and tasks: Is SQL appropriate?

text: I have this idea for a database: it would hold everything I "need to remember", and allow future coding projects to access the information. These future projects include a day-planner and historical analysis of what I've been up to. The things I need to remember break down in to two main categories: Events and Tasks. Some tasks (like "wash dishes") won't be part of a project, but most will (like "write abstract for AIAA paper"). Both Events and Tasks will always have a category like "Home", "School", "Work", or "Family". I want to base this on a few SQL tables because I have used SQL before at work, and it was really straightforward and easy to work with. I also recently became acquainted with it so it is fun and new to me. For this specific project, I was thinking a big table for the actual entries with foreign keys for their project and category. My question is this: Is SQL the right choice for this, or am I using a jackhammer to open a screen door? I am sure that it is possible to do it this way; but I am worried that there might be a more sensible solution out there, and I am certain that the shiny new-ness of SQL is clouding my vision. **Edit after reflecting on comments:** A spreadsheet introduces the possibility of errors due to constantly repeating myself instead of referencing predefined entities; furthermore, it sacrifices machine readability to provide a cumbersome GUI. I accept the notion that SQL would be inappropriate but I do not think a spreadsheet could meet my needs. **Final Edit:** I did some more searching around and found a few potential ways to implement this that strike a nice balance between "sensible" and "interesting". I realized while I was reading y'all's comments that I needed to decide if I wanted to do it the "right" way or the fun way. And I think I want to do it the fun way. I did some exploring and found a few solutions that could extend my toolset for future projects without being completely superfluous like SQL.   * KirbyBase is a really simple ruby database that seems to be perfect for small, silly projects like this one.    * There are also a lot of interesting NoSql options that I intend to do more research on: MongoDB, CouchDB, and neo4j. I am going to go ahead and select the only answer that answered the question and let this topic sink because most of the commentary (not excluding my own) is too subjective for SE. Thank you all for the advice!


title: Editing files without race conditions?

text: I have a CSV file that needs to be edited by multiple processes at the same time. My question is, how can I do this without introducing race conditions? It's easy to write to the end of the file without race conditions by open(2)ing it in "a" (O_APPEND) mode and simply write to it. Things get more difficult when removing lines from the file. The easiest solution is to read the file into memory, make changes to it, and overwrite it back to the file. If another process writes to it after it is in memory, however, that new data will be lost upon overwriting. To further complicate matters, my platform does not support POSIX record locks, checking for file existence is a race condition waiting to happen, rename(2) replaces the destination file if it exists instead of failing, and editing files in- place leaves empty bytes in it unless the remaining bytes are shifted towards the beginning of the file. My idea for removing a line is this (in pseudocode):                   filename = "/home/user/somefile";         file = open(filename, "r");         tmp = open(filename+".tmp", "ax") || die("could not create tmp file"); //"a" is O_APPEND, "x" is O_EXCL|O_CREAT         while(write(tmp, read(file)); //copy the $file to $file+".new"         close(file);     //edit tmp file         unlink(filename) || die("could not unlink file");         file = open(filename, "wx") || die("another process must have written to the file after we copied it."); //"w" is overwrite, "x" is force file creation         while(write(file, read(tmp))); //copy ".tmp" back to the original file         unlink(filename+".tmp") || die("could not unlink tmp file");      Or would I be better off with a simple lock file? Appender process:               lock = open(filename+".lock", "wx") || die("could not lock file");     file = open(filename, "a");     write(file, "stuff");     close(file);     close(lock);     unlink(filename+".lock");      Editor process:               lock = open(filename+".lock", "wx") || die("could not lock file");     file = open(filename, "rw");     while(contents += read(file));     //edit "contents"     write(file, contents);     close(file);     close(lock);     unlink(filename+".lock");      Both of these rely on an additional file that will be left over if a process terminates before unlinking it, causing other processes to refuse to write to the original file. In my opinion, these problems are brought on by the fact that the OS allows multiple writable file descriptors to be opened on the same file at the same time, instead of failing if a writable file descriptor is already open. It seems that O_CREAT|O_EXCL is the closest thing to a real solution for preventing filesystem race conditions, aside from POSIX record locks. Another possible solution is to separate the file into multiple files and directories, so that more granular control can be gained over components (lines, fields) of the file using O_CREAT|O_EXCL. For example, "file/$id/$field" would contain the value of column $field of the line $id. It wouldn't be a CSV file anymore, but it might just work. Yes, I know I should be using a database for this as databases are built to handle these types of problems, but the program is relatively simple and I was hoping to avoid the overhead. So, would any of these patterns work? Is there a better way? Any insight into these kinds of problems would be appreciated.


title: How many make threads to use?

text: When I (re-)build large systems on a desktop/laptop computer, I tell `make` to use more than one thread to speed up the compilation speed, like this:               $ make -j$[ $K * $C ]      Where `$C` is supposed to indicate the number of _cores_ (which we can assume to be a number with one digit) the machine has, while `$K` is something I vary from `2` to `4`, depending on my mood. So, for example, I might say `make -j12` if I have 4 cores, indicating to `make` to use up to 12 threads. * * * My rationale is, that if I only use `$C` threads, cores will be idle while processes are busy fetching data from the drives. But if I do not limit the number of threads (i.e. `make -j`) I run the risk to waste time switching contexts, run out of memory, or worse. Let's assume the machine has `$M` gigs of memory (where `$M` is in the order of 10). So I was wondering if there is an established strategy to choose the most efficient number of threads to run.