title: Storing session in a static variable?

text: I'm currently checking a older piece of C# code used to maintain a login session.               public static ZRWebserviceSession CurrentSession { get { return _currSession; } set { _currSession = value; } }     private static ZRWebserviceSession _currSession;               public static bool IsSessionActive()     {         if (_currentSession == null || !_currentSession.IsOpen || !_currentSession.IsLoggedIn) {              return false;         }         return true;     }      I was always told using globals is bad practice and I'm looking for ways to improve this bit of code by at least getting rid of the static field used to maintain the session. The current situation is as follows: When the application starts the session object is initiated with a server address (taken from a config file) it should connect to. The object then retrieves the session data (token etc.) from the server to store within itself and it is then assigned to the static variable for access through the entire application. This is only done at the start of the application run or when the user explicitly restarts the session. While a session is active other pieces of code can then call methods on the session object to retrieve the session data and make calls to the connected webservice. Can this be improved? Is using globals still a bad practice if used for sessions or something akin to that? EDIT: To clarify what kind of application this is: This isn't a web application but a client application that connects to a webservice. ZRWebserviceSession is a library object that represents a login session for the user currently using the client application. Kind of like the the session object of the Fabebook SDK https://developers.facebook.com/docs/reference/ios/current/class/FBSession/.


title: Limitations of UML?

text: I'm currently studying for an examination and one of the sample paper questions is to discuss the limitations of UML. Most of the material I'm finding on the net is relating to a specific UML implementation or language. I'm wondering from a generalists point of view what would you consider the limitations of UML to be?


title: What's the effect of this assignment (whatever the language)?

text: I think my book (Programming Languages: Principles and Paradigms) is wrong. `a` is a vector, assume a C-like language:               b = 0;     a[f(3)] = a[f(3)] + 1;          int f(int n) {         if(b == 0) {             b = 1;                  return 1;         }         else return 2;     }      > It has the effect of assigning the value of `a[1] + 1` to `a[2]` whenever > the evaluation of the left-hand component of the assignment precedes the > evaluation of the right-hand one. For me, it has the opposite effect, that is assigning the value of `a[2] + 1` to `a[1]`. Because the left-hand component is evaluated first, so `f` returns `1` (because `b` is `0`), thus `a[1]`. Then the right-hand component is evaluated, `f` returns `2` (because now `b` is `1`), thus `a[2] + 1`. Am I right and the book is wrong? Unfortunatly there is no errata...


title: Where do the parser and service objects fit in MVC?

text: Do NSURLConnection service objects and XML/JSON parser objects fall within the controller layer or the model layer? Why? Is it OK to have business logic in the controller? Or should it be in the model layer only? Can the model layer be represented by NSArray/NSDictionary objects or should it be strictly structured with custom objects to comply with the MVC pattern, given that my app doesn't require persistent storage.


title: Architecture/pattern resources for small applications and tools

text: I was wondering if anyone had any resources or advice related to using architecture patterns like MVVM/MVC/MVP/etc on small applications and tools, as opposed to large, enterprisy ones. EDIT: Most of the information I see on application architecture is directed at large, enterprise applications. I'm just writing small programs and tools. As far as using these architecture patterns, is it generally worthwhile to go through the overhead of using an MVC/MVVM framework? Or would I be better off keeping it simple?


title: What are the best practices when performing requirements analysis through job observation?

text: I'm considering sitting with the end-users and observing them while the work for a day to better understand the software requirements. Before I try this, I'm hoping someone can provide a list of best practices, suggestions on when this approach is more/less suitable than simply interviewing the users, and notes from your own experiences using job observation/shadowing. References to other sites or recollections of your own personal experience are both welcome.


title: At what stage of a project should documentation be done?

text: I was assigned to fix some issues in a PHP project. Later on, I was asked to implement some new features, which I did. The project neither uses any framework nor does it use OOP. It lacks a proper structure, except for the use of folders (no sub-folders) to organize files. There was no documentation created by the original programmer. Now, the project's almost complete with some simple testing to be done and the client is asking for documentation. I have a few questions actually.   1. I have always considered documentation as a process which is starts before starting the coding part of project and which continues till the end. So, am I wrong about this? Is the documentation done at the end of the project?   2. What should be my way to go on documenting this project. I've kept a basic "log like" documentation on the changes I've made for my personal use. But since there was no initial documentation produced, I didn't bother to create one either.    3. Is there a good documentation template that I could use to reduce my effort? I am talking about or code documentation (not user documentation). Although I'm assuming this since they haven't specified anything.


title: Ruby on Rails database using static lookup tables or constant strings

text: In some ruby on rails projects, I have seen instances where strings are used instead of a foreign key reference to a lookup table. I usually code in C#/SQL Server and use lookup tables, but am not particularly experienced in ruby on rails. So my **question** is, should I be using strings instead of lookup tables in my ruby on rails web project (mysql and active record)? Is this something specific to ruby on rails, or to dynamically typed languages? Or for some particular circumstances? Or is it just bad database design? By lookup tables I mean, like the following **UserStatus**               Id    Name     1     Active     2     Disabled      **User**               Id    Username               UserStatusId     1     john.smith@gmail.com   1     1     jane.smith@gmail.com   2      Whereas with just strings **User**               Id    Username               UserStatus     1     john.smith@gmail.com   active     1     jane.smith@gmail.com   disabled


title: Have you forgotten more than you know, and how much do you make a point of memorizing?

text: I'm talking about knowing an area of computer science or a language, and then forgetting it over the years. As I approach the 20 year mark, I'm finding myself realizing that I've forgotten more than I currently know. Is this bad? Is this good? Is there a way to solve this? And if not, which things are worth memorizing? For instance, we all know (I think) that Quicksort provides O(n*log n) in average cases, and we know it can balloon to O(N^2) when fed with the wrong inputs. How many of us, if asked without notice, could write a functioning Quicksort on the whiteboard or in their code editor of choice, without blinking? Is this useful? And if we can do it, does it count if it's a naive implementation, and not the optimized version that was engineered by Bentley & Company? I give that as an example, but it could be anything. C++ has many dark corners, that if not used for some length of time, can be easily forgotten. And let's face it, there are many dark corners in C++ that one prefers to steer clear of.


title: Going further with C for iOS development

text: I am an experienced iOS developer amongst other things. I have a good mastery of Objective-C and Apple's frameworks in the language. But when it comes to the C-based frameworks I often hit a ceiling with my knowledge, and often have to look up idioms and syntax. I learnt C from K&R but it's been a while. I did try learning from it again and it was a blast; but by Chapter 6, I got a feeling that its C is a bit archaic, at least idiom- wise. Also, I want to learn C mostly for the sake of iOS development and so a Mac/iOS focused learning process would be ideal. What will be a good way to go about doing this?


title: What FOSS solutions are available to manage software requirements?

text: In the company where I work, we are starting to plan to be compliant to the software development life cycle. We already have, wiki, vcs system, bug tracking system, and a continuous integration system. The next step we want to have is to start to manage, in a structured way, software requirements. We dont want to use a wiki or shared documentation because we have many input (developer, manager, commercial, security analyst and other) and we dont want to handle proliferation of .doc around the network share. We are trying to search and we hope we can find and use a FOSS software to manage all this things. We have about 30 people, and don't have a budget for commercial software. We need a free solution for requirements management. What we want is software that can manage: Required features:   * Software requirements divided in a structured configurable way   * Versioning of the requirements (history, diff, etc, like source code)   * Interdependency of requirements (child of, parent of, related to)   * Rule Based Access Control for data handling   * Multi user, multi project   * File upload (for graph, document related to or so on)   * Report and extraction features Optional Features:   * Web Based   * Test case   * Time based management (timeline, excepted data, result data)   * Person allocation and so on   * Business related stuff   * Hardware allocation handling I have already play with testlink and now i'm playing with RTH, the next one i try is redmine.


title: Deployment: Best Practices (and real practices)

text: One thing that I've learnt in my short dev career is that there are best practices (like TDD) and then there are actual practices that occur under pressure, or through budgetary/time constraints. I'm working in a small PHP dev team on a project using Zend framework. The project has the potential to demand a lot of scalability, and so we are trying to establish a good development environment to promote ease of development long term. Architectural patterns/practices aside, I'm looking at trying to automate deployment, checking code quality through svn hooks, possibly even setting up a CI environment. So I'm interested in hearing people's experience of deployment practices. I've checked other examples as they pertain to other languages - but I'm ideally looking to hear from people who have worked in a PHP/Zend environment To make the question less vague: What are people's experiences of using deployment systems like phpUnderControl and rSync?


title: I want to write a data processing & analysis programming language that compiles to SAS. How to go about choosing a language to write my compiler in?

text: As a side project I wrote a simple macro in SAS to add syntatic sugar to SAS code. I hate how verbose SAS is sometimes! So my macro looks like this               %macro md(code);         /* expects a superquoted string */        * append a b;        %if %lowcase(%scan(&code.,1)) = append %then %do;             proc append base = %scan(&code.,2) data=%scan(&code.,3); run;         %end;     %mend;      Instead of writing               proc append base=a data=b; run;      to append two datasets, I can simply write               %md( append a b);      This got me thinking. Since I work with SAS all day and I enjoy programming. Why not (for fun) design a new data processing language that compiles to SAS?! As many of you can guess this idea was inspired by CoffeeScript which compiles to Javascript. I learnt that CoffeeScript was initially written in Ruby? But why? How did the author choose Ruby? What are the things to consider in choosing a language? And what resources are available that might be useful in pursuing this?


title: Alternatives to Project Euler for improving Excel ability

text: I've recently been enjoying using the mathematical problems listed at Project Euler to learn Python. My Excel ability is better than my Python, but I think I'd still benefit from the sort of inductive learning that comes with solving a series of increasingly difficult puzzles using a particular tool. I know Project Euler can be completed using Excel, but are there any other puzzle series similar to this or The Python Challenge specifically tailored for people trying to increase their knowledge of Excel and what it can do? I'm not looking for a "tutorial", I know there are plenty of these.


title: Various programming concepts (from a Python viewpoint)

text: Ever since I've started lurking on stackoverflow, I keep coming across programming concepts such as abstract classes, virtual functions, contracts, interfaces, etc., from a questions about other languages such as C++, Java, and C#. As far as I can tell, most of these things are related to object oriented programming but aren't typically mentioned in Python tutorials because Python uses a combination of duck typing and magic to make such concepts redundant. Nevertheless, I'd still like to know what they are.   **What are abstract classes, virtual functions, contracts, interfaces, etc. (explained from a Python standpoint?) What other programming/OOP concepts should I know about that Python typically doesn't use or require you to know?**


title: How do people develop emulators?

text: I hope this is right area on Stack Exchange to ask this question. People out there have built emulators for every game console but I don't understand how they do it. I consider myself (and have the professional title of) a senior level developer in several languages including Javascript but I don't have the faintest idea about how to begin writing an emulator in Javascript. How do they figure out how to read the ROMs and emulate the game?


title: Do you dress formally or casually for a programming interview?

text: For the 4 jobs that I have worked at, I dressed formal twice, business casual once and more casual once. How important is the dressing code to programming interviews these days? Will the employer or interviewer not take you seriously if you come in casually: plain shirt and khaki pants with casual walking shoes(non-sneakers)?


title: Proper Price Markup Formula

text: Ok, so this is not the most advanced programming question - and it kind of borders on e-commerce, but it has specifically come up twice in my career - which is only 10 years old, so I figured I would ask it. **Question:** I want to markup a price 10% from its original cost for a website, which is the proper way to do it: **NP = (P * 1.1)** or **NP = (P / 90) * 100** Where P is the original Price and NP is the New Price? **Background:** I am a web developer. I have worked on several e-commerce sites in my time. A few years back, I was building a freelance site for a tool shop. The guy had been in business for years and was moving into online sales. I wrote a script that took his core inventory list, cycled through it and automatically marked up the price 10% before inserting into the Database. I used formula #1. When he reviewed it he said the price was too low and to use formula #2. Using formula #1, a 15 dollar product is now equal to 16.5, using two it is $16.66. His logic was that 15 is 90% of $16.66 and thus 16.66 a 10% markup, by which 16.5 is only about a 9% markup. Flash forward a few years to today and and I hit the same problem. My company has a massive list of inventory that gets marked up and down in a number of ways. Our old DBA was marking up the price for distributors 10%. He was using formula 1. Our new DBA rewrote a stored procedure and started using formula two. A few people flipped out and started saying that the distributor prices were way too high and that the old formula was correct. We sell large quantities of relatively low-cost items, the fear is that our distributors would balk at the cost. Logically it seemed that formula #1 was the proper way to markup, but the experienced business owner told me the other way was. Now I am hearing people say the opposite. EDIT: My Using the original 15 example. It has always seemed to me that 15 is actually a 10% markdown of 16.66 where as 16.5 is the proper 10% markup of 15.


title: Web hosting deciding to pay for hosting or host your own?

text: Is there a guide out there on how to choose when to pay for web hosting vs. hosting your own? Assuming that root access is a must I would like to compare things like cost, scalability and personal stress. Here is what I could come up with. Paying for web hosting: Benefits:   * Much cheaper for a small scale. I assume anything under $50 a month would be cheaper than paying for the bandwidth of hosting.   * No stress in dealing with power outages, server restarts or internet going down.   * For the most part less busy work involved with setting up. Negatives:   * Cost goes way up when higher specs are needed (for example monthly cost triples with ability to use 8gb of ram that you can buy for $90 ). This means you have to target a particular ram usage and monitor so your instance stays within the threshold.   * root access for the most part is a premium.   * You may get tied into a vendor specific deployment process. Hosting on own : Positives:   * 100% control of specs and software.   * When you get past paying for the bandwidth you get much more bang for your buck by building your own machine. Negatives:   * Doesn't make financial sense if bandwidth costs are more than web hosting costs.   * Having to deal with power outages, server restarts or internet going down. I think the best of both worlds would be if there was a place that dealt with bandwidth, power outages and server restarts but you provided your own server. Kind of like a 24 hour day care for a server. Does anything like that exist?


title: Software Developer vs. Project Manager vs. Product Manager

text: I've been a software developer for 10 years. I like being a developer and no surprise I strive for sense of achievement. However, I normally find myself doing stuff that needs to get done regardles of it's my job or not. My experience of various managers I've worked with shows a terrible score of like 20% of those that I find competent for the work they do. This makes me think that demand must be high for no-nonsense managers. I'm seriously considering a career shift from a developer position to one of those positions, but my question is: -Is it worth it? I'm assuming that it's more or less undestood what each of these positions mean. The question is only if an above average developer normally earns more than an average manager or not?


title: The Nature of Spring

text: Is it accurate to say that dependency injection manually using java (without spring) is nothing but implementing the strategy pattern (as per this example)? Furthermore, is it correct to say that Spring just provides a declarative way of specifying the dependency as opposed to manual method whereby the dependency need to be created and 'set' using java code?


title: How can I leverage or 'selling' small-scope skills in a large-scope-heavy environment?

text: I've been working for 15 years at a mid-size company (300-400 engineers) doing a mix of embedded software / signal processing / controls engineering / circuit design. And an event has occurred recently that puts my current role in jeopardy. I'm having trouble deciding how to either find a good fit at my current employer, or deciding where to go next. **What I'm wondering is if anyone here relates to the following situation and can recommend a way to leverage or "sell" my strengths to my current (or future) employer:** Most of the projects at my company need what I see as strong "large-scope" synthesis skills: project X needs a software engineer to take responsibility for area Y in that project, and quickly finish the design, debug, test, and documentation needed to make that area a success, overlapping enough with coworkers so the project as a whole is a success. (or replace "software engineer" with "circuit designer" or "controls engineer", it doesn't matter) That's not my forte, and no matter how hard I try, it always seems to end up in frustration for me. What I'm very good at, is a mix of the following:   * problem solving   * learning   * mathematical analysis   * use of a wide skillset (ee/math/signal processing)   * meticulousness (many projects in our company have been delayed because someone "finished" a task quickly but sloppily, so it had to be redone properly later at a much greater risk/cost)   * identifying design process bottlenecks that cause delays/risk/etc., and writing software tools to help overcome those bottlenecks. (for example: we had a case recently where our build process for a C++ software project was missing some dependencies on autogenerated .h files, so sometimes when we did incremental builds instead of fresh builds, one of the .cpp files wouldn't be recompiled and would refer to an incorrect structure definition. I already had a software tool that could read debug data in the executable file, so I improved it to detect and report multiple conflicting structure definitions present in the executable. Works like a charm: we now use it as a step in our automated build process, and it quickly helps us identify missing build dependencies should a new one occur.)    * focusing on synthesis (design/debug/test/documentation) projects of very limited scope   * acting in a supporting role to take on small issues that have other engineers stuck, freeing them up to continue their work What I'm bad at is synthesis on moderate to large projects. I'm not a programmer workhorse. I cannot seem to manage the complexity no matter what kind of organizational tools I try to use, and it feels like I'm running into a case of neural stack overflow: if I take on new tasks, some of the old ones slip away from my brain, I forget about important details which take me a long time to re-acquaint, and I just feel overwhelmed. And on top of that, I have RSI in my wrists and one shoulder, which get aggravated with stress. **How can I state my strengths and weaknesses effectively and briefly with my current employer (or prospective employers), so that I can find a good fit where my skills benefit them and I can find a role that I'm satisfied with?**


title: Need pointers on my first Windows program

text: I'm a Unix programmer and I need to write a (hopefully simple) program for Windows that does the following: (1) Installs from a USB drive (2) Somehow integrates with the OS at a low- level in such a way that it can filter/shape all network traffic in/out of the machine (a la IPSec) I can write in C, asm, Python, Java, but I have no idea about Windows' methods for doing this sort of thing, nor where to start learning. (I could easily do the above with Linux using a kernel module.)


title: Best starting point for writing small desktop programs for Windows?

text: I know how to program for Unix, Mac, and iOS, but I have no clue when it comes to Windows. Now I have a specific project that requires building a Windows version of a Mac OS X desktop app. But I have no idea where to start learning. What languages can I build the app in and how do I package it for download and distribution? What tools can I use? Can I use Vim and something resembling the Unix command line? I can program well in Ruby and Objective C, but I'm guessing I won't be able to use either of these to make a Windows desktop app. Any tips?


title: Unit testing of "workflow" methods

text: We are currently developing a public API for our app. The methods on this public API are mostly putting together functionality in different corners of the system. An example would be: (names have been changed to protect the innocent)               public String createAppUser(String app, String name, String email, byte[] pwd) {           Application appl = applicationModule.retrieve(app);          User user = userModule.createUser(name,email);          Digest digest = cryptoModule.createDigest(pwd);          authenticationModule.authorize(user,appl,digest);          accountingModule.createAccount(user,appl);          return user.getId();     }      When unit testing such a thing, the unit test is just a copy of the same workflow, with some additional noise to setup mocks, objects and validate interactions. Although I find unit-test of algorithmic parts of the application essential, in this 'workflow' part, I find unit-test a repetition of the workflow in question form. Following the DRY principle, it feels like a waste of time. What are the best practices in these cases? Given that these methods are part of a public API, I would find more valuable to test them through a client and validate that the system effects have taken place. This is more 'system test' or 'integration test' and beyond the scope of unit test. What would be the best test approach in this context?


title: open source flash environments

text: I have been looking for a really good open source flash development environment with no success. The best I could find would help in the development of pretty much everything, but I still needed to have Adobe Flash Professional in order to compile my work. Is there a way I can develop Flash applications and not need to purchase Flash Pro?


title: Is nesting types considered bad practice?

text: As noted by the title, is nesting types (e.g. enumerated types or structures in a class) considered bad practice or not? When you run Code Analysis in Visual Studio it returns the following message which implies it is: > Warning 34 CA1034 : Microsoft.Design : Do not nest type > 'ClassName.StructueName'. Alternatively, change its accessibility so that it > is not externally visible. However, when I follow the recommendation of the Code Analysis I find that there tend to be a lot of structures and enumerated types floating around in the application that might only apply to a single class or would only be used with that class. As such, would it be appropriate to nest the type sin that case, or is there a better way of doing it?


title: Why are more programmers not freelance these days?

text: Leaving the whole _pie_ to only a few of them, amplifying the huge differences between the two status. Pay is a (huge) one, not having to do overtime is another. I leave the question open to hopefully get many great answers on all the different subjects that affects that feeling and decision not to go. **EDIT** : While this question is really global, I'll be interested in any studies, facts, articles, opinions regarding local markets such as US, India and even Australia in which I'm in love with. **EDIT2** : Bounty of 500 points for anyone that will come with recent studies on the subject. If multiple answers, will pick the one with the most upvotes.


title: Best Practices or Project Standards

text: As a software development contractor I've worked on many projects with differing standards and conventions. Quite often these conventions go against the software best practices we know and 'love'. The question is, when you're working on an established project with specific ways of doing things that you know aren't the best ways, do you break the conventions of the project because you know its a better way of doing something, or do you stick to convention meaning that your work will blend into the existing code base? After all, you need to keep in mind someone else is going to stumble across your work one day and if its not consistent with the rest of the project they will have to take the time to work out what you've done differently. So, project convention consistency or best practices?


title: Inheritance gone wrong

text: I have some code where a good inheritance model has gone downhill and I am trying to understand why and how to fix it. Basically, imagine you have a Zoo hierarchy with:               class Animal       class Parrot : Animal      class Elephant : Animal      class Cow : Animal      etc. You have your eat(), run(), etc methods and all is good. Then one day someone comes along and says - our CageBuilder class works great and uses the animal.weight() and animal.height(), except for the new African Bison which is too strong and can shatter the wall, so I am gonna add one more property to the Animal class -- isAfricanBizon() and use that when choosing the material and only override it for the AfricanBizon class. Next person comes and does something similar and next thing you know you have all these properties specific for some subset of the hierarchy into the base class. What's a good way to improve/refactor such code? One alternative here would be to just use dynamic_casts to check for the types but that clutters the callers and adds a bunch of if-then-else all over the place. You can have more specific interfaces here but if all you have is the base class reference that doesnt help much either. Any other suggestions? Examples? Thanks!


title: How can I benchmark concurrent key-value stores?

text: I have some concurrent key-value store implementations that are implemented with hash tables and search trees that I would like to compare. I would like to benchmark them with a real world application where several threads stresses the key-value stores. I already have some micro-benchmark that stresses the key-value stores by executing random operations on the key-value stores in parallel. What I'm interesting in now is applications that do some work that could be useful in the "real world" and where one or several key-value stores are important for scalability and speed. I would like to have a benchmark that is easy to set up and that could be run on many different system. I would prefer if it does not involve network communication etc. An example of the kind of applications I'm looking for is the parallel PageRank algorithm. It is used as a benchmark of different key-value stores in the paper "Concurrent Tries with Efficient Non-Blocking Snapshots (PPoPP'12)". The reasons why I'm not satisfied with "artificial" benchmarks that do X% inserts, Y% deletes and Z% lookups are:   1. It can be more convincing with a benchmark that also solves a real world problem. The risk with an "artificial" benchmarks is that they might not correspond to any real world situation.   2. Some usage scenarios that happen frequently in real world applications might not be covered by the artificial benchmark.


title: What could an algorithm look like that iterates through all combinations of two variables to aim at a certain number of entries?

text: For background information, see "Some background" further down. I have a list that looks like this:               Start-Time-In-Seconds;End-Time-In-Seconds     1;2     4;6     12;15     ...      This works together with a wave file by acting as a cutlist. So the desired parts are 1->2, 4->6, 12->15, ... If the distance between End-Time-In-Seconds of the previous element and Start- Time-In-Seconds of the current element is below a threshold of seconds(I call it _Pausendauer_ ) I merge those two, ie if the threshold is 3 seconds then the list will be               Start-Time-In-Seconds;End-Time-In-Seconds     1;6     12;15     ...      If the distance between Start-Time-In-Seconds and End-Time-In-Seconds is below a threshold of seconds(I call it _Minimallänge_ ) I discard this sample, ie if the threshold is 4 seconds then the list will be               Start-Time-In-Seconds;End-Time-In-Seconds     1;6     ...      What could an algorithm look like that iterates (intelligently) through all combinations of _Minimallänge_ and _Pausendauer_ to aim at a certain number of entries? Example: The number of entries should be 3. Given the number 3 the algorithm should iterate (intelligently) through all combinations of _Minimallänge_ and _Pausendauer_ to output something like this:               Start-Time-In-Seconds;End-Time-In-Seconds     1;12     18;20     50;100      And that should be all. You notice I did not add "..." to it as the final list is to only consist of three entries. _Some background_ : The wave file contains several interviews being recorded continuously with pauses in between. A VAD gave me areas where it presumes voice to be. As I know the number of total conversations(f.i. 3, usually more which is why this makes sense) my goal is to determine them automatically. The cutlist is the raw output of my VAD which I want to turn into a usable cutlist for ffmpeg. _PS_ : If you can, share an algorithm in c#.


title: Is blocking an entire web-client due to compatibility a reasonable request?

text: A little bit of background, we've made an electronic POS system for registered vendors of items of a well known brand. The vendors are required to login to use the system. Recently, IE has been giving us lots of painful maintenance problems than before. Our boss is getting worried about running into further maintenance problems, so he has asked me to find out a way to automatically install & launch chrome if they try to login with any other browsers (For the record, nearly all of the issues are related to some feature working fine on FF/Chrome/Opera/Safari but doesn't on IE). Let us put aside the ridiculousness of running an external .exe from Javascript, which is practically impossible (And rightfully, I told him so. But he insisted it was possible, so whatever). So my questions are:   * Is this request technically viable? Is there a guaranteed way to block requests from all browsers except for allowed ones?   * Is this request reasonable? IMO, From the standpoint of users, limiting accessibility does more harm than good, but maintenance issue is definitely a valid business concern.   * Has there ever been a case like this where other websites explicitly blocked certain browsers? Edit: Thanks for the answers. We're supporting IE 7+ at the moment and indeed, 7/8 were the ones that caused most of the grief. Just dropping those two will make maintenance significantly easier but my boss thinks the problem has to do with IE itself, not necessarily the versions. I'm going to try to see if I can convince him, but I have a strong feeling he's going to stick by what he thinks.


title: Is this "anti-pattern" and should I stop using it or is this clever design?

text: I've basically stared to do the following when creating a REST service:   1. HTML is requested   2. service returns the desired web page but without the requested "resource", eg. data   3. web page contains JavaScript that issues AJAX request to the same service (different content-type)   4. service then returns the actual data (JSON) and the page displays it On one side it seems inefficient (2 requests) but then were I used this, "performance is of no concern", meaning low traffic internal app and the web sites are simple and load fast. The reason I ended up with this is that the web page can then be almost pure Html + JavaScript and almost no server-side stuff is required, especially no loops, to create tables and stuff like that (which I think is very ugly compared to things like slickgrid), e.g. separation of data and view. Now before I get to using this, is this a good idea or should I just stop doing it?


title: Why is semantic markup given more weight for search engines?

text: This question follows directly from the part of an answer of this question - Why would one bother marking up properly and semantically? . I would like to understand why SEO techniques gives more weight to semantically correct mark up?


title: DbFirst vs Code First? what should I use if I rely on Stored procedures

text: This question is asked many times, and I always prefer code-first as I like to keep the logic in code. But now I have a challenge to load screen under 5 seconds and very little time to do things. I have large set of records, and I'm possibly going to retrieve them asynchronously. There are a few doubts in my mind.   * Does using db-first approach have any benefits in performance over code-first?    * Should I write the logic in stored procedures or in code (Linq)?   * Which has less latency: Linq or stored procedures?


title: Application protocols and state machines: designing a complicated server

text: I'm designing and prototyping a server that has the following characteristics:   * during the daemon's initialization it spawns nine "manager" servers, each of which solves one part of the overall problem.   * after initialization, the daemon accepts connections from clients, forking a "slave" server for each which connects to the managers and then accepts requests from the client, farms them out to the managers, assembles the results, and sends them back to the client, ad infinitum.   * the daemon, the managers, and the slaves all should have the ability to concurrently accept "control" connections from a terminal, and receive and process commands (e.g. queries for performance stats).   * the concurrency of each process's socket I/O is being managed by select(). The problem I'm having is the complexity of the coding. For one thing, each program has at least two phases - initialization and main loop - in which it is variously establishing a connection to its parent, or accepting a connections from its children, or sending and asynchronously awaiting data from its children, and so on. At various points I don't want, say, to accept a client connection while I'm initializing, or I do want to accept control sessions even in the midst of regular processing. Not to mention managing the protocol of each such connection. Given enough time, I could probably massage all of this into a reasonably well-factored set of subroutine calls. But I remember having heard of an entirely different approach to this sort of problem, involving libevent, callbacks, and finite state machines. What I'm hoping is that someone reading this might say "Why, yes! That's a perfect example of where event callbacks and FSMs are far superior to looping on select()s - and a great introductory article about this is ..." or "here's what it's all about in a nutshell." (Or, possibly, "that's not what libevent is intended for, at all.")


title: Stacking keywords on top of each other - poor style?

text: I have always wondered about this, especially in C/Java style languages. For example, consider the first 3 lines of this C# code:               lock (serviceLock)     using (var client = new ServiceClient())     try     {         // Do something         client.DoSomething();     }          catch (System.ServiceModel.FaultException ex)     {         // Handle error         addLog(ex.ToString());     }      This usage has always seemed somewhat questionable to me. However, the alternative is not very practical either (3+ levels deep of indentation for a service call). Apart from pure aesthetics, is there any practical reason to add or not to add the extra brackets in this case?


title: Better way to familiarize myself with Haskell

text: I'm a Haskell beginner. I started learning Haskell around 20-25 days back. With a programming day job I am doing this in my spare time because I wanted to learn about functional programming. **Background** I have been going around stackoverflow to see how I should proceed. I have read the first 6 chpaters of learn you a haskell and around 2 chapters of Real World Haskell and done a bit of Haskell programming. I have no prior experience in functional programming. But I have used Python, which has **_some_** functional programming concepts used. Now I am really confused about how to proceed. I am used to learning to program by writing programs on the go but here in Haskell I am not sure what kind of programming problems to do. I am having trouble thinking the solutions to problems that I already solved in Python or C. I have tried some of the 99 Haskell Problems but their solutions use library functions which I don't know about. Haskell emphasizes recursion but without any kind of looping I don't know how to solve many of the problems. I tried going over the advices that I got when I was learning Python. But this time learning Haskell those are not helping because I am stuck at an even lower level. This time I have lesser time to practice and it is just so different. Is there a way to familiarize myself with Haskell better than the above mentioned method? Does it just take some time coming from imperative background?


title: Real-world examples of apps written with TDD and good test coverage?

text: Are there any open source applications that are developed using test driven development that serve as models of how good unit testing should work? I'd prefer to see examples in C# and .NET. (Note that I mentioned applications, not just libraries.) I'm a mid-tier programmer who really wants to believe in and practice TDD. The app I work on in my day job is pretty complicated--about 1 million lines of code--and I would love to introduce more unit testing. We have some unit tests in place, but my efforts at TDD and with working on code that's already under test have not been encouraging. In my admittedly limited experience, TDD seems to encourage a lot of complexity in the name of decoupling. The bits of the app that are hard to test--and which coincidentally tend to be critical--get pushed out to the periphery, into the realm of integration tests that may or may not ever get written. (I'm thinking of the usual suspects here, file system access, hydrating objects from a database, asynchronous web calls, etc.) The code that's under test tends to involve lots of collaboration among objects, and maybe some simple flow logic, all of which happens in memory and which could arguably be written in a simpler, more understandable way if everything didn't have to be totally decoupled for testing. I understand the techniques for mocking dependencies and such, but in my experience heavy use of mocking leads to very brittle tests. If my first instinct upon seeing a bunch of tests go red is, "Great, now I have to fix all the mocks," then my tests have become a drag rather than a safety net. I'm trying to get past this mental barrier, and as part of that I'm reading Michael Feathers' book, _Working Effectively with Legacy Code_. I it hope will show me some of what I'm missing. I'd also like to study some nontrivial .NET applications with good code coverage, maybe a content management system, or a CRUD app. The FitNesse testing framework that Uncle Bob talks about is something I'll probably look at, but it would be nice to see something written in the language I'm most familiar with. Any suggestions or words of wisdom would be appreciated.


title: Passing around impl-specific tokens in generic algorithms in a static/strong type system

text: I was interested in solving several unrelated problems using generic graph search techniques, so after some fiddling around I came up with the following design: have each problem implement a generic "Problem" interface which has an initial state, and several methods that take in states and moves, and return new states and moves. For example, I can `getMoves(state)`, `applyMove(state, move)`, or check `isGoal(state)`. All of the problem specific details are then in one place, and the generic algorithms can pass around states and moves as generic "tokens" that they don't really care about, using the Problem instance to evaluate their properties. The Problems are also consequently stateless (or what state they have is immutable), which makes their behaviour very easy to reason about. This was all fine and good in a dynamic/duck type system (JavaScript), but in migrating the idea to a static/strict type system (Java), I've run into some issues. The most immediate problem was that these "tokens" could really be anything. Arrays, objects, maps, strings, whatever. Javascript didn't care, because the algorithms just passed them around as black-boxes, and the Problems assumed they were being given their own tokens. In Java this is not the case. The first most natural solution is to have all the "tokens" implement some empty `State` or `Move` interface. This already has some problems, as if my state is just some data structure, then I need to extend or wrap the structure, but that's _basically_ fine. The next problem is that the tokens are implementation specific, so every time they're given to the Problem, they need to be cast into what they actually are. Lots of casting strikes me as a red flag, so this seems like a bad (certainly unpleasant) approach. To avoid all the casting, I briefly considered something involving tons of templates (State<ChessProblem>, Move<ChessProblem>), but that seemed like a headache which might not even fix the problem. Is there some "proper"/standard way to accomplish this in stricter type systems? Is this just a bad pattern to use in them (or a bad pattern overall)? Any insights would be appreciated. Also, while I _am_ using Java, if other static/strict languages have novel tools for this sort of thing, I'd love to hear about them.


title: Which is better for increasing accuracy/visibility of project timelines: a developer and a manager or two developers?

text: I'm currently a one person development team. My employer is looking at hiring a manager. They do this because, for the more complicated projects, I tend to take a "this is how much I've got done - this is how much there is to go" approach rather than "this is when it will be done" and they think it's going to magically change if a manager comes on board. Would I be correct that second developer is more efficient? Could I maybe cite the advent of pair programming as evidence, or is that really a specialized thing?


title: Setters or constructor for many variables?

text: > **Possible Duplicate:**   >  Are there guidelines on how many parameters a function should accept? I have got class with 30 variables (it is application form), so I wonder what is the best practice to organize class creation. Should I use huge constructor:               MyClass mc = new MyClass(a, b, c, d)      Or setters:               MyClass mc = new MyClass();     mc.setA(a);     mc.setB(b);     mc.setC(c);     mc.setD(d);      What is the best practice in OOP for such situation? I saw similar question, but now I don't need immutability.


title: Data structures in functional programming

text: I'm currently playing with LISP (particularly Scheme and Clojure) and I'm wondering how typical data structures are dealt with in functional programming languages. For example, let's say I would like to solve a problem using a graph pathfinding algorithm. How would one typically go about representing that graph in a functional programming language (primarily interested in pure functional style that can be applied to LISP)? Would I just forget about graphs altogether and solve the problem some other way?


title: What is a correct/polite way to inherit from an abandoned open-source project for a new open-source project?

text: My team just tried to contact some guys from an old open source project hosted on code.google.com. We told them that we'd like to join their project and commit to it -- at least to some branch of it -- but no one responded to us. We tried everyone, owners and committers; no one was in any way active, and no one replied. But we have some code to commit and we really would love to continue work on that project. So we need to create a new project. We came up with a name for it which is close to but not a duplicate of the name of the project we want to inherit from. How should we do our first commit, and what should the commit message be? Should we just copy their code to our repository with a comment like "we inherited this code, we found it here under such and such a license ... now we're upgrading it to this more/less strict license ..."? Or should we just use their code as our first commit, with updates saying "we inherited from ... we made such and such changes ..."?


title: Why is implicit parallelism/concurrency not more widespread?

text: Implicit parallelism^ can take a big burden away from many programmers, placing it on the computer. So... why is it is not more widespread at present? * * * ^ Implicit parallelism is to make a computer be able to figure out itself how to do more than one thing at a time, instead of a programmer needing to do this job using threads and the like


title: What's the difference between the code inside a finally clause and the code located after catch clause?

text: My java code is just like below:               public void check()throws  MissingParamException{         ......     }     public static void main(){         PrintWriter out = response.getWriter();         try {             check();         } catch (MissingParamException e) {             // TODO Auto-generated catch block             out.println("message:"+e.getMessage());             e.printStackTrace();             out.close();         }finally{             out.close();         }         //out.close();     }      Then, my confusion is: what the difference if I put `out.close()` in a finally code block or if I just remove finally code block and put `out.close()` behind catch clause (which has been commented in the code). I know that in both ways, the `out.close()` will be executed because I know that whether the exception happened, the code behind the catch clause will always be executed.


title: Class or Dictionary

text: I want to create a immutable `Scale` class in C#.               public sealed class Scale     {         string _Name;         string _Description;         SomeOrderedCollection _ScaleValueDefinitions;         Unit _Unit              // properties         ....         // methods         ContainsValue(double value)         ....              // constructors         // all parameters except scalevaluedefinitions are optional         // for a Scale to be useful atleast 1 ScaleValueDefinition should exist         public Scale(string name, string description, SomeOrderedCollection scaleValueDefinitions, unit)         { /* initialize */}     }      so first a `ScaleValueDefinition` should be represented by to values:   * Value (double)   * Definition (string) these values are known before the Scale class is created and should be unique. so what is the best approach.   1. create a immutable class ScaleValueDefinition with value and definition as properties and use it in a list.   2. use a dictionary.   3. use another way i didn't think of... and how to implement it. for option 1. i can use `params ScaleValueDefinition[] ValueDefinitions` in the constructor, but how to do it for the other options? and as last at what amount of value's (properties) should i choose one option over the other?


title: Is it bad that you don't program on your spare time while at uni?

text: There has been some questions about not programming on your spare time, but they all concern when you're at work. What about when you're studying? Do you also need to learn on your spare time when you're already learning during the daytime (at uni)?


title: Code Samples and Interviews?

text: I've seen a number of questions since I've been here where, in the answer, someone has asserted that they would never use portfolios or code samples coded outside of the interview process to judge a candidate, because there is a possibility of that code having been written by someone else. I find myself surprised by this. The way I see it, if I ask someone to come in and solve a simple problem on the spot, there is very little I can learn from it. I don't work for a company like Google where jobs are sought after and I can demand a day of someone's time. But a substantial piece of hobby-written code can tell me a lot. Yes, there is the possibility of plagiarism, but they're going to have to be very well coached to get through an hour long discussion about that code. And should that be the case, they'll have to be very quick learners to get through their 3-month probation (during which I can get rid of them with no reason and with no notice). If they become good programmers that quickly, fair enough, I've been duped, but I still have a good programmer. In the end, the cost to our company and the benefit to the candidate of plagiarism is very minimal. This got me to thinking about other industries. Artists, photographers, designers all use portfolios and nobody worries too much about plagiarism there. An author will get funded for a book based on chapters he has written in his own time. You wouldn't ask an architect to come in and draw design specs for a house at the interview. So what makes us different? Why is it so important to put someone in front of a computer and make them code up a data merge or a factorial calculator, sometimes without access to the very tools we use day-to-day, like the internet? What is wrong with the idea of a code portfolio? I'm genuinely interested to know, in case I am potentially making a huge mistake which just hasn't burned me yet.


title: Need a transition from my workflow, or make it better / fix it

text: This is how I roll with git:   1. I clone/fork something locally   2. I create a new branch `devel`. This is supposed to be a quickfix branch. It is also supposed to be parent to all branches.   3. I create a topic branch (say make a new theme `lex`) I actually create a few more child-topic-branches (say `lex.th2`) to test/see different things. But so now, I have to quickfix (in `devel`) a core functionality (say re- correct database credentials in `wp-config`).   I then have to switch to `lex` and `merge devel`. And then to `lex.th2` and `merge lex`. (So that changes from `devel` could goto `lex` and to `lex.th2`) Doing all this severely messes up my history-graphs ![C:\\Program Files \(x86\)\\Git\\bin\\wish.exe](http://i.stack.imgur.com/8Hy0H.png) I'll admit that the "official" workflow was too much for me and I just took the parts that I liked from it... probably badly. So any suggestions how to make it "tidy" while still not complicating or deviating too much?


title: Provide both RESTful interfaces and Java ones?

text: I am writing a RESTful service in Java, of course it's typical HTTP based interface. I am wondering should the service provide Java interface which has same semantic to the RESTful interface? I think Java interface will ease other Java code to call the service. (Client Java code doesn't need to use HTTP client to trigger HTTP requests to invoke RESTful) The problem is it's difficult to write same semantic Java interface to a RESTful one, I mean same semantic. Any advice for the design? Thanks!


title: Why can't we use IP address instead of cookies in identifying the client in servlets?

text: I know we have some extra advantages in using the cookies over IP address, but my question is Why can't the container just remember the IP address of the client in identifying the client when he visit his site again? Is it possible for the container to remember the client with the help of IP address?


title: Release management software

text: We've got a reasonably good release management process. However large parts of it are manual tasks, i.e. Promoting builds to QA, deploying builds to internal groups, tracking releases, etc. The builds and tests are all automated with CruiseControl. Can anyone recommend some good release management / continuous deployment tools that I can use to automate the rest of our process?


title: What is "condition testing" (as defined by the ISTQB Syllabus) actually good for?

text: I am currently checking through the syllabus for the ISTQB "Technical Test Analyst" certification. This syllabus (henceforth called "TTA syllabus") contains a chapter dedicated to _"condition testing"_ (apparently this is also called _"condition coverage"_ or _"condition coverage testing_ ".) _Condition testing_ as defined in the TTA syllabus strikes me as an exceedingly strange and possibly anachronistic thing that has more to do with Grandma's Ham Story than with software testing. Let me explain... **What is "condition testing" according to the TTA syllabus?** Referring to the "Advanced Level Syllabus - Technical Test Analyst, Version 2012" of the ISTQB, available here, "condition testing" is defined as follows on page 12: > Compared to decision (branch) testing, which considers the entire decision > as a whole and evaluates the TRUE and FALSE outcomes in separate test cases, > condition testing considers how a decision is made. Each decision predicate > is made up of one or more simple “atomic” conditions, each of which > evaluates to a discrete Boolean value. These are logically combined to > determine the final outcome of the decision. _Each atomic condition must be > evaluated both ways by the test cases to achieve this level of coverage._ > > _Applicability_ > > Condition testing is probably interesting only in the abstract because of > the difficulties noted below. Understanding it, however, is necessary to > achieving greater levels of coverage that build upon it. **So let's clarify the words** Suppose we have some software-under-test on which we want to do _whitebox testing_ (i.e. we have the source code). The code naturally contains many of those _decision predicates_ that we all know and love and that show up after strings like `if`, `while`, `until` etc. An example of the decision predicate might be: > `((x>y+z) AND (y<-3)) OR ((z²+x²<4) AND (z≤y))` ![An example of a decision predicate](http://i.stack.imgur.com/HlZtV.png) This decision predicate accepts a triple _(x,y,z)_ of integer values (say) and outputs a boolean, _b_out_. The first-level functions which map _(x,y,z)_ to {TRUE,FALSE} are called _conditions_ (also _atomic conditions_ ) in the TTA syllabus. **Condition testing coverage** One attains _"condition testing coverage"_ by running test cases until all the _conditions_ found in the _decision_ yielded at least once _true_ and at least once _false_. One can thus achieve condition testing coverage by running the following five test cases (for example): ![Truth table achieving condition testing coverage](http://i.stack.imgur.com/nO80z.png) Each of the the _b0_ , _b1_ , _b2_ , _b3_ shows up at least once with _true_ and at least once with _false_. In some test cases, we do not care about a given value as it has no influence on the condition whose output we want to get right. **Addendum: Decision coverage** Incidentally, the truth table shows also that _"decision coverage"_ has been attained for this decision, as _b_out_ shows up at least once with _true_ and at least once with _false_ , so both branches of any code would be covered. **And now the question** What is "condition testing" as defined above actually good for? It won't help you ascertain the correctness of the decision predicate at all. _That_ is best done by a code inspection, letting a second team write the same expression and comparing outputs or running test cases at "boundary values" (e.g. here, for y = -4, -3, -2). Checking the individual conditions strikes me to be more about testing the CPU's ALU or maybe testing the compiler output. It is certainly suitable for checking manually written assembler code or verifying manually assembled logic. And this makes me think that "condition testing" could well be a leftover from the days where conditions were actually wired up on panels (for example in the ENIAC) and might thus be subject to wiring bugs. These days, the condition is written in high-level code and is _exactly_ the one you conceptually want. While review might be useful, a testing of the condition is just a waste of time. Or am I missing something? **Addendum: Literature Search** A search of the IEEE Xplore library for "condition testing" yields only two papers relevant to software (all the others seem relevant to hardware only), both by K.C. Tai of the Department of Computer Science of North Carolina State University. Checking one of those, Condition-based software testing strategies reveals that the author uses the term _condition_ in the sense of _decision_ above, i.e. in this paper "condition testing" is actually "decision testing". The _condition_ as used in the TTA syllabus is called _simple condition_. It seems the TTA syllabus definitions are not widely used. From the abstract: > A computer program consist of statements, such as IF and WHILE statements, > that contain conditions, which are combinations of Boolean and relational > expressions. A testing approach, referred to as _condition testing_ , is to > test a program by focusing on testing the conditions in this program. A > number of condition testing strategies have been developed, but they are not > effective for detecting errors in complicated conditions. In this paper, we > define two condition testing strategies, based on the detection of Boolean > and relational expression [i.e. expression of the form E1 _op_ E2, where E1 > and E2 are arithmetic expressions and _op_ is one of six possible relational > operators: < <=, =, !=, >, >=] errors in a condition. For these two > condition testing strategies, we show some theoretical properties and > explain why they are practical and effective for testing programs containing > complicated conditions.


title: MVC Pattern - How to get errors from the model to the controller?

text: Say I have a typical MVC setup. The controller passes on some input to the model, and asks it to do something with it. But the validation of the data fails, or there is some other problem. What's the best way of getting these errors passed back to the controller, which will then pass them to the view to be displayed to the user? At the moment, I just have an `errors` array in my model. When any errors occur, I simply add the error messages to this array, and `return false` to the controller, so it knows that errors occurred. And in the controller, I do this:               boolean result = model.process( input );          if (! result)     {        view.displayErrors( model.getErrors() );        return;     }     else        view.displaySuccess();      Is there a better way of handling this?


title: Is Open Market Code Review a Good Idea?

text: I have a huge program that I have been developing for almost 2 years. It will probably go commercial in about 6-9 months, but seeing as it is just me developing it, I'd had almost zero feedback about the code (efficiency, maintainability, proper use of best practices, etc.). I would really like to have someone or several people review it for feedback. So:   1. Are there places that I can get this service. Are sites like oDesk the way to go?   2. Is it safe? Would an NDA be sufficient to protect IP or are there other ways of going about protecting IP?   3. Are there particular qualities I should look at in a reviewer, other than they know the language and maybe some of the issues? In fact, I don't even know if the 3 questions above are the right ones to ask and I should be asking different ones first. Any advice on this subject?


title: addIfNotExist alternative

text: Is there are any standards or conventions on naming methods which add something if it not exist into another something. For example: **Store.instance().addItemIfNotExist(item)** IfNotExist is really ugly part. What workaround may be?


title: How to set up a one-man research in the difference between BDD and Waterfall?

text: Earlier, I asked a question about how to measure the quality of a project. The outcome of that question was that the quality of the project can be divided into two parts:   * Internal quality (code quality, measurable by code quality metrics)    * External quality (Acceptance test, how well the software meets the requirements) So based on that, I want to set up some research and validate the outcome of the project. The problem is, I will conduct this research on my own, so it's not possible to run the project once in BDD style and the other one in waterfall by myself. It's also not possible to compare BDD and waterfall projects on a larger scale, due to the fact that there are not enough BDD projects that can be measured because of the age of BDD. So, my question is: did anybody face this problem? How could I execute my experiment in such a way that it is of scientific value?


title: Abstract base classes and copy construction, rules of thumb

text: Often times it's a good idea to have an abstract base class to isolate the interface of the object. The problem is that copy construction, IMHO, is pretty much broken by default in C++, with copy constructors being generated by default. So, what are the gotchas when you have an abstract base class and raw pointers in derived classes?               class IAbstract     {         ~IAbstract() = 0;     }          class Derived : public IAbstract     {         char *theProblem;         ...     }          IAbstract *a1 = new Derived();     IAbstract a2 = *a1;//???      And now do you cleanly disable copy construction for the whole hierarchy? Declare copy construction as private in `IAbstract`? Are there any rules of three with abstract base classes?


title: Reasons for Pair Programming

text: I've worked in a few shops where management has passed the idea of pair programming either to me or another manager/developer, and I can't get behind it at all. From a developer stand-point I can't find a reason why moving to this coding style would be beneficial, nor as a manager of a small team have I seen any benefit. I understand that it helps on basic syntax errors and can be helpful if you need to hash something out, but managers that are out of the programming loop seem to keep seeing it as a way of keeping their designers from going to Facebook or Reddit than as a design tool. As someone close to the development floor that apparently can't quite understand from a book tossed my way or a wiki page on the subject... from a high level management position, what are the benefits of Pair Programming when dealing with Scrum or Agile environments?


title: Can I use MSBuild to build old VS6 C++ projects?

text: I have a build computer where Visual Studio not installed, only MSbuild which can build VS2008 projcets without having any Visual Studio installed. I wonder whether it is possible to use MSbuild with VC++ 6.0 project files, although I am thinking this could not be possible. In the past I have used it with a VS2008 solution file for C++, but not for building C++ 6.0 dsw file. For Vb6 we have an extension package for Msbuild (MSBuild.ExtensionPack.VisualStudio.VB6). Is anything similar available for C++ 6.0 projects? An alternative could be if there are lightweight build tools that can built VC6++ .dsw files without having to install Visual Studio 6.0 ?


title: How is the "evented-io" in node.js any different from the windows event model

text: I'm wondering how the "evented-io" in node.js any different from the windows async IO model? Is the callback from node.js executed on a thread, if not, where is it run? I don't mean to question the productivity or awesomeness of node, but specifically to understand if the architectural design differs from what is commonly done in the windows space, say with WCF or ASP.Net.


title: Best way to expose a data-oriented service

text: I'm currently tasked with writing a wcf service that, for now, will only used inside the company network, the problem is that I'm not sure how I should handle the operations it exposes. The software that will use this service will have to modify similar tables in different ways. For example a table, that has columns a,b,c and d. Program X only updates columns a and b, while program Y updates b,c and d. I feel that a generic Update method that accepts the whole record is easier to write and makes the service less bloated. But it does feel less secure, and would probably make it harder to understand for new developers. How do I best handle these situations on a service level? edit: Yes the tasks are in a sense unique, but the problem is that it's difficult to figure out how unique the service should be. Do I make a general service to allow access to the data, and let the details of those tasks be handled client-side? Security concerns are not that high. The biggest concern is maintainability and ease of understanding. At this moment we have 20+ databases where some of them have 100+ tables.


title: Why would you want to look at IL code?

text: I was reading a blog post over at Channel 9 about the release of an open source .NET/CLR decompiler. I was wondering as to why would you want to decompile a .NET/CLR application and look at its IL code? I'm just curious. **[Edit]** And are there any use for decompilers during the development phase? **[Edit]** I'm a little perverse; I want to know when was the last time you used a decompiler for a software development project, and why?


title: Are closures with side-effects considered "functional style"?

text: Many modern programming languages support some concept of **closure** , i.e. of a piece of code (a block or a function) that   1. Can be treated as a value, and therefore stored in a variable, passed around to different parts of the code, be defined in one part of a program and invoked in a totally different part of the same program.   2. Can capture variables from the context in which it is defined, and access them when it is later invoked (possibly in a totally different context). Here is an example of a closure written in Scala:               def filterList(xs: List[Int], lowerBound: Int): List[Int] =       xs.filter(x => x >= lowerBound)      The function literal `x => x >= lowerBound` contains the free variable `lowerBound`, which is closed (bound) by the argument of the function `filterList` that has the same name. The closure is passed to the library method `filter`, which can invoke it repeatedly as a normal function. I have been reading a lot of questions and answers on this site and, as far as I understand, the term **closure** is often automatically associated with **functional programming** and functional programming style. The definition of function programming on wikipedia reads: > In computer science, functional programming is a programming paradigm that > treats computation as the evaluation of mathematical functions and avoids > state and mutable data. It emphasizes the application of functions, in > contrast to the imperative programming style, which emphasizes changes in > state. and further on > [...] in functional code, the output value of a function depends only on the > arguments that are input to the function [...]. Eliminating side effects can > make it much easier to understand and predict the behavior of a program, > which is one of the key motivations for the development of functional > programming. On the other hand, many closure constructs provided by programming languages allow a closure to capture non-local variables and change them when the closure is invoked, thus producing a side effect on the environment in which they were defined. In this case, closures implement the first idea of functional programming (functions are first-class entities that can be moved around like other values) but neglect the second idea (avoiding side-effects). Is this use of **closures with side effects** considered functional style or are closures considered a more general construct that can be used both for a functional and a non-functional programming style? Is there any literature on this topic? **IMPORTANT NOTE** I am not questioning the usefulness of side-effects or of having closures with side effects. Also, I am not interested in a discussion about the advantages / disadvantages of closures with or without side effects. I am only interested to know if using such closures is still considered functional style by the proponent of functional programming or if, on the contrary, their use is discouraged when using a functional style.


title: Good strategy to implement a listener processing tasks provided by the database

text: Let's assume this conceptual scenario: The database is constantly populated with "a ton" of tasks named `PleaseSendAnEmail`. A scheduler/listener in background is aimed to handle those tasks.   Of course, rules are that a specific mail shouldn't be sent more than once and that the handling should be the fastest possible.   Possible status for the task are: `New`, `InProgress`(facultative regarding the strategies below), `Complete` and `Fail`. Various strategies for the listener (I present one process iteration for each): **Single threaded solution:**   * Querying one task whose status is "New".   * Sending the task to the worker `EmailSender`.    * When the worker did the job, passing the status to `Complete` Pros of this solution: Safety !   Cons: Slow, very slow.. **Multi-threaded solution:**   * Querying several tasks at once whose status is "New".   * Multiple `EmailSender` workers are instantiated: Dispatching all the tasks to them   * As soon as a worker has handled one occurrence, its corresponding status is set to `Complete`.   * Meanwhile the workers are processing, a new query is processed, then tasks dispatched to the worker queues etc.. the whole being asynchronous. Pros: Wow! Fast!   Cons: Potential race conditions, since a same task being currently processed could be retrieve again by the next query since the current worker processing it might not completed yet => More than one mail occurrence could be sent! Bad! **Multi-threaded solution involving the`InProgress` status:**   * Querying several tasks at once whose status is "New".   * Updating immediately those tasks with the status `InProgress`.    * Multiple `EmailSender` workers are instantiated: Dispatching all the tasks to them   * As soon as a worker has handled one occurrence, its corresponding status is set to `Complete`.   * Meanwhile the workers are processing, a new query is processed, then tasks dispatched to the worker queues etc.. the whole being asynchronous. Pros: multi-threaded and safety! No more mails than expected!   Cons: Increasing access to database...to mark status as `InProgress`..possible contention on database with a huge number of events. **Multi-threaded solution avoiding queries while at least one worker is still processing:**   * Querying several tasks at once whose status is "New".   * Multiple `EmailSender` workers are instantiated: Dispatching all the tasks to them   * As soon as a worker has achieve one task, its corresponding status is set to `Complete`.   * Meanwhile the workers are processing, a new query is processed, then tasks dispatched to the worker queues etc.. the whole being asynchronous. Pros: Multi-threaded, safety! No need to involve a locking status as `InProgress`!   Cons: If for any reasons, one mail takes 8 seconds to be sent, it will delay the next query! Many jobs could be seen as idle, awaiting for the next query... Which solution should I use? Is there any other efficient solution?


title: Cascading "Deleted" records that aren't really deleted

text: Just trying to get some ideas on what people do for this scenario. We have a system database(SQL Server 2008 R2) that has tables and every table has a field we can call "Deleted". It's basically a bit field if its a 1 the record is deleted, if it is a 0 it is not deleted. The field is not nullable and its default is of course 0. We cannot allow real deletions to the database, so to get around this we set a bit field (Deleted) to true. In our application we end up with queries that look like this: `SELECT blah FROM MyTable WHERE .. AND Deleted=0` Basically we filter for records so we only get non deleted rows. Our issue is related records that need to cascade. What do people prefer, should we be doing this in the server side code so that when you delete a record it delete's (Sets the deleted bit field to true) for all related records? Or should this be a trigger that has to check this field and sets the bit field for all related records to 1? Or are we completely on the wrong path?


title: Avoid code repetition in CRUD operations

text: I'm developing a PHP application and I find myself doing basically the same code for, say, creating an object based on a form filled by the user. The objects are of different classes, but the process is mostly the same: take the data from the form, apply validation, save/return error. Is there a way to automatize this process? I ask also because I intend to write a public API and use the same code to do those operations, instead of just copy/pasting. I thought of making a kind of Factory Method pattern that receives the type and the data from the form (or any array), create an instance and set the data, testing the validation afterwards (each object knows how to validate their own fields). And that for each of the other CRUD operations as well. Is that feasible/good practice? Should I just repeat the similar code? There are any other way to do it? For the record, I'm using ORM already (Doctrine). Still, I think that a lot of `create` functions with pretty much the same code (a bunch of `set*`) is something too repetitive.


title: How to create an algorithm for determining Boolean Tautologies

text: So i am right now exploring some topics in a proof course and it occurred to me to try to create a boolean tautology solver. I would like an algorithm that is more efficient than brute force. Problem Statement: given a string of '(', ')', '[and]', '[or]', ! and pieces of text that denote variable names (which by definition cannot include parenthetical marks brace marks or ! marks) which must be surrounded by a pair of parenthesis The words 'TRUE' and 'FALSE' are also reserved determine if the boolean string is well-formed and if so, is it a tautology ex: `(alpha)[and](beta)` is well formed and not a tautology because if: alpha = false and beta = true is a counter example ex: `(alpha)[or]!(alpha)` is well formed and a tautology because `((X)[or]!(X))` is by definition a tautology ex: `((alpha)[or]((beta)[or]!(beta)))` is well formed since `(beta)[or]!(beta)` is true and `((alpha)[or](TRUE))` is always true ex: `((alpha[and](beta))` is not well formed Some ideas I had for this was to begin by forming a parenthetical tree. Since every statement will be encapsulated by parenthesis before it can be applied to a [or], [and], or [!] operator what I can do is partition the string into its separate highest level blocks enclosed by parenthesis (clause1)(clause2) to generate 2 nodes of a tree pointing to the high level node Each node contains information about whether it has a ! attached to it's front, and if it has nodes below, what operator is used to unify those two nodes This tree could be quickly generated to reduce the statement to individual literals and easily verify if the statement is well-formed (are there an equal number of ( as ) and does every [or] and [and] have two statements surrounding and a pair of encapsulating parenthesis around these two statements. Now my plan was to systematically crawl up to nodes that do have a (!) value and distribute the not via DeMorgan's laws. If I am ever forced to do something along the lines (x and !x) I have immediately found a contradiction and can abort. I'm still not perfectly clear what must happen at this stage however


title: Why to keep wrapping closure in each js-file if it can be added after concatenating?

text: At the moment every javasrcipt file in our project includes closure wrapper. Before deploying all files are concatenated and minimized. And i'm asking myself, do we really need all that closures OR one closure added after concatenation will do the job. I can see only one reason not to do that - the variable we are sharing between files will get in the global namespace. But there is no conflict so is don't see any problem. The real question is what other cons may be? Or more generally what approach is better - one closure or many?


title: Ruby Shoes for non-trivial apps

text: I've been taking a look at Ruby Shoes for GUI development with Ruby. So far, it's been a pretty good experience for making simple apps. However, I am quite worried about being able to write large scale applications with it. For example, how would I go about using MVP pattern with this framework? For now, I have not been able to not make presentation concerns leak into the view because of the lack of some kind of "data binding". I have code that looks like this :               Shoes.app do         @view = SampleView.new         @presenter = SamplePresenter.new @view              @label = para @view.sample_property              button "Update sample_property" do             @presenter.update_sample_property         end     end      Here, the call to `@presenter.update_sample_property` updates `@view.sample_property` but the label is not updated accordingly. For this to work, I would have to make `@presenter.update_sample_property` to return a string, and then call `@label.text = return_value`, but I think that would violate the MVP principle of not having presentation logic in the view. I'm used to work in .Net with the MVP pattern so I don't know if the pattern applies correctly to Shoes like I tried to do. Are there any resources out there for making non-trivial apps with Shoes? Especially using the MVP pattern or something similar? EDIT : I took a look at the shoebox to see what other people have achieved with the framework. Though I did not look through it extensively, at first sight it seems like they are all simple projects with no real purposes. UPDATE : I've finally been able to come up with something that satisfies me. Oh, and by the way, I moved to green_shoes because it is all written in ruby and I can run it from the command line rather than from the Shoes application. Packaging is not an issue for me quite yet.


title: Is Ruby on Rails' Active Record an example of Aspect-Oriented Programming?

text: From Clean Code, about Cross-Cutting Concerns: > Note that _concerns_ like persistence tend to cut across the natural object > boundaries of a domain. You want to persist all your objects using generally > the same strategy, for example, using a particular DBMS... Is Active Record an example of aspect-oriented programming? > In AOP, modular constructs called _aspects_ specify which points in the > system should have their behavior modified in some consistent way to support > a particular concern. This specification is done using a succinct > declarative or programmatic mechanism. If Active Record is an example of AOP, what is the "aspect"? Is it the class declaration that inherits from Active Record?               class Foo < ActiveRecord::Base


title: Python for a desktop app

text: I currently have a .NET app that I want to convert to being cross platform, as a growing number of my users want a Mac version. Since this forum doesn't seem to like questions that are "what languages are suitable for these requirements", I'll focus this question on Python as the language of choice. Will Python be a good fit for the requirements below? Drawbacks?   * Desktop app - many of my users do not have an Internet connection where they use the software, so a web app will not do   * Object oriented   * Store data in a relational database as well as configuration files   * Reporting engine, preferably using templates   * Network connectivity - Some users setup multiple workstations sharing a single data file   * Support RS-232 serial port communications, read and write   * Support video capture   * Play WAV and other sound files   * Simple app installation - too many of my users are not very computer savvy, so the easier the install the better   * Be able to implement a demo or time-limited licensing model I considered Java, but am hesitant being at the mercy of Oracle and many people have had security concerns about the JVM. I also considered the Mono project to keep the app in .NET, but their MoMA utility shows thousands of unsupported items. I really prefer to have just one code base to maintain, instead of one for Windows and one for Mac. Python seems to be what I keep coming back to. For some background on myself, most of my experience has been with VB, VB.NET, C#, and Java with some dabbling in PHP/Javascript/HTML. All of my desktop experience has been with Windows.


title: Music Notation Editor - Refactoring view creation logic elsewhere

text: _Let me preface by saying that knowing some elementary music theory and music notation may be helpful in grasping the problem at hand._ I'm currently building a Music Notation and Tablature Editor (in Javascript). But I've come to a point where the core parts of the program are more or less there. All functionality I plan to add at this point will really build off the foundation that I've created. As a result, I want to refactor to really solidify my code. I'm using an API called VexFlow to render notation. Basically I pass the parts of the editor's state to VexFlow to build the graphical representation of the score. _(EDIT: The following diagram is outdated as I began to rework the structure, please see the update at the bottom of the post for the new diagram)_ Here is a rough and stripped down UML diagram showing you the outline of my program: In essence, a `Part` has many `Measure`s which has many `Note`s which has many `NoteItem`s (yes, this is semantically weird, as a chord is represented as a `Note` with multiple `NoteItem`s, individual pitches or fret positions). All of the relationships are bi-directional. There are a few problems with my design because my `Measure` class contains the majority of the entire application view logic.   1. The class holds the data about all VexFlow objects (the graphical representation of the score). It contains the graphical Staff object and the graphical notes. (Shouldn't these be placed somewhere else in the program?)   2. While `VexFlowFactory` deals with actual creation (and some processing) of most of the VexFlow objects, `Measure` still "directs" the creation of all the objects and what order they are supposed to be created in for both the VexFlowStaff and VexFlowNotes. I'm not looking for a specific answer as you'd need a much deeper understanding of my code. Just a general direction to go in. Here's a thought I had, create an `MeasureView`/`NoteView`/`PartView` classes that contains the basic VexFlow objects for each class in addition to any extraneous logic for it's creation? but where would these views be contained? Do I create a `ScoreView` that is a parallel graphical representation of everything? So that `ScoreView.render()` would cascade down `PartView` and call `render` for each `PartView` and casade down into each `MeasureView`, etc. Again, I just have no idea what direction to go in. The more I think about it, the more ways to go seem to pop into my head. I tried to be as concise and simplistic as possible while still getting my problem across. Please feel free to ask me any questions if anything is unclear. It's quite a struggle trying to dumb down a complicated problem to its core parts. **UPDATE:--------------------------------------------------------------------------** So I went ahead and started refactoring with my idea from above. Here is an updated Diagram @JW01 I understand why bi-directional relationships are potentially bad (difficult to maintain, increased complexity), however, I do believe the increased flexibility is worthwhile and I have implemented it in a maintainable way. Each notation "container" (`Score`, `Part`, `Measure`, `Note` \- all contain children of some sort) inherits from `Container` (this relationship isn't shown in the diagram because the program I use is shitty and it looks super messy). The `Container.addItem(item)` method mixes in the `Traversable` class methods and `parent` property to the item added. To me this seemed pretty clever and easy to understand. Basically, any item that gets put in a container gets extended functionality. As a mentioned in a previous comment, I may want to pull out a nice music data API out of this, which would allow for "plug-ins" to be easily created. Traversing in both directions would be particularly helpful for functionality like that. Plus these classes are small and maintainable, and unlikely to change. However, I understand that the less things that depend on these relationships the better. So it's definitely best if I isolate this traversing functionality for use with the `Selection` module. I'm noticing that my `View` classes are doing a lot now. Building, rendering, formatting and handling click. It would probably be wise to factor out a an abstract View module composed of a ViewBuilder, ViewFormatter, ViewRenderer, ClickBehavior?


title: What is the difference between btree and rtree indexing?

text: I've noticed on MySQLWorkbench that you can choose how to store your indexes before forward engineering your design. The storage types are:   1. BTREE   2. RTREE   3. HASH Researching this, I found some information that was pretty much over my head, so I'm looking for practical information on what the difference is between these and/or why you should choose one over another. Also, I have never chosen a storage type before, so I assume MySQL is choosing a default storage type (BTREE?)


title: How do document-oriented databases implement references?

text: In relational world we have Foreign Keys to reference other entities. But how do document-oriented databases like MongoDb, CouchDb, RavenDb implement references among entities? **Update.** StackExchange related example. We have Question entity and its tags. Each tag, is a separate entity so it has its properties (for example, description). How can I reference tags for some Question?


title: Solution Checker Algorithm for a Game

text: For the moment I'm strictly speaking in Pseudocode. I'd only like to see if i'm on the right track. The game I'm talking about is similar to a application called FLOW.   In this game, you're given a nxn board(Always a square) and need to fill out each slot in the board. Similarly, when a board game is initialized, it will have objects like the set up below...               Board - 1 2 3 1             0 0 0 0             0 2 3 0             0 0 0 0      In this example - the objects are 1 2 and 3. A solution would be as follows...               Board - 1 2 3 1             1 2 3 1             1 2 3 1              1 1 1 1      The whole purpose is to fill out the board game by connecting the starting object to the end object. What I have in mind is the following...               CheckSolution(1d representation of the boards state, int totalcolors) {            // I would loop through the colors, a 0 is not a color - empty.        // If the board has a 0 in the array, I would automatically return a false solution.        // Then, I would call DepthFirstSearch on the color.             // -- I would set a counter on this to count the # of colors, if this isn't equal to the total # of that particular color, I would return false.          // Else, the solution is valid.     }      Does this sound reasonable? Or is the better way to implement a solution checker.


title: What is the point where multitreaded programming becomes slower than the problem?

text: I currently try to design an engine at the core level. However, I cannot decide if input thread should be mixed with a rendering thread or any other thread. Would making it an extra thread with all the locks it will require be slower? If it's same or faster, would at least be marginally faster? [Consider the above only an example to the concept.]


What is this pattern called? Is this a variant of the Module pattern? I remember there's disadvantage to this pattern and it's related to memory usage.               var module = function() {              this.Alert = function() {                 alert("I'm a public");         }              function iamPrivate() {              alert("not callable because I'm private");            }     }          var inst = new module();     inst.Alert();


title: Is there a term for this coding practice?

text: One of the incidental complexities of introducing features to an existing system is that the programmer often has to touch several areas of code that are not immediately adjacent. Over the long haul it can be unclear when looking at a bit of code that it pertains to another bit found elsewhere. It's both ugly design and a maintenance hazard. One of the properties of superior code, in my book, is its ability to keep a concept localized in one place. Sometimes this is built in to an architecture up front making it easy to plug new features into a system. In scripting languages where all classes remain open to extension at runtime, it can be easy to think of the language as its own platform and not go the route of formalizing how things plug in. An app written in a scripting language could accept a module whereby the module reaches out to the various system components and changes them -- adding aspects to functions, wiring into events, and so on. Essentially, because the architecture wasn't properly designed for extension, we utilize a poor-man's plug-in system and oftentimes this suffices. In effect, we eliminate the need to modify several spots directly and instead tweak the system perhaps in similar spots but in an automated fashion. That's what I'm focusing on. We still need to modify things that are spread across our system, but we do so in a way that keeps the entirety of the change localized to a single file (module). In there a design pattern/term for the practice of simply localizing all the code (even if it has tentacles) to a single physical location (its own file)? I'm not sure it's the plug-in pattern or the extensibility pattern because in many cases a scripted system may not have been designed with extensibility in mind; however, it is still possible to localize change. Would this simply be called modularity? I'm really just looking for a shared term that I can use to rightly convey the concept without all the explanation.


title: Name for sanitizing at the right time?

text: Recently we had an issue on our site where someone attempted SQL injection via a cookie (we'll call it `lastID`). NOC was in a frenzy and angry about how the cookie as an attack vector could be ignored. They had a developer create a class for managing cookies that will sanitize `lastID` (and eventually other cookies) to check that it is numeric. However, I think that this is wrong. The problem wasn't that `lastID` wasn't numeric, it was that the query that uses it was vulnerable to injection. I'm in charge of the review of the code changes, and I want to bring up the fact that forcing `lastID` to be numeric is not particularly useful and perhaps even undesirable. Is there a term or concept that describes sanitizing at the right time (i.e. sanitizing at query time rather than at cookie retrieval time), or "over- sanitizing" (e.g. forcing `lastID` to be numeric) that I can use to describe what's happening/should happen in my review? The second part of Postel's Law seems to apply here in my mind: > Be ... liberal in what you accept


title: Most readable way to format long if conditions?

text: Long winding `if` conditions should be avoided if at all possible, yet sometimes we all end up writing them. Even if it's a very simple condition, the involved statements are sometimes simply very wordy, so the whole condition ends up being very lengthy. What's the most readable way to format those?               if (FoobarBaz::quxQuux(corge, grault) || !garply(waldo) || fred(plugh) !== xyzzy) {         thud();     }      or               if (         FoobarBaz::quxQuux(corge, grault)      || !garply(waldo)      || fred(plugh) !== xyzzy     ) {         thud();     }      or               if (FoobarBaz::quxQuux(corge, grault)         || !garply(waldo)         || fred(plugh) !== xyzzy) {         thud();     }      or               thudable = FoobarBaz::quxQuux(corge, grault);     thudable ||= !garply(waldo);     thudable ||= fred(plugh) !== xyzzy;          if (thudable) {         thud();     }      or any other preferences?