title: Selenium and non technical team members

text: I work on a team developing a web site with a large number of pages. The QA guy on the team currently runs all of the tests manually. I am thinking of having him create a bunch of Selenium scripts. I don't think he can automate all of the tests, but he could automate many of them. Because he doesn't have a programming background, how hard will it be for him to create and manage a batch of Selenium scripts? What issues will he need help with?


title: Will an app made for windows store support WindowsRT, windows8 and windows 8 mobile?

text: I am very much confused about these. I would like to develop app for windows 8 , Windows RT , and windows mobile. I have windows 8 OS installed in my laptop. As far as I know, Windows RT is for ARM based devices. HERE ARE MY QUESTIONS:   1. I develop an app, and put in windows store. Will that can be downloaded from a ARM based device ,which runs on Windows RT, AND from a windows 8 laptop , and same from a Windows 8 mobile? OR should it be different apps ?


title: How to access / query Team Foundation Server 2012 with Odata?

text: I've tried to find a solution for this for hours now, and I'm getting the same results in the end, asking me to install a lot of Azure and other stuff, plus running some example project .sln that I can't open with my 2012 version of Visual Studio. So, I'm pretty much stuck, and have some pretty straight forward questions regarding this:   1. Does TFS 2012 include the Odata service in any way, so that I don't have to install it?   2. If not, how can I install a NATIVE 2012 version of the Odata service for TFS 2012?   3. Is it possible that I'm aiming for the wrong target here? I'm looking for a solution to the following: I have a TFS 2012 Server that I need to be able to create Work Items on programatically, based on data from our Help Desk system. Then I need to query these Work Items for changed status since its creation, and update the Help Desk Database. Am I better off using the "regular" TFS API? I was kinda thinking that the Odata way was more "future proof", but I'm not sure...


title: NUnit SetUp and TearDown

text: I have some experience in MS Test but new to NUnit.   1. Whether NUnit [Setup] is corresponding to [ClassInitialize] or [TestInitialize] in MS Test?   2. What is the NUnit attribute corresponding to [TestInitialize]? REFERENCE:   1. http://stackoverflow.com/questions/1873191/testinitialize-gets-fired-for-every-test-in-my-visual-studio-unit-tests   2. http://stackoverflow.com/questions/4602288/nunit-testcontext-currentcontext-test-not-working


title: How do I (quickly) let people know that software I am providing for free is not abandon-ware?

text: As an independent, individual programmer: **How do I let people very quickly know that I have not abandoned the software I've written and given away for free?** That I am putting in the effort required to maintain and support my software to a professional level? When software written by one or two developers is available for free, or marked as open-source, usually the default assumption is that it's abandon- ware. This is usually a safe assumption - check out the answers to this question if you doubt it: Why do programmers write applications and then make them free?. There are lots of programmers who provide free and/or open-source tools which are not abandon-ware, though. If we're talking about large companies, ie Google, there's no real problem telling the difference between supported, live tools and software, and those which are abandoned or discontinued. A lively git repository isn't quick - users will have to be savvy enough to understand the repository and know where to look for it. Consistent marketing and community management take more time and effort than I can put in on my own. Also, if my software becomes popular/successful, I assume those will grow on their own, and be supported by power users in the community.


title: function pointers are so complex to me

text: I found this code sample in this answer by Armen Tsirunyan.               class MyClass     {        public:        typedef void (*funcPtr)(int, int);        MyClass(funcPtr whatToCall)        {           callme = whatToCall;        }        void myClass::callMain()        {              callSomeApi(callme, <some arguments>);  //callme function pointer is passed as argument        }     private:        funcPtr callme;     };          void f(int a, int b) {blah blah blah};               int main()     {        MyClass myObject(f);        myObject.callMain(); //will call the api function with f passed as argument     }      I would like to know the advantages to use such a function pointer as a class member. If there are more, I should be overwhelmed to their uses and calls. Do you have some tips to help me memorise its usage?


title: What are the differences between the Unified Process and the Rational Unified Process?

text: Are there any differences between the Rational Unified Process (RUP) and the Unified Process (UP)? What does "Rational" mean, in this context?


title: Caching by in-memory dictionaries. Are we doing it all wrong?

text: This approach is pretty much the accepted way to do anything in our company. A simple example : when a piece of data for a customer is requested from a service, we fetch all the data for that customer(relevant part to the service) and save it in a in-memory dictionary then serve it from there on following requests(we run singleton services). Any update goes to DB, then updates the in memory dictionary. It seems all simple and harmless but as we implement more complicated business rules the cache gets out of sync and we have to deal with hard to find bugs. Sometimes we defer writing to database, keeping new data in cache till then. There are cases when we store millions of rows in memory because the table has many relations to other tables and we need to show aggregate data quickly. All this cache handling is a big part of our codebase and I sense this is not the right way to do it. All of this juggling adds too much noise to the code and it makes it hard to understand the actual business logic. However I don't think we can serve data in a reasonable amount of time if we have to hit the database every time. I am unhappy about the current situation but I don't have a better alternative. My only solution would be to use NHibernate 2nd level cache but I have nearly no experience with it. I know many campanies use Redis or MemCached heavily to gain performance but I have no idea how I would integrate them into our system. I also don't know if they can perform better than in- memory data structures and queries. Are there any alternative approaches that I should look into?


title: How to read reduce/shift conflicts in LR(1) DFA?

text: I am reading an explanation (awesome "Parsing Techniques" by D.Grune and C.J.H.Jacobs; p.293 in the 2nd edition) and I moved forward from my last question: How to get lookahead symbol when constructing LR(1) NFA for parser? Now I have such "problem" (maybe not a problem, but rather need of confirmation from some more knowledgeable people). The authors present state in LR(0) which has reduce/shift conflict. Then they build DFA for LR(1) for the same grammar. And now they say it does **not** have a conflict (lookaheads at the end):               S -> E .        eof     E -> E . - T    eof     E -> E . - T    -      and there is an edge from this state labeled `-` but no labeled `eof`. Authors says, that on `eof` there will be reduce, on `-` there will be shift. However `eof` is for shift as well (as lookahead). So my personal understanding of LR(1) DFA is this -- you can drop lookaheads for shifts, because they serve no purpose now -- shifts rely on input, not on lookaheads -- and after that, remove duplicates.               S -> E .        eof     E -> E . - T          So the lookahead for reduce serves as input really, because at this stage (all required input is read) it is really incoming symbol right now. For shifts, the input symbols are on the edges. So my question is this -- am I actually right about dropping lookaheads for shifts (after fully constructing DFA)?


title: Design suggestions needed to create a MathBuilder framework

text: Let explain what I'm trying to create. I'm creating a framework, the idea is to provide base classes to generate a math problem. Why do I need this framework? Because at first time, I realized when I create a new math problem I always do the same steps.   * **Configuration settings such range numbers**. For example if I'm developing multiplications, in beginner level only generate the first number between 2-5 or in advanced level, the first number will be between 6- 9, for example.   * **Generate problem method**. All the time I need to invoke a method like this to generate the problem. This one receives the configuration settings and generate the number according to them. And generate the object with the respective data.   * **Validate the problem**. Sometimes the problem generated is not valid. For example, supposed I'm creating fractions in most simplified, if I receive 2/4, the program should detect that this is not valid and must generate another like this one, 1/4.   * **Load the view**. All of them, have a custom view (please watch below the images).   * **All of the problems must know how to CHECK if the user result is correct**.   * **All of this problems has answers**. Some of them just require one answer, anothers may require more than one, so I guess a way to maintain flexibility to the developer has all the answers he wanna used.   * **At the beginning I started using PRISM**. Generate modules for each math problem was the idea and load it in the main system. I guess are the most important things of this idea. Let me showing some problems which I create in a WPF standalone program. Here I have a math problem about areas. When I generate the problem a set to the view the object and it draw it. ![enter image description here](http://i.stack.imgur.com/H46YA.png) ![enter image description here](http://i.stack.imgur.com/SNwLq.png) In beginner level, I set in the configuration settings that just load square types. But in advance level, can load triangles and squares randomly. In this another, generate a binary problem like addition, subtraction, multiplication or division. ![enter image description here](http://i.stack.imgur.com/AQUzo.png) ![enter image description here](http://i.stack.imgur.com/YGJgE.png) Above just generate a single problem. The idea of this is to show a test o quiz, I mean get a worksheet (this I call as a collection of problems) where the user can answer it. ![enter image description here](http://i.stack.imgur.com/wMiqy.png) I hope gets the idea with my ugly drawing. How to load this math problems? As I said above, I started using PRISM, and each module contains a math problem kind. This is a snapshot of my first demo. ![enter image description here](http://i.stack.imgur.com/toywO.png) Below show the modules loaded, and center the respective configurations or levels. Until momment, I have no idea to start creating this software. I just know that I need a question | problem class, response class, user class. But I get lost about what properties should have to contain in it. Please give a little hand of this framework. I put much effort on this question, so if any isn't clear, let me know to clarify it.


title: Looking for suggestions for starting and managing a programmer user group

text: I am thinking about starting an area user group to discuss and share information on a variety of technology topics surrounding programming practices. Any suggestions for finding attendees, space, sponsors, speakers, etc. - and managing all of this?


title: Refactoring c++

text: I know that there are some other questions about c++ refactoring, but none satisfies my needs. I have a background in java and python programming, but now I'm approaching C++. I've read (and absolutely love) books about agile coding, tdd, refactoring, etc. The first that comes in my mind is "Clean Code". From this I have learned a lot of things: keep my functions short, keep my classes short, keep names of variables/classes consistent etc.. I like very much this way of working: first resolve the problem, then refactor in small functions (and one function does only one thing), adding subclasses, etc. I strongly believe that this way of working is made easy from modern IDE: add file, rename function, rename classes, etc.. I'm now coding in c++ with cmake inside QtCreator. All of those things are more difficult. Even adding a file is "more difficult" (I have to generate one header file, one source file, add them to cmakelist.txt, run again cmake, etc). Thinking about renaming files (I have to manually change all includes) or some strong refactoring methods that in Java with Eclipse has no cost now gives me a headache. I mean.. it is not "difficult" in the meaning that are "hard task", but the human mind is kind of lazy: if I can do other easiest way.. In Java with some modern IDE like Eclipse.. refactor is the fun parts, some clicks and voilà, it is done, I do it every time I pass a test. It is easy, fun, and I like reading my clean code with small functions and nice names. Now everything is more difficult mainly because there is no tools that can do it without cost. I bare myself in bad attitudes driven by lazyness: write several classes in a single super-long .h file because I don't want to create new files, spent hours in modify classes/functions/variables with more appropriate names and change manually all includes, write long functions because when I automatically change a function attributes that concerns the std lib QTCreator is deleting the templates so I avoid it, and many others.. This is quite frustrating.. what can you advice me? Do I have to get more relaxed in the "rules" of writing clean code? Do I have to does not think about those stuffs and thinking only in getting things works? Or (maybe this is the more importart question) do I have to thinking about some other way of working? No more incremental/iterative/agile way but more waterfall and spend more time in design stuffs before coding in the hope of minimize the refactor when test are passed? Anyway, any comment are welcome because I am very far to be a good programmer : )


title: is Python PHP polyglot a good design?

text: We have Python middle-tier for our Web App . Now we need to render 3 different HTMLs...   * for older browsers (simple read-only interface)   * for HTML5 browsers (LOT more complex than older browsers)   * for mobile website (simple XHTML-MP) Now, we need to keep the Python middle-tier completely independent of any HTML -- just pure business logic. So, we think we should use a PHP layer on top of Python to generate these HTMLs. PHP would talk to Python via SOA. First -- is this a good idea? And if not, can you suggest a better design? Second, if this is a feasible design -- do you think PHP+Python is good (maintainable) mix. If not, how about replacing the PHP layer by yet another Python layer. Just remember that our middle-tier needs to be COMPLETELY isolated from any HTML thingy :) \-- **_UPDATE_** \-- The reason we're inclined to using PHP is...   * PHP itself is just a template engine embedded into HTML -- and it is SO easy to generate complex HTML with it. On the other hand, Python is more of a general purpose language and generating HTML with it will require us to use a third party library which will entail maintenance/upgrade/security hassles. Generating HTML is a sort of raison d'être for PHP.   * Secondly, Python support for Nginx is NOT as good as PHP.


title: Design document for project in C

text: I have had some experience in documenting the design for project developed in OOP languages. I made classes and used class diagrams to showcase the overall design structure of the implementation when I used OOP languages. **Problem :** I am about to begin a project in C language. How am I supposed to go about writing the design document now ? **Q.** Shouldn't the design document be independent of language of implementation ? But I am not able to figure out, with no classes involved in my implementation, how and between what will I show relations ? **Q.** Is there any standard way to document C projects ? I am totally confused as to what exactly am I supposed to show in the design document ? Functions ? How will I related them ? Will appreciate link to any open source C project which might have such a documentation for reference ? P.S. : Project is minimal kernel development in C language.


title: Spring bean injection into a hibernate validator constraint

text: I have a controller method like listed below whose argument is annotated with `@Valid` to validate `PasswordChange` object using a Hibernate validator `@Constraint`. Both `PasswordChange` and a sample constraint are listed below. As you can see, I am injecting up `loginDao` inside the constraint. Is this an anti-pattern ? The other alternative I can think of is injecting the daos into the `PasswordChange` object so that the loginDao's are available inside the implementations of `ConstraintValidator<A, V>`. Somebody said that mixing data with business logic is an anti-pattern in spring. Any suggestions are welcome. **Controller Method** * * *               @RequestMapping(value = "/passwordChange", method = RequestMethod.POST)     public @ResponseBody PasswordInfo passwordInfo(@RequestBody @Valid PasswordChange passwordChange)             throws PasswordChangeException {         return passwordService.changePassword(passwordChange.getLoginKey(), passwordChange.getOldPassword(), passwordChange.getNewPassword());     }      **PasswordChange Bean** * * *               public class PasswordChange {              @LoginAttemptsExceeded         private String loginKey;              private String oldPassword;              private String newPassword;              @Autowired         private LoginDao loginDao;              private LoginEntity login;         private Person person;                   public PasswordChange() {                }              public PasswordChange(String loginKey, String oldPassword, String newPassword) {             this.loginKey = loginKey;             this.oldPassword = oldPassword;             this.newPassword = newPassword;             }              @PostConstruct         public void postInit() {                 login = loginDao.findByLogin(loginKey);             person = login.getCorePerson();         }          }      **Sample Constraint** * * *               @Target({ FIELD, ANNOTATION_TYPE })     @Retention(RUNTIME)     @Constraint(validatedBy = LoginAttemptsExceededValidatorLoginId.class)     @Documented     public @interface LoginAttemptsExceeded {              String message() default "{com.mrll.global.core.constraint.loginAttemptsExceeded}";              Class<?>[] groups() default {};              Class<? extends Payload>[] payload() default {};          }      **Sample Constraint Validator** * * *               public final class LoginAttemptsExceededValidatorLoginId implements ConstraintValidator<LoginAttemptsExceeded, String> {              @Resource         private LoginDao loginDao;              private LoginAttemptsExceeded loginAttemptsExceeded;              @Override         public void initialize(final LoginAttemptsExceeded loginAttemptsExceeded) {             this.loginAttemptsExceeded = loginAttemptsExceeded;         }              /**          * Validation fails if the login attempts have exceeded the preset number.          * @param loginId          * @param constraintValidatorContext          * @return          */         @Override         public boolean isValid(final String loginId, final ConstraintValidatorContext constraintValidatorContext) {             if(StringUtility.IsEmpty(loginId)) return false;                  return !loginDao.findByLogin(loginId).isLoginAttemptsExceeded();         }     }


title: Does open sourcing your work help you?

text: Are developers actually likely to receive significant _help_ by open sourcing a work in its unfinished stages, or are open source consumers more likely to want something ready to use? This is frequently cited as a benefit of open source, but I haven't been able to find evidence of it outside of already established products.


title: what is the javascript internal data structure?

text: Consider a basic js object:               var obj={x:1,y:'2'};      Is this stored internally as a hashtable or does js use a different mechanism for key value pairs? If they are hash tables does anyone know how they handle collisions?


title: Are there any companies using BDD in a .NET environment?

text: I've seen BDD in action (in this case using SpecFlow and Selenium in a .NET environment) for a small test project. I was very impressed - mainly due to the fact that the language used to specify the acceptance tests meant they engaged with the product owner much more easily. I'm now keen to bring this into my current organisation. However I'm asked 'who else uses this?' and 'show me some case-studies'. Unfortunately I cannot find any 'big names' (or even 'small names' for that matter!) of companies who are actively using BDD. I have two questions really:   * Is BDD adopted by companies out there? Who are they?   * How can BDD be implemented in an agile .NET environment and are there any significant drawbacks to doing it?


title: Traverse a matrix using a linear index to get an evenly distributed values sample

text: I'm looking for an algorithm idea on how to traverse a matrix using a linear index while avoiding row/column based traversals to get a more diverse distribution of values. To understand this better, think of an image that's split in blocks, with `N` rows & `M` columns. I need to process each image block sequentially (from `1` to `NxM`) but I don't know in advance what the processing time will be for each block ( blocks that are close together tend to have a similar processing time, with small variations). During processing, I need to be able to estimate as best as possible the remaining processing time based on the number of blocks that have already been processed & their associated processing time. For this reason, traversing the blocks by columns or by rows will not give an accurate estimation so I need to find another way of traversing the matrix that would pick values from different zones of the image. It's also important to be able to determine the blocks processing order based on a **linear index** (from 1 to NxM), without calculating them in advance. The algorithm that returns the `row` & `column` corresponding to the linear index should be as fast as possible. **Shorter version of the question** For a liner index named `idx`, I need to get a corresponding `row` & `column` pair from a matrix with `N` rows & `M` columns while avoiding a row/column based traversal. For each `idx` between `1` and `NxM`, the algorithm would return a `[row, column]` pair so that all the rows & columns combinations are returned exactly once. **Example** (the values in the matrix represent the linear index's value that's associated with that row&column position) ` 1 17 13 9 5 6 2 18 14 10 11 7 3 19 15 16 12 8 4 20 ` The above example is for a diagonal traversal that would produce a better distribution of values that a row/column based traversal. Another possible solution would be to split the matrix into smaller blocks & traverse those blocks in rows/columns. For example a `4x5` matrix could be virtually split into `2x2` blocks and those smaller blocks could be traversed by rows or columns (e.g. `idx(1) = block1[1, 1]`, `idx(2) = block2[1, 1]`, etc.). The traversal would look something like this: ` 1 13 | 3 15 | 5 7 17 | 9 18 | 11 ------+-------+--- 2 14 | 4 16 | 6 8 19 | 10 20 | 12 ` Any other traversal ideas are welcomed. Ideally, this algorithm would translate to a math formula to calculate the row & column based on the linear index, possibly with a few conditions (`IF` statements) to compensate for missing values, etc.


title: Is there a better way to load objects?

text: I have always kept the code to load an object within the object itself. That way no matter what method is creating the object, it always has access to the method to load the object. However this does mean that if I'm loading a lot of objects I have to create a blank copy of an object to retrieve an array of objects, and it doesn't seem to be the most logical way of loading an array of objects. Take this code as an example, a page is loading a bunch of products.               class Product() {              // product variables...              public function LoadProducts($dbConn, $where) {             $products = array();             $query = "SELECT * FROM products $where";             $results = $dbConn->query($query);             while($row = $results->fetch_assoc()) {                 $products[$row['pId']] = new Product();                 $products[$row['pId']]->StoreVars($row);             }             return $products;         }              public function StoreVars($row) {             foreach($row as $key => $val) {                 $this->$key = $val;             }         }          }               class Page() {              // page variables...              public function DrawPage($dbConn) {             $product = new Product();             $where = "Some where clause";             $products = $product->LoadProducts($dbConn, $where);             // Do something with products to output HTML to the page...         }          }      Most of my objects like `product` follow a similar pattern. Is this good practice? Is there different / a standard way of doing this? Am I doing this correctly? It just seems a bit pointless to me to have to call a blank instance of product to load all the products, but I don't know where else to put that function so I don't have to have many copies of the same query.


title: Proper & Efficient Structure for an entity layer?

text: ## Context Web application based on the .NET Framework written in C# and following the MVC design pattern. ## Question What is the most efficient way to structure an entity layer consisting on various data inputs? ## Background I am developing an application for a client that requires my reading and writing data from various sources and I would like to build a single entity layer/model to abstract the various data sources so that I only need to query the unified model from code. Here is an example of the disparate sources:   * MS SQL Data Warehouse (about 200 tables of enterprise-wide data   * MS Dynamics AX web services   * A new MS SQL database that is specific to the application being developed   * MS Active Directory for authenticating users and for getting user profile and group information.   * In some cases, SharePoint web services. I have used ADO.NET a good bit (.edmx files and so forth) and fundamentally, I know how to do this but I am struggling a bit with a solid, clean approach. Do I create two separate .edmx files for the two SQL DBs and then write object classes for the Active Directory, SharePoint and AX stuff? Do I simply write one big model file? A whole separarate project just to make the abstraction? Many thanks!


title: When should you use Local Classes in Java?

text: I learned about local classes on the Oracle Java Tutorial page. Not nested classes. I don't see myself using local classes. It makes the code look messy and you can easily do what local classes do with having a class declared separately. But maybe I'm missing some use cases for it. Are there situations where you would prefer using local classes over other approaches or are local classes just an antiquated feature no one really uses?


title: How to become a technical architect from a developer

text: I have been programming in .NET for the last 5 years. I have used design patterns a lot in our projects. I do have some domain knowledge in financial jargon. My ultimate goal is to become a technical architect. But the problem is that I am not getting the opportunity to do so in our organization. My question is in such a case how should I develop myself for becoming a successful technical architect? Also I have read somewhere that domain knowledge does matter for becoming a architect. Can some one please clarify this statement?


title: Testing web applications written in java

text: How do you test the web applications (both server side and client side code)? The testing method has to work irrespective of the framework used (struts, spring web mvc) etc. I am using Java for the server side code, Javascript and HTML for the client side code. This is the sample test case of what I am talking about:                1. When you click on a link, the pop up opens.      2. Change some value in the pop up (say a drop down value) and it gets saved          in the DB.      3. Click the popup again, you get the changed values.      Can we simulate this kind of thing using unit test cases? Is JUnit enough for this?


title: How important is a good coding style for the decision to hire a programmer?

text: Even as a student I am asked to review the code of programmers who have (not) passed a test (create a list of Fibonacci numbers on android). While I am very strict on coding style I just read about the "block" style someone used (read the comments!). In my position I would recommend to not hire a guy using this kind of style. The code is completely the opposite of the coding style used in my firm. While searching for coding style and how to deal with a lack of it I am curious about one thing: Should I hire a guy that will have ~~serious trouble~~ adapting the coding style used in the firm? Please: This should _not_ be a discussion about coding style in general and which is better. Its about the importance of coding style for the decision to hire someone! **More information:** I am not the guy that makes the decision, I just give my opinion based on code. The guy has to pass an interview where our head of whatever checks the soft skills. If he passed this, he have to pass our little skill test and thats where sometimes I was asked to review the written code. I am not in the position to say yes or no. I just want to know how important coding style should be for my review...


title: Need ideas for an innovation week

text: So 4 times a year we have an innovation week (to even out the odd sprint releases). This whole week is dedicated to experimenting with new technology/ideas that could potentially help progress the software department or the company as a whole, and serve as sort of a starting point for new ideas and brainstorming. For example, the last one contained a lot of projects. One was the re-design of our web app into more of a Web 2.0 look and feel using JQuery and a lot of cool CSS tricks. Another was a proposal for a new bug tracking software as opposed to the clearly outdated one we use, and another was a very cool JQuery/Js design that could show the same page to multiple users on different computers and allow each of them to take "charge" of the page, disabling the other one from doing anything, and vice versa, seeing all updates in real time -- sort of like Netmeeting through Js. Well, this is my first one as a new employee so I wanted to think of something cool. We get one week (anywhere from 40-60 hours or so), and we usually pair up or do this in groups of 3-4, depending on how many projects there are. Projects have to get approved but usually that doesn't prove to be too difficult. We are in the financial analysis software industry if the domain was leading you guys to think of anything helpful. I am primarily working on a web app in MVC 2 at the moment using a lot of JQuery and a C# backend. Do you guys have any idea of something that would be cool/beneficial/worth it?


title: Long term planning and agile?

text: My team recently went through the process of laying out a nearly one year plan for our work. We separated the plan into three phases. Each phase will include a couple of launches. I wonder, from an agile point of you, is this wrong? I think it's not a bad idea, because we haven't spent too much time on designing anything but the first few steps. It's possible for us to change direction. At the same time it's nice that we don't act with only the near term in sight.


title: New vs Clone Git in Eclipse with EGit

text: I'm not sure I have either my new repo or clone repo workflow, or both, setup correctly. When I create a new project I create a repo on github, can't clone from it as it's empty so I create a new project which goes into my workspace and then the git init runs on the workspace copy. So I end up with everything in workspace\project-name. However, when I clone from github first I need to clone the repo and this goes into my default git directory (C:\git) as git\cloned-project-name, I then need to import this Git repo as a project into my workspace and I end up with workspace\cloned-project-name effectively duplicating the project folder in the git area. I've tried to clone to workspace\cloned-project-name but then it asks to import the git project and if I try to use workspace\cloned-project-name again, it errs. What am I doing wrong? Thanks, Matt.


title: Low Level Software and Devices

text: I'm looking at a new chapter in my career. I'm a web developer, but now I'm starting to play around with C, compilers, and things I didn't have to work with before. It's all very intriguing! As I'm getting more and more into the "lower level" arena, I'm wondering how devices (mice, printers, webcams, microphones, etc...) are controlled, managed, detected, or used in general with software. I ask because I'm really having a hard time finding straightforward documentation online describing or giving examples of how hardware interacts with software. Does someone know of decent sites that can get me started learning this?


title: what is the difference between the below two syntaxes?

text: 1.                $(function () {            function foo() { return true; }            log(bar());                        // getting error            var bar = function() { return true; };          });      2.               $(function () {             function foo() { return true; }             log(bar());                        // working              function bar() { return true; };       });      in above snippets **log** is my custom function to log the result.


title: Is it ok to not fully understand RB Trees?

text: So I just learned red black trees at Cormen and wow! Typically I like to understand all algorithms and data structures to the point I can rebuild them from scratch without having to cheat looking at the pseudo code. I really like algorithms so I enjoy learning how they work and I usually go line by line and try some cases by looking at the code and checking if what's happening is what I understood that should happen. Just understanding what's happening took me A LOT of time for RB trees. Even with the explanations of the book, I still found it hard to grasp the code. Not to mention that I couldn't understand how/why rotations work. I don't find it intuitive at all. I mean, the three (six actually) different cases for insertion and then the 4 cases for deletion? Is it possible to understand this thing? It's impossible for me to rebuild this code without cheating. Until binary tree I could implement the stuff out of my head, with some tweaking it would always work, but RB trees I'm not even going to try. I mean, even the teacher got confused sometimes so I suppose it's really not that easy, but at the same time, shouldn't we have to understand everything that's happening or at least why? The book didn't really explain how someone came up with the idea of rotations. How did someone notice that with 2 rotations you could solve any insertion problem? That's amazing! My question is, do I really have to 100% understand RB trees? I feel kind of bad skipping stuff without fully understanding it. Thanks in advance guys! (PS: there's no tag for RB-tree, actually not even for tree, just binary-tree, so I only put algorithms)


title: What is the order of diagram drawing in a design?

text: I'm new with OOP and UML and I have some confusion here. I'd like to know where to start, I mean, somebody comes to you and ask you to do something (involves software design of course), once you have determined what has to be done, what is the order in which you have to start the software architecture? I mean, is it first the use case diagram or the class diagram? or should I draw some diagrams in parallel? But basically, where should I start? and what UML diagram goes first? Thanks for helping!!


title: How to calculate checksum?

text: I am developing instrument driver and I want to know how to calculate checksum of frame. Explanation: > Expressed by characters [0-9] and [A-F]. > > Characters beginning from the character after [STX] and until [ETB] or [ETX] > (including [ETB] or [ETX]) are added in binary. > > The 2-digit numbers, which represent the least significant 8 bits in > hexadecimal code, are converted to ASCII characters [0-9] and [A-F]. > > The most significant digit is stored in CHK1 and the least significant digit > in CHK2. This is sample frame :               <STX>2Q|1|2^1||||20011001153000<CR><ETX><CHK1><CHK2><CR><LF>      and I want to know what is value of chk1 and chk2 and I am new in this so I am totally blank about how to calculate checksum I am not getting above 3rd and 4th point. Can anyone provide sample code for c#?


title: Choosing between words with different spellings for function names

text: A question has been bothering me for a while: when developing international projects, it is common sense to use English as the reference language since it is the language that the most people understand. However, how can one choose to name a function when it could have different valid English spellings. For example, would one name a function `get_center` or `get_centre`? Are there some rules of thumb to choose, do we choose both or just choose one arbitrarily and try to keep consistency afterwise? **NOTE:** Most answers recommend using American English, which makes sense. However, I had no idea that one of the spellings was American English and the other one was Great-Britain English. Therefore, my example is not a good one. Of course I would have used `center` if I had known that difference. But my question is still valid even though my example is a poor one. **NOTE²:** Concerning `center` vs `centre`, I see that wxWidgets uses both.


title: Easiest way to use objects as filters for queries

text: I'm just starting on a new little pet project of mine. I started the project using a familiar pattern for using objects as "filters" in SQL Queries. I've never been much happy about its easy of use, but eventually more or less accepted it after having it drilled into my head by colleagues. The example below hopefully highlights my concern. Especially in regards of sheer size. However that being said, I also see the strengths of this pattern which may put it in favor of continued use. I'm looking for some opinions if I should continue as I always have or if there indeed is an easier way to do this. Either by using a different pattern or somehow "automate" the process. _Please note that the below is only an example and isn't in use._               public static User getUser(User filter) throws UserControllerException {         String sql, sqlFilter = "";         User user = null;              try {             Connection con = DataSource.getInstance().getConnection();                  if (filter.getCorp() != null) sqlFilter += " AND corp_id = ?";             if (!filter.isNew()) sqlFilter += " AND user_id = ?";             if (filter.getUsername() != null) sqlFilter += " AND username = ?";             if (filter.getPasswordHash() != null) sqlFilter += " AND password_hash = ?";             if (filter.getFirstName() != null) sqlFilter += " AND first_name = ?";             if (filter.getLastName() != null) sqlFilter += " AND last_name = ?";             if (filter.getPhoneNumber() > 0) sqlFilter += " AND phone_number = ?";                  sql = "SELECT * FROM users WHERE 1 = 1 " + sqlFilter;                  PreparedStatement ps = con.prepareStatement(sql);             int psPos = 0;                  if (filter.getCorp() != null) ps.setLong(++psPos, filter.getCorp().getCorpId());;             if (!filter.isNew()) ps.setLong(++psPos, filter.getUserId());             if (filter.getUsername() != null) ps.setString(++psPos, filter.getUsername());             if (filter.getPasswordHash() != null) ps.setString(++psPos, filter.getPasswordHash());             if (filter.getFirstName() != null) ps.setString(++psPos, filter.getFirstName());             if (filter.getLastName() != null) ps.setString(++psPos, filter.getLastName());             if (filter.getPhoneNumber() > 0) ps.setLong(++psPos, filter.getPhoneNumber());                  ResultSet rs = ps.executeQuery();                  if (rs.next()) {                 user = new User(                         rs.getLong("user_id"),                         new Corporation(rs.getLong("corp_id"), null),                         rs.getString("username"),                         rs.getString("password_hash"),                         rs.getString("first_name"),                         rs.getString("last_name"),                         rs.getLong("phone_number")                 );             }              } catch (IOException e) {             throw new UserControllerException(e.getMessage(), e);         } catch (SQLException e) {             throw new UserControllerException(e.getMessage(), e);         }         return user;     }


title: Reducing code complexity for an interface between angular and d3

text: I'm playing around with different ways of integrating d3 and angular, in the context of learning both of these frameworks, and am hoping for some input: My client application receives a JSON array of nodes and an array of edges from my server. The central component of the client is a graph visualization implemented as a d3 force-directed layout: For each node in the nodes array, a (SVG) circle element is added to this visualization, and lines between these circles are added for each edge in the edges array. Of course, d3's `selection.data( )` makes it trivial to add these elements and bind each to the data it represents, but the graph visualization is only part of a much larger application: I need to create different types of elements representing these same nodes and edges in different parts of the application (which d3 has nothing to do with), and I'd like to keep all of these elements bound to a single dataset. My primary goal is minimizing code complexity, and - although I've fallen in love with the simplicity and elegance of d3's data-binding functionality - I've arrived at the tentative conclusion that using it in one part of the application while using Angular to do the same in other parts is creating unnecessary complexity, and that the simplest approach would be to use Angular to handle the data-binding/element-creation In other words, instead of using `selection.data( ).enter( ).append( )` to create SVG elements, I'm thinking I should do so using a `ng-repeat="node in nodes"`, perhaps creating creating each as a custom directive to allow for custom functionality. Having done so, I would then need to get these elements "into" d3, so that they can be laid out on the screen and animated by its force- **Is my reasoning here sound?** In particular, I'm worried that I'm overlooking complications this will create with regard to object constancy, which is an important requirement as nodes will be entering, exiting and moving about the screen constantly and I need these transitions to be smooth. How would you recommend I go about integrating my angular-created elements into d3 (more precisely, getting them into my `force.nodes{ }` and `force.links( )` arrays) to avoid any such complications? Finally, I'm also considering a strategy that I'm hoping might give me the best of both worlds: I could use d3 to create my SVG elements and bind them to their respective datum, but rather than executing that code in the `link` function of visualization directive (as I've been doing, and as all the ng/d3 tutorials I've found do), I could run it in the `compile` function, and do something like this:               d3.select('SVG').selectAll('.node').data('nodeDataArray')         .enter( ).append('circle').attr("class", "node-icon"); //...other attributes/styles etc        where `node-icon` is the normalized name of a directive with a `restrict` property that includes `C`. If this runs in the compile method, angular should then compile all of these directives as normal, adding any additional functionality / interfaces with other directives (etc.), the same way it does with any other type of element . **_Right?_** This is the option I'm most attracted to intuitively - are there any pitfalls of it I might be overlooking, which might make the former strategy preferable? **NOTE:** this question is cross-posted on SO. I know that cross-posting is discouraged in general, but in this case I'm not sure which forum is the most appropriate venue for this question: It does reference concrete implementations, but the core of the question is about general design patterns. Interpreted in the context of SO, I think its a question about implementation. Interpreted in this context, I think its a different question entirely, which is how I've justified cross-posting. Please feel free to comment if you disagree with this justification and I'll consider deleting the question.


title: Checking for the presence of optional properties of an object

text: I'm designing a class that holds several types of data. Some of the properties are optional. For example, let's say I have a class that represents a person, and one of the properties is occupation. I have another property, military rank, but this property is can only be retrieved if the person's occupation is military. What's the best way to handle this?   1. Have `getMilitaryRank()` throw `IllegalStateException` if the occupation isn't military   2. Have `getMilitaryRank()` return an `Optional<Rank>`   3. Return null if the occupation is invalid (I don't like nulls)   4. Something else? Idea 1 works because the user can check the occupation prior to calling this method, making sure they don't call it on an invalid person. Idea 2 seems unnecessary, because you can infer whether the Optional is present by calling `getOccupation()`. However, let's say my Person class has another optional property, but its presence can't be inferred from the value of another property; for example, a middle name. Obviously it's best for `getMiddleName()` to return an empty `Optional` or null if the person has no middle name, as the presence of a middle name can't really be inferred some other way. Since I should probably be consistent in how I'm handling optional properties, it seems like I could do one of the following:   1. Use `Optional` for any property that may be absent, even if it can be inferred from another property.   2. Add methods like `hasMiddleName()` to resolve the discrepancies (this seems like a bad idea)   3. Not be consistent and let the properties whose presence can be determined externally throw an exception, while the ones that are independent be wrapped in an `Optional`.   4. Something else? While nulls could simplify things, it causes a problem if an optional property is an `int`, which can't be nullable in Java. I could use an `Integer`, but that seems like a bad idea. What is the best way to handle these different types of optional properties?


title: License for library developed with commercial program

text: I'm developing a commercial application that largely depends on the functionality of a library that will be developed with it. I'd like to open- source this library, because it offers functionality that is not found elsewhere and can be useful in other applications. However, I will also use it in my own commercial application. I don't want to publish the source of the main application, but it is definitely not a derived work (think of calculator app using GPL licensed library to calculate sine). And if someone else commercially uses the library, I want to require them to publish any changes made. Is the GPL license suitable for this or is LGPL perhaps what I need?


title: Good workflow for software development with scrum and continuous integration

text: I'm studying an approach to understand better how the continuous integration workflow fits better in a software development company with the scrum method. I'm thinking something like this: ![enter image description here](http://i.stack.imgur.com/vBqTq.jpg) Would that be a nice workflow?


title: Should I still make my site work in non-javascript capable browsers?

text: Apparently less than 1% had javascript off in 2010: http://developer.yahoo.com/blogs/ydn/posts/2010/10/how-many-users-have- javascript-disabled/ So is it worth it to still support browsing without javascript? For example: **Form submissions.** Normally I would set up click or change events on form elements and just update the current page HTML from the response. But if the user has js disabled, the form cannot be submitted, and it won't work. If I have to take into consideration that the user has JS off, then I need to wrap my input elements within `<FORM>`, add a submit button and add additional mark-up on the current page to handle the form submission results... Anyway there's a lot of extra work to do in this case. Another example - replacing generic form elements with DIVS that you style to look like cooler input elements, and make them behave like generic inputs trough JS. Again, users without js won't be able to do anything with them. Or a different example, the UI created by JS on page load. Besides the fact that non-js browser won't display the UI, there's also a small problem with JS-capable browsers which will show a ugly UI until the page is full loaded and the JS gets to be executed. Are these drawbacks important enough to take into consideration, when less than 1% of your visitors are affected by them?


title: Programmer performance : based on location, timings

text: Do programmers perform better when working from office or from a location of their choice? Also do they work better with fixed timings compared to flexible hours?


title: Does Quebec require all output, including internal logs, to be in French?

text: I've once heard a Microsoft architect say that, in Quebec, program output must be in French, including the custom log output that would be used by service technicians in other countries who don't speak French or are Quebecois. Apparently, it's in Bill 101 Article 5. If you read the document _correctly_ (thanks Matthieu), Article 5 says > **5\. Consumers of goods and services have a right to be informed and served > in French.** 1977, c. 5, s. 5. Is what the Microsoft technician saying correct? Does this affect all output from a program, or just the output intended for a French-speaking audience (e.g., the logs in this case wouldn't apply)? Is it only intended for government agencies (including contract work done for them), or does it affect private use and sale, as well?


title: Python dynamic attributes creation, a blessing or a curse?

text: Consider this code:               >>> class Foo():             pass     ...     >>> foo = Foo()     >>> foo.a = 'test'     >>> foo.a     'test'      One can just override `__setattr__` to make attributes read only and prevent their creation at runtime, however:   * Why is this the _default_ Python behavior (any good reasons)?   * Is there any practice to prevent this without altering each class?   * Would you worry about this behavior in serious projects? don't you consider it error prone? or you can just ignore it (relying on new IDEs code completion)


title: Teaching computer programming?

text: I've kicked around the idea of teaching computer programming formally(at a college-level). What kind of degree would be required at most colleges for teaching and also any general advice for if someone would be a good fit for such a field?


title: Can a compiled C++11 library (lib,dll,etc.) be linked in older C++ compilers?

text: Could older C++ compilers (e.g. VS2008 and gcc3.4) link with external libraries written in C++11? My thought is that the C++11 .lib files are just byte code at this stage, and it shouldn't bother the older compilers how it was generated, as long as it is somehow resolvable and callable. I'm developing a small library whose API should still support C++03 users. So, looking forward, I'm wondering whether it's ok to implement my library using helpful features like `std::unique_ptr` and such, or do I have to just stick with `boost::`?


title: Is there an (open-source) ReST-based blogging/forum package out there?

text: The site I work on is almost entirely in Javascript, it just goes back (via Ajax) to the server for authentication, database access, things like that. My boss would like me to add blogging, forum, and commenting capabilities. I don't want to implement it from scratch and I certainly don't want to integrate some HTML-generating PHP atrocity. Ideal, I'm looking for a package that does all the backend work and offers ReST interface so I can write a Javascript-based UI that integrates nicely with the existing site. Does such a thing exist?


title: How much more should I charge for freelance project source code?

text: Currently I'm working as a freelancer, and for the first time a faced a client who wants the source code too. This client owns a software development company, and wants to have rights over the source code, but that I keep my rights too. That means that they can use my code to make similar applications using my code for different customers and the same applies for me. How much more should I charge my client?


title: Who should initialize dependencies in a TDD application?

text: I'm trying to learn implementing TDD with mocking/fake objects. One of the questions I have is how to initialize a dependency in an application which implements TDD? An example from this article  Beginning Mocking With Moq 3 shows:               public class OrderWriter     {         private readonly IFileWriter fileWriter;              public OrderWriter(IFileWriter fileWriter)         {             this.fileWriter = fileWriter;         }              public void WriteOrder(Order order)         {             fileWriter.WriteLine(String.Format("{0},{1}", order.OrderId, order.OrderTotal));         }     }      In this example, the constructor takes an `IFileWriter` parameter, I suppose because you want to supply the real file writer in case of the actual application, and the fake one for unit test. My question is, in the real application, who will supply this parameter? I suppose it will be the caller of this application. What if it has dependency as well in the constructor? Will the caller code be responsible for that too? Maybe the better way is to use factory. How would this factory work? And how will the factory be distributed? Will it be in the constructor parameter like in the above manner?


title: Visual Studio Setup - why is solution explorer on the right?

text: Every time I install VS (whichever version going back years) it installs with the Solution Explorer on the right. Now as most UIs have the navigation in a left hand column (and at the top of the viewport) and the content to the right of this navigation this always seems wrong to me. So I drag the solution explorer to the left of the screen and dock it there. But I've never seen another developer do this. Considering how most programmers usually like to customize their environment, adding their favourite text editor, browser, plug-ins, greasemonkey scripts etc **why do Visual Studio developers never seem to make this simple UI change?** Does anyone else do this or am I just screaming in the dark?


title: Should i shift from Testing to Development?

text: i have 1.2 yrs of experience in Testing in big MNC company, I have good Programming knowledge in Java (Core,Servlets). I have completed ISTQB certification(Testing) and trying for HP QTP certification. I am not at all satisfied with the manual testing. Can i shift from testing to development? if yes which development should i shift Java or Ruby on Rails ?(i dont have any idea about web development but my friends are suggesting Ruby On Rails) ? What are all the skills should i develop to move in to development? what will be the right time to shift? if ROR can i get good job opportunitites? Please suggest me .


title: At what point would you drop some of your principles of software development for the sake of more money?

text: I'd like to throw this question out there to interestingly see where the medium is. I'm going to admit that in my last 12 months, I picked up TDD and a lot of the Agile values in software development. I was so overwhelmed with how much better my development of software became that I would never drop them out of principle. Until...I was offered a contracting role that doubled my take home pay for the year. The company I joined didn't follow any specific methodology, the team hadn't heard of anything like code smells, SOLID, etc., and I certainly wasn't going to get away with spending time doing TDD if the team had never even seen unit testing in practice. Am I a sell out? No, not completely... Code will always been written "cleanly" (as per Uncle Bob's teachings) and the principles of SOLID will always be applied to the code that I write as they are needed. Testing was dropped for me though, the company couldn't afford to have such a unknown handed to the team who quite frankly, even I did create test frameworks, they would never use/maintain the test framework correctly. Using that as an example, what point would you say a developer should never drop his craftsmanship principles for the sake of money/other benefits to them personally? I understand that this can be a very personal opinion on how concerned one is to their own needs, business needs, and the sake of craftsmanship etc. But one can consider that for example testing can be dropped if the company decided they would rather have a test team, than rather understand unit testing in programming, would that be something you could forgive yourself for like I did? So given that there is something you would drop, there usually should be an equal cost in the business that makes up for what you drop - hopefully, unless of course you are pretty much out for lining your own pockets and not community/social collaborating ;). Double your money, go back to RAD? Or walk on, and look for someone doing Agile, and never look back...


title: How/where to run the algorithm on large dataset?

text: I would like to run the PageRank algorithm on graph with 4 000 000 nodes and around 45 000 000 edges. Currently I use neo4j graph databse and classic relational database (postgres) and for software projects I mostly use C# and Java. Does anyone know what would be the best way to perform a PageRank computation on such graph? Is there any way to modify the PageRank algorithm in order to run it at home computer or server (48GB RAM) or is there any useful cloud service to push the data along the algorithm and retrieve the results? At this stage the project is at the research stage so in case of using cloud service if possible, would like to use such provider that doesn't require much administration and service setup, but instead focus just on running the algorith once and get the results without much overhead administration work.


title: Should I use events in this case?

text: I'm creating a video player, like a custom YouTube player. All of the GUI elements (progress bar, video player, play button, ...) are different classes, but I obviously need them to communicate. When the progress bar is clicked, or the slider is moved, it needs to send a "seek(x)" command to the video player. Similarly, the video player needs to update the progressbar every frame. Currently I'm doing this by having almost all elements have a link to each other. So when I create the progress bar, I'm telling it where the video player is. But after a while this becomes more and more complicated, and I'm wondering if events would be a better way to do this. Or a main controller class that has all the connections. What should I do?


title: What hardware do newly hired programmers get at various companies?

text: Looking at various pictures/office tours of software companies (Facebook for instance), I see a lot of the same hardware in terms of monitors (Dell monitors). I was wondering when companies hire new programmers, is the programmer given a choice between say a large monitor + laptop, a desktop + 24"(2?) monitor, or some other combination? PS. If you know for sure, it would be helpful to list the options at various companies.. e.g. Microsoft, Apple, Google; unless the information is confidential.


title: UML Actions with object and control flows

text: Consider a UML Action contained in a UML Activity defining the behavior of a classifier. Such Action has three input pins connected to other output pins of different action by means of object flow edges. It also has an incoming control flow. My question is: does the action start when all the tokens _ those coming from all the input pins and that coming from the control flow _ are available? What if I have more than one control flows?


title: Is it common to purchase an insurance policy for contract development work?

text: I am not sure if this is the best place for the question, but I am not sure where else to ask. ## Background I am a contract developer and have just been asked to provide a general liability policy for my next gig. In 6-7 years this has never been asked of me. ## Question Is this common? If so, can anyone recommend a good underwriter that focuses on what we do as contract software developers? I realize that Google could help me find underwriters but it won't give me unbiased public opinion about which companies actually understand what we do and factor that into the price of the policy.


title: Does auto make C++ code harder to understand?

text: I saw a conference by Herb Sutter where he encourages every C++ programmer to use `auto`. I had to read C# code some time ago where `var` was extensively used and the code was very hard to understand—every time `var` was used I had to check the return type of the right side. Sometimes more than once, because I forgot the type of the variable after a while! I know the compiler knows the type and I don’t have to write it, but it is widely accepted that we should write code for programmers, not for compilers. I also know that is more easy to write:               auto x = GetX();      Than:               someWeirdTemplate<someOtherVeryLongNameType, ...>::someOtherLongType x = GetX();      But this is written only once and the `GetX()` return type is checked many times to understand what type `x` has. This made me wonder—does `auto` make C++ code harder to understand?


title: Combine auto-syncing cloud and VCS

text: This question brought me to another question: **is there any VCS/tool for a VCS which automatically backups your source code between the last checkout and current changes**? I had the problem of loosing uncommited source code changes just one week ago.   I did not want to commit yet because the changes were incomplete. But then, an error when moving the data to an USB stick caused the data loss. That's the opposite what a cloud service (like Google Drive, SkyDrive, DropBox, ...) does: it tracks **each** change you made!   Have you lost your data? That's no problem because you have the latest version online. So what would a combined solution look like?   It would offer full functionality of a VCS including auto-syncing of any **intermediate changes** between two commits/checkouts to a temporary online location.


title: My manager hates documentation in our large project.  What should I do?

text: I am working in a small team on a large complex software project. I want to document all requirements, but I've been told by my manager that it is waste of time. I have tried the same with design and functionality, and I encountered the same discouragement. I am responsible for anything that goes wrong, and obviously, I don't remember everything. Still, I've been told not to create documentation. How should I approach this problem?


title: String class based on graphemes?

text: I'm wondering why we don't have some string classes that represent a string of Unicode grapheme clusters instead of code points or characters. It seems to me that in most applications it would be easier for programmers to access components of a grapheme when necessary than to have to organize them from code points, which appears necessary even if only to avoid casually breaking a string in "mid-grapheme" (at least in theory). Internally a string class might use a variable length encoding such as UTF-8, UTF-16, or in this context even UTF-32 is variable length; or implement subclasses for all of them (and optionally configure the choice at run-time so that different languages could use their optimal encodings). But if programmers could "see" grapheme units when inspecting a string, wouldn't string handling code in general be closer to achieving correctness, and without much extra complexity?


title: Is this how dynamic language copes with dynamic requirement?

text: The question is in the title. I want to have my thinking verified by experienced people. You can add more or disregard my opinion, but give me a reason. Here is an example requirement: Suppose you are required to implement a fighting game. Initially, the game only includes fighters, who can attack each other. Each fighter can punch, kick or block incoming attacks. Fighters can have various fighting styles: Karate, Judo, Kung Fu... That's it for the simple universe of the game. In an OO like Java, it can be implemented similar to this way:               abstract class Fighter {         int hp, attack;              void punch(Fighter otherFighter);         void kick(Fighter otherFighter);         void block(Figther otherFighter);      };          class KarateFighter extends Fighter { //...implementation...};     class JudoFighter extends Fighter { //...implementation... };     class KungFuFighter extends Fighter { //...implementation ... };      This is fine if the game stays like this forever. But, somehow the game designers decide to change the theme of the game: instead of a simple fighting game, the game evolves to become a RPG, in which characters can not only fight but perform other activities, i.e. the character can be a priest, an accountant, a scientist etc... At this point, to make it more generic, we have to change the structure of our original design: `Fighter` is not used to refer to a person anymore; it refers to a profession. The specialized classes of Fighter (KaraterFighter, JudoFighter, KungFuFighter) . Now we have to create a generic class named `Person`. However, to adapt this change, I have to change the method signatures of the original operations:               class Person {         int hp, attack;         List<Profession> skillSet;     };          abstract class Profession {};          class Fighter extends Profession {                  void punch(Person otherFighter);         void kick(Person otherFighter);         void block(Person otherFighter);      };          class KarateFighter extends Fighter { //...implementation...};     class JudoFighter extends Fighter { //...implementation... };     class KungFuFighter extends Fighter { //...implementation ... };          class Accountant extends Profession {          void calculateTax(Person p) { //...implementation...};          void calculateTax(Company c) { //...implementation...};     };     //... more professions...      Here are the problems:   1. To adapt to the method changes, I have to fix the places where the changed methods are called (refactoring).   2. Every time a new requirement is introduced, the current structural design has to be broken to adapt the changes. This leads to the first problem.   3. Rigid structure makes it hard for code reuse. A function can only accept the predefined types, but it cannot accept future unknown types. A written function is bound to its current universe and has no way to accommodate to the new types, without modifications or rewrite from scratch. I see Java has a lot of deprecated methods. OO is an extreme case because it has inheritance to add up the complexity, but in general for statically typed language, types are very strict. In contrast, a dynamic language can handle the above case as follow:               ;;fighter1 punch fighter2     (defun perform-punch (fighter1 fighter2) ...implementation... )          ;;fighter1 kick fighter2     (defun perform-kick (fighter1 fighter2) ...implementation... )          ;;fighter1 blocks attacks from fighter2     (defun perform-block (fighter1 fighter2) ...implementation... )      `fighter1` and `fighter2` can be anything as long as it has the required data for calculation; or methods (duck typing). You don't have to change from the type `Fighter` to `Person`. In the case of Lisp, because Lisp only has a single data structure: list, it's even easier to adapt to changes. However, other dynamic languages can have similar behaviors as well. I work primarily with static languages (mainly C and Java, but working with Java was a long time ago). I started learning Lisp and some other dynamic languages this year. I can see how it helps improving my productivity.


title: Better to inject IoC container or use a Service Locator pattern?

text: I have an IoC container (If you want a specific one to look at, it's very similar to Unity) and I'm working on how I want to integrate it into my application. My overall goal for this exercise is to transform this horrendous code I wrote into something much more testable. I can create the IoC container and register types and I understand the fundamentals of how it is supposed to accomplish it's goal. My question is should I be injecting the container down into objects that need it, or should the objects that need it look it up using a Service Locator pattern? Realistically I see myself having to reference the container in two or three layers of my application.


title: Python/Database Website development

text: I want to create my own website that would allow me to acess a database in the server and do inserts and lookups in a user friendly way. I am a seasoned user of linux and C/C++, and also have experience with Python and sqlite3, but i don't have any experience in Web development, so i have no idea where to start. I have researched online and the best i came up with was an Apache/Nginx server together with an fcig or wscgi and Django, so that i would have database and python integration through a Django App. Can someone tell me if this is the way to go or if there is some easier (or better) way to accomplish what i want?


title: share code between check and process methods

text: My job is to refactor an old library for GIS vector data processing. The main class encapsulates a collection of building outlines, and offers different methods for checking data consistency. Those checking functions have an optional parameter that allows to perform some process. For instance:               std::vector<Point> checkIntersections(int process_mode = 0);      This method tests if some building outlines are intersecting, and return the intersection points. But if you pass a non null argument, the method will modify the outlines to remove the intersection. I think it's pretty bad (at call site, a reader not familiar with the code base will assume that a method called `checkSomething` only performs a check and doesn't modifiy data) and I want to change this. I also want to avoid code duplication as check and process methods are mostly similar. So I was thinking to something like this:               // a private worker     std::vector<Point> workerIntersections(int process_mode = 0)     {         // it's the equivalent of the current checkIntersections, it may perform         // a process depending on process_mode     }               // public interfaces for check and process     std::vector<Point> checkIntersections()  /* const */     {         workerIntersections(0);     }               std::vector<Point> processIntersections(int process_mode /*I have different process modes*/)     {         workerIntersections(process_mode);     }      But that forces me to break const correctness as workerIntersections is a non- const method. How can I separate check and process, avoiding code duplication and keeping const-correctness?


title: "Agile Principles, Patterns, and Practices in C#": Is this just a .NET-translation of the popular Uncle Bob book?

text: I found this book sold on Amazon Agile Principles, Patterns, and Practices in C#, written by Robert C Martin and Micah Martin. Is it merely a .NET port of the older, more popular Agile Software Development, Principles, Patterns, and Practices? Or is it just a new book trying to take advantage of the other book's popularity? If I am a .NET developer who hasn't read either book, which one would you recommend?


title: How to 'convert' a Static Access style project to IoC/DI style?

text: Are there any best approaches for refactoring a programming project that has previously been written with the static reference anti-pattern (the majority of classes refer at some point to a static bean, where all of it's variables are public. Half-way through a class, for instance you'll see something like: `EvilClass.Variable = returnsABoolean()`. Then in a different class, you'll see something like:               if(EvilClass.Variable == foo){         doSomething();     }else{         doSomethingDifferent();     }      Up until recently, I've been working with this pattern as I don't want to mix the styles and get things confused between the styles. But I want to slowly but surely 'fix' this project. I'm the only dev on this, and I don't have the time to just sit down and refactor it (otherwise, I'd push for a full rewrite!). Are there any best practices to be aware of when working with/fixing this kind of project/problem?


title: Evaluation order of expressions in Clojure?

text: I'm currently learning Clojure (my first functional programming language), and I'm curious as to its order of evaluation. Here is an example: `(take 10 (cycle [1 2 3]))` If the `cycle` expression was not wrapped in a `take` expression, this would cause a memory error, as it would iterate infinitely through the vector. So, how does Clojure _know_ that it has been wrapped with a `take` expression? (If I'm using any incorrect terminology here, I'd appreciate a nudge too!)


title: Choosing a process modeling notation

text: It is questionable whether this question really belongs here, but, in any case, it does not fit in Stack Overflow or any other Stack Exchange site. So here I go. ## The purpose My current pet project consists in developing a software tool to generate code from business process specifications. The program's inputs are...   * Process diagrams (very detailed ones, of course!)   * User interfaces, if necessary, for those activities to be automated   * Identification of interfaces with third-party programs, either already existing or to be constructed later And the program's outputs are...   * Table, view and stored procedure creation scripts   * Application code (CRUD, information flow between processes/activities/users, etc.) ## The problem Well, I still do not know which process modeling _notation_ I should use. ## The alternatives Personally, I like EPC (event-process chain) diagrams very much because of the simplicity of their structure:   * The process flow must start with an event and must end with an event. If there are several alternative branches, this rule applies to all branches and possible flows.   * Events may trigger zero or more activities. If they trigger zero activities, they are final events. If they trigger two or more activities, a branch opening must be used.   * When completed, an activity must trigger exactly one event.   * Activities may be triggered by one or more events. If they are triggered by two or more events, a branch closing must be used.   * Everything else (i.e., anything that is not an event or an activity; e.g. personnel, resources, physical materials, information) can be added after completing the description of the process flow. However, at least judging from other software developers I know, EPC diagrams are unpopular. Everyone else seems to be using BPMN, which are of course excellent for describing functional / responsibility aspects (i.e., who performs each activity), but are horrible for everything else, because the lanes get in the way. ## The constraints Other notations I know but have explicitly rejected are...   * **UML sequence diagrams:** Because a diagram must be created for each alternative flow, the cost of which would be prohibitive for users of my tool.   * **IDEF:** IDEF0 is great for mapping information flows, but IDEF3 is a horrible process flow notation: gotos should not be allowed at this level. ## The questions Which process notations have you used? Which one would you recommend me for my project?


title: The cost of running a Windows App Server

text: I want to know what is the cost of running a Windows Application Server. I know the cost of running a Linux server with Java based Application Server is probably zero. What is the cost of running a windows based server on which all Apps are written in C#? I assume is is just the license cost of a copy of Windows Server. Is this true? Are there any other hidden cost for hosting with WIndows? I think with Cloud based hosting, these license costs can be avoided then.


title: How to design RESTful Web Api to represent Resources

text: I'm developing an ASP.NET Web Api 2 RESTful web api with .NET Framework 4.5.1 and C# and I'm trying to understand how to expose resources through a Web Api: Imagine that I'm a group owner and I am the only one that can add new users to that group (I'm trying to simulate a WhatsApp group). This is my C# class for user:               public class User     {         public int UserId { get; set; }         public string UserName { get; set; }              public List<Group> Groups { get; set; }         public List<Group> GroupsOwned { get; set; }     }      And Group class:               public class Group     {         public int GroupId { get; set; }         public string GroupName { get; set; }              public User Owner { get; set; }              public List<User> Members { get; set; }     }      How do I have to expose user's groups owned members in a RESTful Web Api? I think I have to expose it this way:               "api/users/{ownerId}/groupsOwned/{groupId}/members/"      I will allow `PUT` to modify the Group to add a new member, and probably `GET` to get all members. Any advice?


title: How to learn about graph algorithms and some real world applications?

text: I've read Franco Moretti's work, but I'm looking for something more technical and perhaps broad in scope, if possible. Specifically, I want to learn about techniques programmers are using to glean information from complex networks, eg clustering. I'd also like to know what are some interesting questions/problems when it comes to graphs. So far I've just skimmed academic papers with very specific applications. I would appreciate any advice. Thanks!


title: Select data from a table that is not in another table

text: I've two tables and I want to select only the rows of the first table which it's 'id' field is not in a second table. I'm completely new to SQL. Any hint? For example, suppose I have a table of users with the following fields: id, password, location, description, among other fields. I have another table that holds the banned users, with two fields, id_user and id_blocked. My guess is SELECT u.id, u.pasword, u.location, u.description FROM `table_users` u WHERE NOT EXISTS (SELECT bl.id_blocked FROM `table_block` bl WHERE u.id = bl.id_blocked) is that correct?


title: Practical way to store a "reasonably large" amount of data that hardly ever changes?

text: Think in terms of pre-computed lookup tables or something. At what point does it make more sense to use a database instead of hardcoding values in my application? The values are not going to change, and they're nicely segregated away from maintenance developers. 100 values, 1k, 10k, 100k? I'm wanting to store about 40k values. Right now it's a machine-generated `switch` statement (which VS2010 is unhappy about). edit: If anyone is curious, here's how I approached this: My data was storable in two 100k-element float arrays, so that's what I did. It took about 20 seconds to generate the data, so I did that once, and serialized it to an embedded resource with a BinaryFormatter. Unpacking the data takes about 5 milliseconds at application startup, and outperforms the database implementation I was replacing (these hard-coded values were stored there prior) by almost 45,000x.


title: Using T[1] instead of T for functions overloaded for T(&)[N]

text: The asio::buffer function has `(void*, size_t)` and `(PodType(&)[N])` overloads.   I didn't want to write ugly C-style `(&x, sizeof(x))` code, so I wrote this:               SomePacket packet[1]; // SomePacket is POD     read(socket, asio::buffer(packet));     foo = packet->foo;      But that `packet->` looks kinda weird - the `packet` is an array after all.   (And `packet[0].` doesn't look better.) Now, I think if it was a good idea to write such code. Maybe I should stick to unsafe C-style code with `void*` and `sizeof`? * * * **Upd:** here is another example, for writing a packet:               SomePacket packet[1]; // SomePacket is POD     packet->id = SomePacket::ID;     packet->foo = foo;     write(socket, asio::buffer(packet));


title: Develop web site from existing software or cherry pick and use a web framework?

text: A small team and I are tasked with developing a web site. The client has referenced a particular open source project (we'll call it X) when describing some of the features. Because of this, the team wants to start with X and adapt it to satisfy the client. I have looked at X and its code and, in my opinion, it would be unwise. However, my experience is limited, and could really benefit from the insights of others so that I can figure out what I should be asserting as the right direction for the team. My red flags are going up and this is why. X was developed in the earlier days of PHP; 500 line blocks of code are the norm; global variables are abundant; giant switch cases are the norm for switching between which page is shown. There is no clear mapping between URL and where the code for that page sits. From a feature-set standpoint, X is actually software specialized for a different task and has dozens of features we don't need or have use for that come as core assumptions. We will be unable to adapt X through its plugin system. That said, there are a few features which can be mapped, with some modification, to suit our purposes. I believe this is the attraction the team feels. I would feel comfortable if, instead of using X directly, we lifted what is salvageable and useful to us. We can then use that code, and the same 3rd party libraries X is using, in a new code base built on top of a PHP web framework (particularly Agavi, so you understand what I mean by 'web framework'). The web framework gives us a strong MVC structure and provides the common facilities for web development, or adapters to work with 3rd party libraries that do so. We will also have a clean slate feature-wise to work from, which means we can work additively instead of subtractively. Because the code base is better structured, and contains none of what we don't need, it will be easier to document, which is a critical requirement of our client. So to summarize, the team wants to use X, whereas I want to take the bits we can from X and use a web framework instead. I want to bounce this opinion off of other's experiences so that I can be more informed.


title: Are there any non-blocking web servers for Java?

text: I was studying about the infrastructure being used by Facebook, as I was developing a website based on social interaction for a university project. Facebook is using Tornado Web Server as its scalable, non-blocking web server, but it's written for Python. I'm trying to find something similar for Java: what should I be looking at? What are your experiences in non-blocking web servers for Java?


title: How to track dependencies when a reported bug affects multiple products containing shared components?

text: If you have multiple products that contain some shared components, how do you track dependencies to work out which other products a bug affects? For example, product A, B and C use a CRC library module. A bug is found and filed in the module in product A. How can we assess that B and C are affected and need a bug fix release. Of course we already have version control and issue tracking software, but it's not clear whether or how they can help in doing this, or whether we need to look for better tools. Practically, is it worth modeling a subsystem breakdown to detect that an issue/defect affects also other products?


title: How to fail an interview?

text: Imagine a situation where several people are sent to an interview and only one has to pass. His knowledge is enough for the project. However, the customer asked for the several candidates so he can choose the best one. And the other people from your company are already engaged in other projects and should not get the job. The question is: How to show that the other candidates are worse and at the same time not make them look stupid? **UPD** I've got the point but I need to clarify the primary idea. **I wanted to know how another candidate [that should not pass the interview] has to behave at it?** I've left the modified question [1st one] because several answers correspond to it.


title: Select design pattern - user stage

text: I'm struggling to point a finger into the right design pattern. I have a web site which user can register and interact with the system. I want to add the following abilities to a user:   1. Each user will be in a stage. Let's say that we have 5 stages. when user is register, he will be in the 1-st stage.   2. User will be able to climb to the next stage. To do so, he will need to complete X tasks. (There will be 20 tasks in the system).   3. In each stage, the user will be able to buy benefits with the points that he gain in each task that he completed.  What's the appropriate design pattern to use here? Thanks.


title: What's your advice for getting Oracle Certified Professional Java Programmer certificate?

text: I intend to get the certification but am not completely sure how to effectively prepare myself. So I'm wondering if you have any advice on the matter; in particular I would like to know:   * What should the basic learning/practicing plan look like?   * Which book (set of books) should be considered?   * Which practical exercises should be performed? **NOTE:** I've got several years of corporate experience (mostly web apps, though), but I want to be 100% sure I'll pass the test (that's the reason the issue is raised).


title: Should a software company have a dedicated team for research and/or utility libraries?

text: I work in a company that does web applications for various banks and some smaller e-shops We employ about 20 developers and have 4-5 projects in development at any one time. Our development teams don't interact much and a lot of the same problems are done in varied ways(good to bad). I was wondering if it would be a good idea for a company to have a team of programmers that do research on current frameworks and continually improve a common library of functions and a common framework to build current and future projects much faster and more efficiently. How large should a team like this be? Also should it have permanent members that train others or should it rotate people? **Update:** I was thinking about a common project that people can work on for fun that might spark some interest. It seems that when people have job pressures the solutions they come up with are not the best.


title: Why is a private member accessible in a static method?

text: The following is pseudo code, I tried it in Java and PHP and both worked:               class Test {               private int a = 5;              public static function do_test(){             var t = new Test();             t.a = 1;             print t.a // 1         }          }          Test::do_test();      Why can you do this in OOP paradigm and what's the use of it?


title: What does " (int) value & 0x1, (int) value & 0x2, (int) value & 0x4, (int) value & 0x8 means"

text: > ![code](http://i.stack.imgur.com/KSwRO.jpg) The "value" ranges from 0 to 15 (it's possible values). When will those 4 "if"condition be met? If my (int)value = 2 does this mean 0010?                           if  ((int)value & 0x1)                  {                     //statement here                 }                 if  ((int)value & 0x2)                  {                     //statement here                 }                 if  ((int)value & 0x4)                  {                     //statement here                 }                 if  ((int)value & 0x8)                  {                     //statement here                 }


title: Consistent header HTML across multiple sites

text: We've got several sites. Some are HTML/Angular, some are built on a CMS, some are built on other code. What we'd like to do is have a consistent header experience for each site. I'm trying to figure out the best way to do this. I've got a couple of options -   1. Have it served on one site - then put it in an iFrame on each of the sites.      * Advantages here are that we only need to deploy to one place, it'll be always consistent     * Downsides I can see are that it may not work that well when we have to resize the header responsively, and that I'm not sure if using iframes are considered bad practice now. Also I'm not sure how the links would work with angular routing.   2. Have the HTML/CSS stored in my source control, then have each application pull it in.     * Advantage/Disadvantage - headers aren't automatically updated across all sites. They have to be deployed individually.     * Disadvantage - Possible CSS conflicts since its written in isolation?     * Advantage - Pretty simple solution   3. Some other way?


title: Uniqueness of for loop

text: How does the for loop function is implemented so that it can accept `;` as parameter separator rather than `,` which is trivial in normal functions.


title: How do I add link-time optimization capabilities to my LLVM-based compiler?

text: I am designing and implementing a programming language, and I am using LLVM for native code generation. Among others, performance is a key feature of the language, and as such, I am looking to implementing link-time optimization. On the official LLVM site, I've read that > LLVM features powerful intermodular optimizations which can be used at link > time. However, the page in question does not mention how a user can request link- time optimization. In particular, it only explains the theory (and some big- picture decisions of implementation) of LTO, but it does not reference any API documentation nor a tutorial. I have performed a quick search on Clang's code base, but the results aren't too informative or relevant either – I haven't even found what settings the `-flto` switch turns on in Clang, let alone the changes in code generation that make it possible for the linker to optimize across object files. Now, I suppose doing LTO should go along the lines of:   1. Generating some sort of metadata in the object/bitcode file so that the linker knows it can employ LTO. Maybe this needs to contain concrete information about the module, the functions to be optimized, etc. (I really have no idea what exactly should go in there...)   2. Then adjusting my code generation procedure (i. e. the way I am using the LLVM API) in a manner that it "supports" LTO. After some researching on the internet, I've found this related LLVM source file, so I assume it's possible to automatize at least part of this task, but – as always – the autogen'd LLVM documentation is scarce at best. So, my question is: is my description of the process of incorporating the LTO features of LLVM in my compiler correct, and if so, can you suggest me any sort of documentation or tutorial which I could base my project on?


title: Single python file distribution: module or package?

text: Suppose I have a useful python function or class (or whatever) called `useful_thing` which exists in a single file. There are essentialy two ways to organize the source tree. The first way uses a single module:               - setup.py     - README.rst     - ...etc...     - foo.py      where `useful_thing` is defined in `foo.py`. The second strategy is to make a package:               - setup.py     - README.rst     - ...etc...     - foo     |-module.py     |-__init__.py      where `useful_thing` is defined in `module.py`. In the package case `__init__.py` would look like this               from foo.module import useful_thing      so that in both cases you can do `from foo import useful_thing`. **Question:** Which way is preferred, and why? EDIT: Since user gnat says this question is poorly formed, I'll add that the official python packaging tutorial does not seem to comment on which of the methods described above is the preferred one. I am explicitly _not_ giving my personal list of pros and cons because I'm interested in whether there is a community preferred method, not generating a discussion of pros/cons :)


title: How achieve a page-change proof player?

text: I am interested in develloping a web music player similar to the soundcloud one However, I can't figure out one thing: How player like soundclou one (and some other one) can "resist" a page change, continue playing without any latency, even if the page in the background is loading, the player is here and continue his job without any lag at the momment we click links. The only way to stop it is to reload the page with the browser How can this be achieved? Does this used using a particular language and site architecture that center the player? If not, does any language / framework offers possibility to do thing like that? EDIT: So I made a Few search, and I get the following Idea:   * Pjax : That allow you to reload only certain content.   * HTML5 History API : The API Behind PJax   * One-page APP : Much harder. But using Ajax it could work. Are these solution good? Wich one would be easier/ Better? Are there other alternative?