Are fluent interfaces more flexible than attributes and why?

In a EF 4.1 Code First tutorial the following code is given:               public class Department     {         public int DepartmentId { get; set; }         [Required]         public string Name { get; set; }         public virtual ICollection<Collaborator> Collaborators { get; set; }     }      Then it is explained that the fluent interface is more flexible: > Data Annotations are definitely easy to use but it is preferable to use a > programmatic approach that provides much more flexibility. The example of using the fluent interface is then given:               protected override void OnModelCreating(ModelBuilder modelBuilder)     {         modelBuilder.Entity<Department>().Property(dp => dp.Name).IsRequired();         modelBuilder.Entity<Manager>().HasKey(ma => ma.ManagerCode);         modelBuilder.Entity<Manager>().Property(ma => ma.Name)             .IsConcurrencyToken(true)             .IsVariableLength()             .HasMaxLength(20);     }      I can't understand why the fluent interface is supposedly better. Is it really? From my perspective it looks like the data annotations are more clear, and have more of a clean semantic feel to it. My question is why would a fluent interface be a better option than using attributes, especially in this case? (Note: I'm quite new to the whole concept of fluent interfaces, so please expect no prior knowledge on this.) Reference: http://codefirst.codeplex.com/


What term is used to describe running frequent batch jobs to emulate near real time

Suppose users of application A want to see the data updated by application B as frequently as possible. Unfortunately app A or app B cannot use message queues, and they cannot share a database. So app B writes a file, and a batch job periodically checks to see if the file is there, and if load loads it into app A. Is there a name for this concept? A very explicit and geeky description: "running very frequent batch jobs in a tight loop to emulate near real time". This concept is similar to "polling". However polling has the connotation of being very frequent, multiple times per second, whereas the most often you would run a batch job would be every few minutes. A related question -- what is the tightest loop that is reasonable. Is it 1 minute of 5 minutes or ...? Recall that the batch jobs are started by a batch job scheduler (e.g. Autosys, Control M, CA ESP, Spring Batch etc.) and so running a job too frequently would causes overhead and clutter.


Designing configuration for subobjects

I have the following situation: I have a class (let's call it Main) encapsulating a complex process. This class in turn orchestrates a sequence of subalgorithms (AlgoA, AlgoB), each one represented by an individual class. To configure Main, I have a configuration stored into a configuration object MainConfig. This object contains all the config information for AlgoA and AlgoB with their specific parameters. AlgoA has no interest to the information relative to the configuration of AlgoB, so technically I could have (and in practice I have) a contained MainConfig.AlgoAConfig and MainConfig.AlgoBConfig instances, and initialize as AlgoA(MainConfig.AlgoAConfig) and AlgoB(MainConfig.AlgoBConfig). The problem is that there is some common configuration data. One example is the printLevel. I currently have MainConfig.printLevel. I need to propagate this information to both AlgoA and AlgoB, because they have to know how much to print. MainConfig also needs to know how much to print. So the solutions available are   1. I pass the MainConfig to AlgoA and AlgoB. This way, AlgoA has technically access to the whole configuration (even that of AlgoB) and is less self-contained   2. I copy the MainConfig.printLevel into AlgoAConfig and AlgoBConfig, so I basically have three printLevel information repeated.   3. I create a third configuration class PrintingConfig. I have an instance variable MainConfig.printingConfig, and then pass to AlgoA both MainConfig.AlgoAConfig and MainConfig.printingConfig. Have you ever found this situation? How did you solve it ? Which one is stylistically clearer to a new reader of the code ?


IValidatableObject vs Single Responsibility

I like the extnesibility point of MVC, allowing view models to implement IValidatableObject, and add custom validation. I try to keep my Controllers lean, having this code be the only validation logic:               if (!ModelState.IsValid)         return View(loginViewModel);      For example a login view model implements IValidatableObject, gets ILoginValidator object via constructor injection:               public interface ILoginValidator     {         bool UserExists(string email);         bool IsLoginValid(string userName, string password);     }      It seems that Ninject, injecting instances in view models isn't really a common practice, may be even an anti-pattern? Is this a good approach? Is there a better one?


Why do companies tell me they want me as an in-house employee, not as a contractor?

## Context Money is not what is at issue here. What is at issue is independence and to make sure I will contribute by working at my field of expertise, tactfulness, and ensuring everyone's expectations are in-line. Companies that are trying to develop new software products tell me they want me as an in-house employee, and not as a contractor. After just finishing my PhD, I am an expert in a very specialized kind of data analysis, not in general programming. My programming skills were gained as a by-product of my academic research. I believe I am called a 'domain expert' rather than a 'software engineer'. My coding is focused on implementing a specific class of data analysis algorithms, so I consider myself more of an a academic excelling at thinking of creative ways of developing tools to solve problems, who programs to test and implement these new ideas, rather then being a corporate programmer. I am looking for work as a contractor in my field of expertise and would prefer to earn less money and have less benefits working as a short-term contractor helping people with what I am an expert in rather than being a in- house employee. Some of the problems they have discussed seem perfectly suited for me to work with them for only a few months and then move on and let their real coders take over. I have helped academics in this manner. I am in the USA. ## **The problem:** Companies say I need to be an in-house employee for intellectual property reasons. ## **The question:** Wouldn't it be easy for them to just have me sign a contract saying all my work is owned by them? If I work as a contractor, they can let me go when my value diminishes and save lots of money and I could just focus on what I think is a fun way to work --moving from problem to problem. What am I missing here?


Discrete Mathematics Refreshers Course?

I graduated 8 years ago and did a discrete mathematics course in my 2nd year, but I've been told that I'll likely be asked discrete maths questions in an upcoming interview. Is there a simple webpage/document that I can use to refresh my memory? I understood the concepts when I took the course 10 odd years ago, but my memory is a bit rusty and I'd like to just refresh it.


Lines of Code vs. Optimal Language

I was wondering whether it is possible to give any advice as the the maximum number of lines of code at which one should consider switching from say MATLAB to a more low level language? Is it even the case that at a certain point it makes more sense to manage a certain degree of complexity of a given program in a proper object oriented language rather then MATLAB? I should say I am a newbie in both MATLAB and Java, so I have no hidden agenda in this question even though I m aware of the heated discussions that people sometimes engage in over whether MATLAB is a proper programming language. I'm not experienced enough to even think about participating in such an exchange and I'm just looking for advice whether there is a cut off point where one really needs to go to a different language? Also I should add I understand the code may become longer when you move to lower level, however I was under the impression that object oriented programming makes it easier to manage the complexity of bigger programs. (Maybe lines of code was a bad choice as a proxy for complexity?) Is the choice of low vs. high level just one of performance? (which in the end you have to pay for with a bigger programming task at your hands for the low level language?)


open source database project

What is the best way to build an open source database? I would like to build a database of all vehicles and their related maintenance information (i.e Oil Weight, Quantity, Tire Pressure, Windshield wipers etc). Currently this information is fragmented or just not put on-line in an easily accessible manner. As soon as collection begins, I would like to import this data into the DB and make it available freely to anyone. Is there a process (site or group) that I can start gathering this information in a reliable and verifiable way? In addition to this, are there any issues that I should be aware of?


Storing bugfixes as local changes rather than in SVN branch

We are deploying and upkeeping web-sites to different customers. Normally we wait for newest changes to stabilize, then tag subversion version as release, and install than version to customer. Then we receive support requests, and sometimes are forced to make quick bugfixes between releases. I find it troublesome to upkeep these bugfixes in branches, and wonder why not store them as "local changes" in some "Release X.Y"-folder (on build-machine)? Can this work, or is branching the only way? Reasons for this change are:   * it seems much easier to use WinMerge-utility for merging newest bugfixes into some "Release X.Y"-folder, than using tortoise-svn's "branch integration". WinMerge offers you much finer control over which changes to merge and which not (on file-basis, not commit-basis).   * when keeping bugfixes as "local changes" you have three-way comparison: in "Check for modifications" you can see all the bugfixes in current release, and with WinMerge you can see all the newest trunk-changes (if compare "Release X.Y" with "trunk"-folder)   * also it seems over-obsessive to keep everything in SVN. IMO SVN should serve the user and not the other way around.   * also branch re-integration never merges only those files that have actually changed. It takes along whole bunch of unnecessary files, which make it difficult to track anything in SVN-log.


What is the most optimal algorithm for counting lines of text in a file?

File > 5Gb, simply with lines like apache access.log. Need to get number of lines. Any constructions like               file(filename).read().counter('\n')      Would read all of files and it would be very long time. e.g.               os.stat(filename).st_size      Works very fast. It is possible to get at least hypothetically number of lines, by size of first lines in bytes and total size of file. Is there more accurately way?


Why is the folder name "bin" used in some frameworks and languages?

I have been learning Java. And still after a prolonged time I don't know **why the name of the folder is "bin"** where one find all the tools for java? Is there is any logical reason behind that? I have also noticed the same in .Net framework also.


Should Development / Testing / QA / Staging environments be similar?

After much time and effort, we're finally using maven to manage our application lifecycle for development. We still unfortunately use ANT to build an EAR before deploying to Test / QA / Staging. My question is, while we made that leap forward, developers are still free to do as they please for testing their code. One issue that we have is half our team is using Tomcat to test on and the other half is using Jetty. I prefer Jetty slightly over Tomcat, but regardless we using WAS for all the other environments. My question is, should we develop on the same application server we're deploying to? We've had numerous bugs come up from these differences in environments. Tomcat, Jetty, and WAS are different under the hood. My opinion is that we all should develop on what we're deploying to production with so we don't have the problem of well, it worked fine on my machine. While I prefer Jetty, I just assume we all work on the same environment even if it means deploying to WAS which is slow and cumbersome. What are your team dynamics like? Our lead developers stepped down from the team and development has been a free for all since then. Walter


What approaches can I take to lower the odds of introducing new bugs in a complex legacy app?

Where I work I often have to develop (and bug fix) in an old system (.NET 1) whos code is complete spaghetti - with little thought given to variable names, program structure nor comments. Because of this it takes me ages to understand what bits need changed, and I often 'break' the existing software because I've made a modification. I really _really_ want to spend a couple of months (with colleagues) going through it to refactor but existing developers both can't see the need - nor think theres time for this (the system is massive). I dread having to work on its code as it takes days to fix something only to find out I've broken something else. This obviously makes me look incompetent - so how can I deal with this?


A list of the most important areas to examine when moving a project from x86 to x64?

I know to check for/use asserts and carefully examine any assembly components, but I didn't know if anyone out there has a fairly comprehensive or industry standard check-list of specific things at which to look? I am looking more at C and C++. note: There are some really helpful answers, I'm just leaving the question open for a couple days in case some folks only check questions that don't have accepted answers.


Returning an IQueryable from an IRepository

Using the Repository pattern, is it proper to return an IQueryable of a data set (table), for generic usage? It is very handy in many cases, especially when using external libraries that leverage that interface, for example some plugins that sort/filter and bind to ui elements. However, exposing an IQueryable sometimes seems to leave the design prone to errors. This, coupled with a wrong usage of lazy loading could lead to severe performance hits. On the other hand, having access methods for every single usage seems redundant and also a lot of work (considering unit tests etc).


Is there any way to remove this redundancy?

I currently have the following HTML code                 <time datetime="2012-08-23">         23. August 2012       </time>      I have that because I felt the "23. August 2012" format was easier for website visitors to read than               <time>2012-08-23</time>      Both of those HTML5 examples validate at w3, but the first one is obviously redundant, and I like to cut out markup I don't need. Is there another date formate that I can use in the second example that is (1) easy for website visitors to read, and (2) w3 valid?


Why aren't there native Javascript interpreters for Windows/Mac/Linux?

It seems to me it would be very useful to use Javascript for general server side scripting tasks as it has more or less the same features as Perl and Python. But AFAIK there are no generally available Javascript interpreters for the major machine architectures. I guess the other problem may be lack of libraries but surely these would come if the interpreters were there. Google's V8 maybe could be a starting point. Does anyone think we'll see this soon?


How to unit test a function that is refactored to strategy pattern?

If I have a function in my code that goes like:               class Employee{              public string calculateTax(string name, int salary)         {             switch (name)             {                 case "Chris":                     doSomething($salary);                 case "David":                     doSomethingDifferent($salary);                 case "Scott":                    doOtherThing($salary);                           }     }      Normally I would refactor this to use Ploymorphism using a factory class and strategy pattern:               public string calculateTax(string name)     {         InameHandler nameHandler = NameHandlerFactory::getHandler(name);         nameHandler->calculateTax($salary);     }      Now if I were using TDD then I would have some tests that work on the original `calculateTax()` before refactoring. ex:               calculateTax_givenChrisSalaryBelowThreshold_Expect111(){}         calculateTax_givenChrisSalaryAboveThreshold_Expect111(){}          calculateTax_givenDavidSalaryBelowThreshold_Expect222(){}        calculateTax_givenDavidSalaryAboveThreshold_Expect222(){}           calculateTax_givenScottSalaryBelowThreshold_Expect333(){}     calculateTax_givenScottSalaryAboveThreshold_Expect333(){}      After refactoring I'll have a Factory class `NameHandlerFactory` and at least 3 implementation of `InameHandler`. How should I proceed to refactor my tests? Should I delete the unit test for `claculateTax()` from `EmployeeTests` and create a Test class for each implementation of `InameHandler`? Should I test the Factory class too?


What's the benefit of a singleton over a class in objective-c?

They both seem to take about the same amount of effort to use: Singleton: needs a .h and .m file, has to be imported into any class you want to call it from and then has to be instantiated How is that any different than a class?


When you won't need a language anymore, should you still use it?

My first main language was Java. However, over the years I've dropped Java in favor for Python, JavaScript, bash, etc. I still have advanced reading knowledge of Java, but since I haven't coded in it for so long, my writing knowledge is intermediate at most. The other day, while looking at some old code written in Java, I got inspiration to re-write it as a learning experience to reacquaint myself. It was at that point that I stopped to think that if I wrote this in Java, it would be nice, but when the renewed inspiration had hit me, I wanted to implement it as a web app (it was a game), so other people could play it. So now here's the dilemma: Do I re-write (and heavily refactor) the code I've previously written in Java, and _then_ in JavaScript (for the web version), or do I just forget about Java altogether and re-write it in JavaScript? EDIT: I have no problem writing in Java first and then JavaScript, but I'm more likely than not going to need Java anymore for a long while. What I'm trying to ask is whether or not I should rewrite the old code in Java first, to practice a skill I may not need in the future. The actual languages are less important than that question.


Do context diagrams have levels?

I heard that the context analysis diagram has different levels. I couldn't find this in .Net, but I have seen that a DFD has different levels. Do context diagrams have any levels (`level0`, `level1`, `level2`)? If yes, please suggest some examples.


In a multidisciplinary team, how much should each member's skills overlap?

I've been working in embedded software development for this small startup and our team is pretty small: about 3-4 people. We're responsible for all engineering which involves an RF device controlled by an embedded microcontroller that connects to a PC host which runs some sort of data collection and analysis software. I have come to develop these two guidelines when I work with my colleagues:   1. Define a clear separation of responsibilities and make sure each person's contribution to the final product doesn't overlap.   2. Don't assume your colleagues know everything about their responsibilities. I assume there is some sort of technology that I will need to be competent at to properly interface with the work of my colleagues. The first point is pretty easy for us. I do firmware, one guy does the RF, another does the PC software, and the last does the DSP work. Nothing overlaps in terms of two people's work being mixed into the final product. For that to happen, one guy has to hand off work to another guy who will vet it and integrate it himself. **The second point is the heart of my question.** I've learned the hard way not to trust the knowledge of my colleagues absolutley no matter how many years experience they claim to have. At least not until they've demonstrated it to me a couple of times. So given that whenever I develop a piece of firmware, if it interfaces with some technology that I don't know then I'll try to learn it and develop a piece of test code that helps me understand what they're doing. That way if my piece of the product comes into conflict with another piece then I have some knowledge about possible causes. For example, the PC guy has started implementing his GUI's in .NET WPF (C#) and using LibUSBdotNET for USB access. So I've been learning C# and the .NET USB library that he uses and I build a little console app to help me understand how that USB library works. Now all this takes extra time and energy but I feel it's justified as it gives me a foothold to confront integration problems. Also I like learning this new stuff so I don't mind. On the other hand I can see how this can turn into a time synch for work that won't make it into the final product and may never turn into a problem. **So how much experience/skills overlap do you expect in your teammates relative to your own skills? Does this issue go away as the teams get bigger and more diverse?**


What's the best way of marketing to programmers?

Disclaimer up front - I'm definitely not going to include any links in here - this question isn't part of my marketing! I've had a few projects recently where the end product is something that developers will use. In the past I've been on the receiving end of all sorts of marketing - as a developer I've gotten no end of junk - 1000s of pens, tee-shirts and mouse pads; enough CDs to keep my desk tea-free; some very useful USB keys with some logos I no longer recognise; a small forest's worth of leaflets; a bulging spam folder full of ignored emails, etc... So that's my question - **What are good ways to market to developers?** And as an aside - are developers the wrong people to target? - since we so often don't have a purchasing budget anyways!


Why is the use of abstractions (such as LINQ) so taboo?

I am an independent contractor and, as such, I interview 3-4 times a year for new gigs. I am in the midst of that cycle now and got turned down for an opportunity even though I felt like the interview went well. The same thing has happened to me a couple of times this year. Now, I am not a perfect guy and I don't expect to be a good fit for every organization. That said, my batting average is lower than usual so I politely asked my last interviewer for some constructive feedback, and he delivered! The main thing, according to the interviewer, was that I seemed to lean too much towards the use of abstractions (such as LINQ) rather than towards lower- level, organically grown algorithms. On the surface, this makes sense--in fact, it made the other rejections make sense too because I blabbed about LINQ in those interviews as well and it didn't seem that the interviewers knew much about LINQ (even though they were .NET guys). **So now I am left with this question:** If we are supposed to be "standing on the shoulders of giants" and using abstractions that are available to us (like LINQ), then why do some folks consider it so taboo? Doesn't it make sense to pull code "off the shelf" if it accomplishes the same goals without extra cost? It would seem to me that LINQ, even if it _is_ an abstraction, is simply an abstraction of all the _same_ algorithms one would write to accomplish exactly the same end. Only a performance test could tell you if your custom approach was better, but if something like LINQ met the requirements, why bother writing your own classes in the first place? I don't mean to focus on LINQ here. I am sure that the JAVA world has something comparable, I just would like to know why some folks get so uncomfortable with the idea of using an abstraction that they themselves did not write. ## UPDATE As Euphoric pointed out, there isn't anything comparable to LINQ in the Java world. So, if you are developing on the .NET stack, why not always try and make use of it? Is it possible that people just don't fully understand what it does?


Can the ScrumMaster and other team members be managed by the Product Owner?

Our team is switching to Scrum. I would be the ScrumMaster (in addition to being a developer), and another developer would become Product Owner (in addition to our product marketing guy). All members of the team, including me, would be managed by the would-be Product Owner. By that I mean that the guy would be the one deciding about our yearly evaluation, raises, etc. Would this hierarchical link be prone to introduce issues? How do organizations typically map hierarchical structure onto agile teams? I suppose it's quite common that the ScrumMaster has a hierarchical link to the other developers in the team. Here it would be the Product Owner. Is this different?


choosing an opensource license for a software

i am glad to say that we are going to make Advanced Electron Forum (anelectron.com) an Opensource project, since we have a lack in developers and we think that this will make the development wheel turn much much better, we are going to post the source code to public in github, but we are not sure about the license that we are going to use, GPL gives too much freedom we don't want, the only thing we want to prevent the user from doing is the forking, we don't want any forks or redistribution of the code without permission, so what to chose ?


Is it common for developers to deal with extensive change control procedures?

This question requires a bit of setup, please bear with me. Last week my company rolled out a new change management procedure. Any change destined for production requires a change control record; this policy was already in place and I don't disagree with it. The new procedure, however, involves a highly convoluted, server-intensive web app for creating the records. As an added bonus the servers are in Europe (I'm in Seattle), which often results in latency issues. **Any** given change record requires (at a minimum) a business justification, requirements document, pre-implementation plan, pre-implementation test plan, execution plan, execution test plan, post-implementation plan and post- implementation test plan. These plans have to be typed manually into the aforementioned web app. After creating the record, the developer making the change is required to attend an hour-long phone conference with the Change Advisory Board to justify the change. Nevermind that the change request passed through four layers of management before hitting our desks; it's on us to justify the work. I'm of the opinion that any work that lands on my desk should have been justified long since, preferably by the person/department requesting the work. This may end up being a deal-breaker for me. My question is, how common is this practice in the programming shops of non- software companies? **Edit:** There's a lot of good feedback here. It sounds like the solution is to join a software company that isn't involved in finance, healthcare or government. :) Thanks to everyone for the responses.


Where do other programming languages fit in Windows 8 development model?

Today, Windows applications can be developed in numerous languages and frameworks. But in the upcoming Windows 8, with the introduction of WinRT, the development model is going change at a large scale. So, where do other programming languages fit in this model?


Design pattern for isomorphic trees

I want to create a data structure to work with isomorphic tree. I don't search for a "algorithms" or methods to check if two or more trees are isomorphic each other. Just to create various trees with the same structure. Example:                 2 - - - - - - - 'a' - - - - - - - 3.5       / \              / \               / \     3   3           'f' 'y'           1.0 3.1        / \              / \               / \       4   7           'e' 'f'           2.3 7.7      The first "layer" or tree is the "natural tree" (a tree with natural numbers), the second layer is the "character tree" and the third one is the "float tree". The data structure has a method or iterator to traverse the tree and to make diferent operations with its values. These operations could change the value of nodes, but never its structure (first I create the structure and then I configure the tree with its diferent layers). In case of that I add a new node, this would be applied to each layer. Which known design pattern fits with this description or is related with it?


How many regression bugs from refactoring is too many.

Recent QA testing has found some regression bugs in our code. My team lead blames recent refactoring efforts for the regressions. My team lead's stance is "refactor, but don't break too many things", but wouldn't tell me how many is "too many". My stance is it's QA's job to find bugs that we can't find, and refactoring usually introduces breaking changes. So sure, I can be careful, but I don't knowingly release code with bugs to QA. I do it because I don't see them. If the refactoring was necessary, how many regression bugs should be considered too many?


How to sync clocks over networking for game development?

I'm writing a game that has a lot of time based aspects. I use time to help estimate player positions when the network stalls and packets aren't going through (and the time between packet's being received and not). It's a pacman type game in the sense that a player picks a direction and can't stop moving, so that system makes sense (or at least I think it does). So I have two questions: 1) How do I sync the clocks of the games at the start since there is delay in the network. 2) Is it okay NOT to sync them and just assume that they are the same (my code is time-zone independent). It's not a super competitive game where people would change their clocks to cheat, but still. The game is being programmed in Java and Python (parallel development as a project)


Maintaining Two Separate Software Versions From the Same Codebase in Version Control

Let's say that I am writing two different versions of the same software/program/app/script and storing them under version control. The first version is a free "Basic" version, while the second is a paid "Premium" version that takes the codebase of the free version and expands upon it with a few extra value-added features. Any new patches, fixes, or features need to find their way into both versions. I am currently considering using `master` and `develop` branches for the main codebase (free version) along side `master-premium` and `develop-premium` branches for the paid version. When a change is made to the free version and merged to the `master` branch (after thorough testing on `develop` of course), it gets copied over to the `develop-premium` branch via the `cherry-pick` command for more testing and then merged into `master-premium`. Is this the best workflow to handle this situation? Are there any potential problems, caveats, or pitfalls to be aware of? Is there a better branching strategy than what I have already come up with? Your feedback is highly appreciated! P.S. This is for a PHP script stored in Git, but the answers should apply to any language or VCS.


Scrum task over estimation

In my current company we're using Scrum with 2 week iterations and a regular planning session. How planning normally works in our company is that we take a predefined , prioritized (by PO before the planning) product backlog of user stories / PBIs, take PBIs from the top one by one and break it down to tasks to then estimate them in hours (using poker planning and fibonacci) until we reach a given team's capacity. While this works for most of the teams, there is one 2-person team where I'm a SM, that tends to systematicaly overestimate the tasks by far (as those developers are being paid by an hour in this project, and from the record of working with them in another project I know for a fact they have a far better velocity). Not being a part of this team as a developer, trying to adhere to Scrum I'm refraining from influencing those estimates by any means, however as we approach the deadlines in the project this situation is becoming more and more troublesome. My question is - is there a way / good practice in such situations, to keep the team on the edge of their velocity and not influence their estimations, or maybe we're doing sth wrong in the process ?


Why Num&sizeMinusOne faster than num&(size-1)

I've been told that when I have a hash table of size `m` and `m=2^k`, I can use the `&` operator as `num & (size-1)` instead of `num % size`, to fit the hashCode to my table size. I've also been told that the the command Num&sizeMinusOne is more than twice faster than `num & (size-1)`. My question is, why? And isn't the operation of creating a variable called SizeMinusOne takes time too?


How to find extra work outside of full time job?

> **Possible Duplicate:**   >  Do you work contract projects in addition to your full-time job? I currently work as a C++ developer full time (not a contract). I'm seeking extra opportunities outside of work. So far, I've been doing small gigs for people on sites like Craigslist or ODesk.com on the side for extra cash but they are just never lucrative enough. My first question is ... is it possible to find a contract type position that will allow me to work outside of normal hours (i.e. evenings and weekends)? How would you even find a job like that? I'm also worried about potential conflicts of interest. If the contract was in a completely different field, is there any reason that I have to report this to my employer? Should I get the help of a recruiter to find these type of jobs? If it's too difficult to find something like that ... where do you guys go to find extra work outside of your full time job? I know a lot of people do their own projects but I just don't have any of my own ideas for an iPhone app or anything like that. :P I have had the most luck with Craigslist in the past but there has to be better sites out there somewhere. Anyone willing to reveal the secret place? ;) Thanks!


How do you get people to use a bug tracker?

This is actually a question I should've asked a while ago(as in, I don't even work at this job) but I thought it to be an interesting question nonetheless. Our team was basically just 1 developer(me!). The manager also developed sometimes, but was mostly just business. He thought we should have some sort of bug tracker, so we installed some open source tracker on our server. I initially did not use this bug tracker. Then, another developer was hired. He doubled as a tester(sometimes) and it seemed like every morning(His shift was scheduled like 2 hours earlier than mine by preference) I'd come into work, he'd have about 2 pieces of paper full of bugs and possible bugs. I'd go through each item, mark them off as a fixed them, or wrote by-design, or fix later. Anyway, then I'd come in another morning.. another list of bugs. About 6 of the 15 bugs listed were duplicates, or extremely related to bugs I'd previously said by-design or fix-later on. So, I started using the bug tracker on our server. It wasn't hard to use(required only a bug title), but it wasn't great either. I told the other developer that he should start entering bugs there and I will check the bugs he submits when I come in. This way it'd be easier to track. I come in the next morning, and lo and behold another piece of paper on my desk listed with bugs. At this point about 11 out of 13 listed bugs were duplicates. I didn't even bother writing on the paper. (this continued basically for about 4 months, until I was layed off) **TL;DR:** What should I have done to convince this other developer to use the bug tracker?


Competitive Programming

I think this may just be one of the most frequently asked questions by a novice (like me) on this site. Please pardon me for that. My question is I wish to get better at solving the harder problems of competitive programming which almost always are very tough dynamic programming formulations, dynamic data-structure manipulations and hard combinatorial object manipulations. How should I go about training myself to not only gain confidence but also gain an expertise in these areas. Yes, I know the obvious answer is practise! But, I'd want to know say books or materials that I should look up to before hitting a programming site like say spoj, hackerrank, codechef, codeforces and the like.


How to fit beta versions into a numeric versioning scheme?

Some tools force developers to adopt a version scheme of a certain form, form instance "major.minor.build.revision", where each field must be a number. How do I fit in betas in there? For instance, what version should I choose for version "2.0 beta2"? Should it be of the form "1.99.x.y" (it's not yet 2.0 stable) or "2.0.x.y" (2.0 beta introduces breaking changes with 1.x).


Definition of a type

Conceptually, I used to think of types as sets. However, I think I've seen people wishing to distinguish types `A`, `B` even if they represent identical collections of values. So I figured a better definition of type is a pair `(type_name, set)`, where two different types cannot have the same first element. Then I ran into a different situation. I thought a function is just a set of pairs `(x, y)`. But then a function `A->B` (where `A, B` represent the same collections of values) cannot be distinguished from a function `B->B` or `A->A` or `B->A`, and again I think I've seen people want to distinguish them. So how do I define a function? As a tuple `(A, B, (x1, y1), (x2, y2), ...)`, where each element of `A` appears exactly once as the first element in the pairs, and where each second element is of type `B`? And the type `F` that represents all functions that takes `A->B` is then `(F, ((A, B, (a1, b11), (a2, b12), ...), (A, B, (a1, b21), (a2, b22), ...), (A, B, (a1, b31), (a2, b32), ...)))`, where `a1, ...` are all the values represented by A, and `b?1, b?2, ...`, for any `?`, are some of the values represented by `B`. This all seems rather cumbersome, am I missing something?


Hierarchical View/ViewModel/Presenters in MVPVM

I've been working with MVVM for a while, but I've recently started using MVPVM and I want to know how to create hierarchial View/ViewModel/Presenter app using this pattern. In MVVM I would typically build my application using a hierarchy of Views and corresponding ViewModels e.g. I might define 3 views as follows: ![View A](http://i.stack.imgur.com/eHsn6.png) The View Models for these views would be as follows:               public class AViewModel     {         public string Text         {             get { return "This is A!"; }         }              public object Child1 { get; set; }             public object Child2 { get; set; }     }          public class BViewModel     {         public string Text         {             get { return "This is B!"; }         }     }          public class CViewModel     {         public string Text         {             get { return "This is C!"; }         }     }      In would then have some data templates to say that BViewModel and CViewModel should be presented using View B and View C:               <DataTemplate DataType="{StaticResource local:BViewModel}">         <local:BView/>     </DataTemplate>     <DataTemplate DataType="{StaticResource local:CViewModel}">         <local:CView/>     </DataTemplate>      The final step would be to put some code in AViewModel that would assign values to Child1 and Child2:               public AViewModel()     {         this.Child1 = new AViewModel();         this.Child2 = new BViewModel();     }      The result of all this would be a screen that looks something like: ![enter image description here](http://i.stack.imgur.com/hXGz7.png) Doing this in MVPVM would be fairly simple - simply moving the code in AViewModel's constructor to APresenter:               public class APresenter      {         ....         public void WireUp()         {             ViewModel.Child1 = new BViewModel();             ViewModel.Child2 = new CViewModel();          }      }      But If I want to have business logic for BViewModel and CViewModel I would need to have a BPresenter and a CPresenter - the problem is, Im not sure where the best place to put these are. I could store references to the presenter for AViewModel.Child1 and AViewModel.Child2 in APresenter i.e.:               public class APresenter : IPresenter     {         private IPresenter child1Presenter;         private IPresenter child2Presenter;              public void WireUp()         {             child1Presenter = new BPresenter();             child1Presenter.WireUp();             child2Presenter = new CPresenter();             child2Presenter.WireUp();                  ViewModel.Child1 = child1Presenter.ViewModel;             ViewModel.Child2 = child2Presenter.ViewModel;         }     }      But this solution seems inelegant compared to the MVVM approach. I have to keep track of both the presenter and the view model and ensure they stay in sync. If, for example, I wanted a button on View A, which, when clicked swapped the View's in Child1 and Child2, I might have a command that did the following:               var temp = ViewModel.Child1;     ViewModel.Child1 = ViewModel.Child2;     ViewModel.Child2 = temp;      This would work as far as swapping the view's on screen (assuming the correct Property Change notification code is in place), but now my APresenter.child1Presenter is pointing to the presenter for AViewModel.Child2, and APresenter.child2Presenter is pointing to the presenter for AViewModel.Child1. If something accesses APresenter.child1Presenter, any changes will actually happen to AViewModel.Child2. I can imagine this leading to all sorts of debugging fun. I know that I may be misunderstanding the pattern, and if this is the case a clarification of what Im doing wrong would be appreciated. **EDIT** \- this question is about WPF and the MVPVM design pattern, not ASP.NET and MVP.


While running an application the error occurs, while debugging it doesn't

There is an issue which appears while running the application. It is not an Exception, but the desired UI change is not been implemented. While debugging to find the code which should be changed to fix this problem, the UI changes can be seen correctly, To be specific, if we put one breakpoint in the class where it is called, and press the Continue in NetBeans, the problem occurs. But if we step over to the next lines and try to see the state at the end of the debug, the component seems to work perfectly. How can these kind of issues be resolved?


How does an interviewer get a glimpse of a candidates thought process during an interview?

> **Possible Duplicate:**   >  How do you interview someone with more experience than you?   >  How can I really "wow" an employer at an interview? I am a bit puzzled by the whole technical interview process. I have been on a few interviews recently and I keep hearing certain phrases during the interviews. And I want to get more insight into the mind of the interviewer and the process itself. Can anyone please shed some light into this? What do they really want? I am convinced that it is not the actual correct answer to the problem one is presented with because getting the right answer hasn't gotten me a job. How do they "get a glimpse into my thought process"? EDIT: I am adding this to the question because I think I might help. During the interview when you are writing code on the white board and they ask you to explain the process or approach are they expecting me to act like a player on who want to be a millionaire? Do I need to explain every little detail or reason for doing something?


Interviewing a Senior Dev when they will be far more competent at programming than the interviewer

> **Possible Duplicate:**   >  How do you interview someone with more experience than you? Next week i'll be interviewing some contractors for a 6-month senior Dev position on a project. I'm an OK programmer myself, but nothing special, and at the moment i'm struggling to think of what questions to ask them, or what coding challenges i'd set, since the answers would likely go over my head anyway. The project is an ASP.NET MVC application for an intranet. My personal thought was to have them write a trivial MVC app that pulls some data from a DB during the interview, showing that they can implement a testable, loosely coupled application, but i don't know if this is _too_ trivial. From it i would expect them to have implemented a couple of tests, set up dependency injection, and probably use a repository instead of fat controllers. Any ideas, or is what i'm suggesting a bad idea? The coding part of the interview would likely last about 40 minutes. I timed myself doing what i'd planned and it took me just over half an hour. The candidates would have seen the requirements for the application a couple of days prior to the interview. From thinking about it a bit more, perhaps i should start off with a tightly coupled app, and ask the candidates to refactor it instead, and implement some tests? Edit: With respect to Rob's comments below, i'd like the answers to more focus on what i'd got planned (But all answers gratefully received)


What to expect from a 'peer interview' for a new grad position?

I apologize if something like this has been asked, I did try to look for something similar. I am graduating May 16th, and I applied for a position posted as '.NET Application Developer' requiring 1-2 years experience and a Bachelor's in CIS. I had the phone screen, which went well. They brought me in Friday for an interview with the head managers which consisted of a written 20 question test, and other behavioral like questions and oddball ones such as "How would you make an M&M?" That seemed to go well too, they took me on a tour of the campus and said they usually will get back to the candidate, if they decide to proceed, in a week or so. Well, that following Monday at 9:00 am sharp they called me back for a third and final 'peer interview'. **This is where I am stuck - I have no idea what to expect here? How do I prepare?** Is this like the 'Hey let's see if you are culture fit" or "Lets put him through the paces with whiteboard coding" or what? Any advice would be HIGHLY appreciated. I have been practicing whiteboard coding just in case, and will come in with a humble, "I want to learn from you guys" kind of attitude.


What are some interview questions I can expect for a technical evaluation?

I am 20 years old and I've been doing some web development work for about 2 years or so. I have an interview for a Junior Web Developer position and the company knows that but I'll still be going through a technical interview and since I haven't been on one before I am not sure what kinds of questions I'll expect. I will be interviewed on PHP, HTML, CSS, and JavaScript. What are some popular or rather important questions that I might be asked in those four language areas? I know the questions might vary greatly but just to get an idea. Eager to see some of your responses. Thanks!


How to prepare yourself for programming interview questions?

> **Possible Duplicate:**   >  Really "wow" them in the interview Let's say I appear for an interview. What questions could I expect and how do I prepare?


How can I really "wow" an employer at an interview?

I'm a top-notch programmer, but a notoriously bad interviewee. I've flunked 3 interviews consecutively because I get so nervous that my voice tightens at least 2 octaves higher and I start visibly shaking -- mind you, I can handle whatever technical questions the interviewer throws at me in that state, but I think it looks bad to come off as a quivering, squeaky-voiced young woman during a job interview. I've just got the personality type of a shy computer programmer. No matter how technical I am, I'm going to get passed up in favor of a smooth talker. I have another interview coming up shortly, and I want to really impress the company. Here are my trouble spots:   1. **What can I do to be less nervous during my interview?** I always get really excited when I hear I have a face-to-face interview, but get more and more anxious as the interview approaches.   2. **How long or short should I keep my answers?** Interviewers want me to explain what I used to do at my prior employment, but I'm a very chatty person and tend to talk/squeak for 10 minutes at a time.    3. **What exactly is my interviewer looking for when asking about prior jobs?**   4. During the interview, I'll be asked if I have any questions for the interviewer. I _should_ , but **what kinds of questions should I ask to show that I'm interested in being employed?**   5. **How can I sugarcoat "I want to make more money" into something that sounds nicer?** Interviewers always ask why I'm looking for a new job. The real reason is that my current salary isn't that great, and I want to make more money: otherwise the work environment is fine.   6. I have only one prior programmer job, and I've worked there for 18 months, but I have the skill of someone with 4 to 6 years of experience. **What can I say to compete against applicants with more work experience?**


Preparing for Interviews

> **Possible Duplicate:**   >  How to prepare yourself for programming interview questions? Could someone give me pointers on how go to about preparing for a technical interview? As a CS graduate, I guess one must be thorough with the following topics: **Data Structures:** Array, Linked List, Stack, Queues, Heap, Hash Table, Binary Tree, Binary Search Tree, Self Balancing Binary Tree (AVL, Red Black Tree), B-Tree, Tries/Suffix Tree **Algorithms:** Sorting (Bubble Sort, Insertion Sort, Selection Sort, Shell Sort, Quick Sort, Merge Sort, External Sorting), Searching (linear and logarithmic time searching), Graph Theory (Adjacency List, Adjacent Matrix, DFS, BFS, Topological Sort), Dynamic Programming, Greedy Algorithms, Divide and Conquer. **Adhoc Algorithms:** Select Algorithm, Fisher Yates Card Shuffle, Reservoir Sampling and list is endless. **Databases:** SQL Queries **Programming and Design:** C,C++, Java, scripting languages (Perl, Python), (OOPS basics, virtual functions, deep and shallow copy, copy constructor, assignment operator, STL, memory management, pointers/reference, interface, abstract classes **Operating Systems:** Thread Synchronization (Mutex, Conditional Variables, Semaphores, Deadlocks), Memory Management (Segmentation, Paging, TLB, Caching Mechanisms) * * * Also it would be great if we all could compile the resources available on internet to brush up these topics. I will add some of these: Linked List and trees: http://cslibrary.stanford.edu/103/ Please help me out to find useful resource to prepare for these topics, also I would appreciate if you could add in to these topics.


Doing practice jobsearch/technical interviews?

> **Possible Duplicate:**   >  How can I really "wow" an employer at an interview? I graduated college last year & I've never gone through the interview process - my current programming position evolved out of projects I did in school, but in a few months I'm making a clean break and moving across the country so I'm going to have to face a "grown-up" jobsearch. I'm kind of scared of technical interviews - I think I'm pretty good at my job and my hobby programming projects ... but what if it turns out I'm part of that group that thinks they're qualified, but really just cause despair at the state of education in the hearts of interviewers? So, I'm thinking of doing a "practice" job hunt in my current city to get an idea of what it's like and what kind of experience/expertise employers are really looking for. Is this a dick move ethically (applying to/interviewing for jobs I can't take)? If so, is there another good way to prepare for technical interviews, especially those little trick puzzle-type questions?


c# interview with a programming task

> **Possible Duplicate:**   >  How to prepare yourself for programming interview questions? I am going for c#-sql server job and I was looking for some link where I could download some questions and answers to have look at.Googling I have found many but because there is no download you have to click and navigate for each question and answer which makes the process very intense. Do you know a link where I can download some good c#/sql server questions? Also I am told I will be given a programming task. I have no idea what that might be. I hope is not some silly math algorithm that I know I will fail or some bubble sort stuff that I have never used in my c# programming life. Any ideas or examples people have been asked? Or is there a place where managers go to get this stuff? It's not a case of cheating but I find some questions not really pratical in the real world. typical silly question for a c# in my view is What's the difference between a stack vs heap? Now tell me whether as a c# programmer you are really bothered about the stack and heap. If you do some unboxing the compiler will tell you have an error.etc.. Why they keep asking that question.Even the agency the other day asked me that question. thanks a lot for any suggestions


Need help eliminating dead code paths and variables from C source code

I have a legacy C code on my hands, and I am given the task to filter dead/unused symbols and paths from it. Over the time there were many insertions and deletions, causing lots of unused symbols. I have identified many dead variables which were only being written to once or twice, but were never being read from. Both blackbox/whitebox/regression testing proved that dead code removal did not affected any procedures. (We have a comprehensive test-suite). But this removal was done only on a small part of code. Now I am looking for some way to automate this work. We rely on GCC to do the work. P.S. I'm interested in removing stuff like:   1. variables which are being read just for the sake of reading from them.   2. variables which are spread across multiple source files and only being written to. For example:               file1.c:     int i;          file2.c:     extern int i;     ....     i=x;


How do programming languages integrate with OS runtimes

For example, Objective-C, Swift and Ruby (i.e. RubyMotion) integrate with the Cocoa framework. Is this done via linked libraries? I assume they call functions in existing binaries instead of simply recreating some common interface.


GUI app with Web Technology that can take screenshots

I was given a task to prototype a Desktop Application with the ff. requirements:   1. Must use javascript, nodewebkit, node.js   2. Must be multi platform specially Windows and OSX   3. Can take a screenshot of a certain area where a use can point and drag   4. Must be able to watch multiple directories for changes Mostly `1,2,4` are possible but I can't get my head around (3) how I will take screen shots on specific areas depending on user point and drag input with only web technologies? What are ideas on this? I also plan to use angularJS/css for the UI.


How to learn new technologies without live projects

I have a year of experience in .Net but I have knowledge in basic stuffs like framework 2.0, java script and basics of sql server. But in Industry there is no need of these basic stuffs, they want more than these but as we don't have live project, How to go about that...?


Pros and cons of using Grails compared to pure Groovy

Say, you (by you I mean an abstract guy, any guy in your team) have experience of writing and building java web apps, know about filters, servlet mappings and so on, and so on. Also, let us assume you know pretty well any sql db, no matter which one exactly, whether it mysql, oracle or psql. At last, let pretend we know Groovy and its standard libraries, for example all that JsonBuilder and XmlSlurper stuff, so we don't need grails converters. The question is - what are benefits of using grails in this case. I'm not trying to start flame war, I'm just asking to compare - what are ups and downs of grails development compared to pure groovy one. For instance, off the top of my head I can name two pluses - automatic DB mapping and custom gsp tags. But when I want to write a modest app which provides small API for handling some well defined set of data, I'm totally OK with groovy's awesome SQL support. As for gsp, we does not use it at all, so we are not interested in custom tags as well.


Fault tolerance through replication of SQL databases

Suppose the middle tier servers are replicated 3 way and the backend database (MySQL, PostgreSQL, etc...) is replicated 3 way. A user request ends up creating some user data in the middle tier servers and I would like to commit this to the backend database in a way resilient to failures. A candidate attempt solution, for example, if I send the data to one SQL database and have it replicate the data to the other databases then if the one SQL database has the harddrive crash before it can replicate the data, the data is lost. What is the best practice solution for fault tolerance that is used in the actual real world.


Data Structures to represent logical expressions

Here is a logical statement:               term1 AND (term2 OR term3) OR term4      What is an effective way of storing this information in a data structure? For example, should I use a graph, with a property on each edge defining the operator to the next term? (This suggestion doesn't make sense IMO, but it's a data structure that might be useful for this)


Organizing your Data Access Layer

I am using Entity Framework as my ORM in an ASP.Net application. I have my database already created so ended up generating the entity model from it. What is a good way to organize files/classes in the data access layer. My entity framework model is in a class library and I was planning on adding additional classes per Entity(i.e per database table) and putting all the queries related to those tables in their respective classes. I am not sure if this is a right approach and if it is then where do the queries requiring data from multiple tables go? Am I completely wrong in organizing my files based on entities/tables and should I organize them based on functional areas instead.


Explain what this means, "Bulldozer Code"

I ran across an article on things programmers should avoid doing and came across this term: Bulldozer Code. The author defined it at as "giving the appearance of refactoring by breaking out chunks into subroutines, but that are impossible to reuse in another context". I interpret that as him saying to avoid creating procedures for code that can't actually be used in more than one place, which confuses me a little because I have an instructor prefers using procedures for the purpose of 'cleaner' code. So what exactly is bulldozer code and why should I avoid it?


What can be done to decrease the number of live issues with applications?

First off I have seen this post which is slightly similar to my question. : What can you do to decrease the number of deployment bugs of a live website? Let me layout the situation for you. The team of programmers that I belong to have metrics associated with our code. Over the last several months our errors in our live system have increased by a large amount. We require that our updates to applications be tested by at least one other programmer prior to going live. I personally am completely against this as I think that applications should be tested by end users as end users are much better testers than programmers, I am not against programmers testing, obviously programmers need to test code, but they are most of the times too close to the code. The reason I specify that I think end users should test in our scenario is due to the fact that we don't have business analysts, we just have programmers. I come from a background where BAs took care of all the testing once programmers checked off it was ready to go live. We do have a staging environment in place that is a clone of the live environment that we use to ensure that we don't have issues between development and live environments this does catch some bugs. We don't do end user testing really at all, I should say we don't really have anyone testing our code except programmers, which I think gets us into this mess (Ideally, we would have BAs or QA or professional testers test). We don't have a QA team or anything of that nature. We don't have test cases for our projects that are fully laid out. Ok, I am just a peon programmer at the bottom of the rung, but I am probably more tired of these issues than the managers complaining about them. So, I don't have the ability to tell them you are doing it all wrong.....I have tried gentle pushes in the correct direction. Any advice or suggestions on how to alleviate this issue ?


Implementing a generic/dynamic custom property system in C#

I have an architecture design problem which I think is appropriate for this site. _Note that I have made an_ **EDIT** _to this post below, reflecting my latest potential solution to this problem._ **General problem description:** My primary goal is to design a software library/program (C#) to automate a very particular type of microscopy experiments. Our experimental setups consists of many distinct hardware devices that generally fall into a limited number of categories:   * Point detector   * XY sample stage   * Autofocus device   * ... The natural choice is to design an interface `IDevice` with some basic properties shared by all devices such as e.g. `IDevice.Initialize()`, `IDevice.Name`, ... We can even design an abstract class, inheriting `IDevice`, e.g. `DeviceBase` implementing some functionalty common to all devices. Likewise, we can also design interfaces for specific devices, each time implementing the common stuff (`IXYSampleStage` might hold e.g. `IXYSampleStage.Move(posX, posY)` or `IXYSampleStage.AxisXStepSize`). Ultimately, I can implement all these interfaces in the final classes representing specific devices. I think I know what to do there. However, not all devices of a class are exactly the same. Some manufacturers offer rich functionality on top of the standard stuff. An XY Stage might have e.g. any number of optional/non-standard parameters to set such as e.g. channel delays, PID control values or whatever. To tackle this, > I need a mechanism to add additional properties (not methods, properties > will suffice) to specific device classes. Higher level code, interacting > with the devices should understand these added properties, be able to > get/set them, however many there might be. So much for the basic design problem. **What exists already** There is an OS software program, Micro Manager, which has such a system implemented, be it in C++ (full source here and no, I cannot use this SW directly for my purposes):               class PropertyBase     {     public:        virtual ~PropertyBase() {}             // property type        virtual PropertyType GetType() = 0;             // setting and getting values        virtual bool Set(double dVal) = 0;        virtual bool Set(long lVal) = 0;        virtual bool Set(const char* Val) = 0;             virtual bool Get(double& dVal) const = 0;        virtual bool Get(long& lVal) const = 0;        virtual bool Get(std::string& strVal) const = 0;             // Limits        virtual bool HasLimits() const = 0;        virtual double GetLowerLimit() const = 0;        virtual double GetUpperLimit() const = 0;        virtual bool SetLimits(double lowerLimit, double upperLimit) = 0;             // Some more stuff left out for brevity        ...     };      Subsequently, the `Property` class implements some of the pure virtual functions related to the limits. Next, `StringProperty`, `IntegerProperty` and `FloatProperty` implement the Get()/Set() methods. These kinds of properties are defined in an enum which allows only these three kinds of property. Properties can next be added to a `PropertyCollection` which is basically a kind of dictionary that is part of a device class. This all works nicely. We use MM a lot in the lab for other types of experiments but when trying to do similar things in my C# solution I stumbled about a few more fundamental questions. Most of these have to do with not being quite sure how to leverage specific features offered by C#/.NET (generic but definitely also dynamics, ...) to perhaps improve the existing C++ implementation. **The questions:** _First question_ : To limit the types of properties allowed, MM defines an enum:                   enum PropertyType {           Undef,           String,           Float,           Integer         };      Whereas C# has reflection and a lot of built-in support for types/generics. I therefore considered this:               public interface IProperty<T>     {        public T value { get; set; }             ...     }      I could next do an abstract `PropertyBase<T>` and ultimately               IntegerProperty : PropertyBase<int>     StringProperty : PropertyBase<string>     FloatProperty : PropertyBase<double>      But this gets me in trouble when trying to put them into a collection because in .NET following is not possible:               PropertyCollection : Dictionary<string, IProperty<T>>      Unless, perhaps, I adopt this strategy, i.e. have a non generic base class that only returns a type and then yet more base classes to actually implement my property system. However, this seems convoluted to me. **Is there a better way**? I think that utilising the generic language features might allow me to do away with needing all these Get()/Set() methods in the MM example above, as I would be able to know the backing type of my property value. I realise this is a very broad question but, there is a big gap between understanding the basics of some language features and being able to fully make the correct design decisions from the outset. _Second question_ I am contemplating making my final device classes all inherit from a kind of `DynamicDictionary` (e.g. similar to the one from here):                   public class DynamicDictionary : DynamicObject         {             internal readonly Dictionary<string, object> SourceItems;                  public DynamicDictionary(Dictionary<string, object> sourceItems)             {                 SourceItems = sourceItems;             }             public override bool TrySetMember(SetMemberBinder binder, object value)             {                 if (SourceItems.ContainsKey(binder.Name))                 {                     SourceItems[binder.Name.ToLower()] = value;                 }                 else                 {                     SourceItems.Add(binder.Name.ToLower(), value);                 }                 return true;             }             public override bool TryGetMember(GetMemberBinder binder, out object result)             {                 if (SourceItems != null)                 {                     if (SourceItems.TryGetValue(binder.Name.ToLower(), out result))                     {                         return true;                     }                 }                 result = null;                 return true;             }         }     }      but instead of `<string, object>` I would then like to use `<string, MyPropertyBase>` where the string would be the alias for my property (which would correspond to the design choice from Q1). Would doing such a thing make sense from a design standpoint? I would actually only need to add custom properties to devices at design time (i.e. when writing a custom device driver). At runtime, I would only need to inspect my custom properties or get/set their values. the C++ MM solves this by using a bunch of `CreateProperty("alias", Property)` methods in the device constructor, which again, works so maybe using dynamics here is overkill. But again, I am wondering if somebody could provide insight in possible advantages but certainly also disadvantages of going down the dynamic route. **To summarize** Are there .NET features (4.5) which I could leverage to implement some of the MM concepts in a more elegant way with a focus on the above mentioned specific matters? Again, I do realise this is a very broad question and perhaps some of the possible answers are more a matter of taste/style than anything els but if so (this making the question unsuited for this platform), please provide feedback/comments such that I can adjust accordingly. **EDIT** I have spent some more thinking about this and tried to solve it in the following way: First, an enum specifying the allowed propertytypes:               public enum PropertyType     {         Undefined,         String,         Float,         Integer     }      Second, an interface `IPropertyType` that is responsible for checking values fed to a property of a specific type:               public interface IPropertyType     {            Type BackingType { get; }              PropertyType TypeAlias { get; }              bool IsValueTypeValid(object value);     }      Then, a base class implementing `IPropertyType`:               public bool IsValueTypeValid(object value)         {             if (value == null)             {                 return true;             }                  Type type = value.GetType();                  if (type == this.BackingType)             {                 return true;             }                  return false;         }          ...          public Type BackingType         {             get             {                 switch (this.TypeAlias)                 {                     case PropertyType.Integer:                         return typeof(long);                     case PropertyType.Float:                         return typeof(double);                     case PropertyType.String:                         return typeof(string);                     default:                         return null;                 }             }         }      I then have three `IPropertyType`: `StringPropertyType`, `IntegerPropertyType` and `FloatPropertyType` where each time, the property `PropertyTypeAlias is set to one of the enum values.` I can now add my IPropertyType to `IProperty` types:               public interface IProperty     {         string Alias { get; }              /// If we want to limit the property to discrete values.         Dictionary<string, object> AllowedValues { get; }              bool HasLimits { get; }              bool HasValue { get; }              bool IsReadOnly { get; }              /// Callback for HW operations using the property value.         Func<PropertyFuncType, bool> PropertyFunction { set; }              PropertyType TypeAlias { get; }              object Value { get; set; }              void AddAllowedValue(string alias, object value);              void ClearAllowedValues();              // On numeric properties, it might be usefull to limit the range of values.         void SetLimits(object lowerLimit, object upperLimit);              // These will do stuff on the HW...         bool TryApply();              bool TryUpdate();     }      Here, the Value setter will run the validation on input value as defined by the `IPropertyType`. `IProperty` is almost fully implemented in `PropertyBase` which also has a field of `IPropertyType` which gets set upon instance creation (and cannot be changed thereafter; a property cannot change type. From the base class e.g.:                   public object Value         {             get             {                 return this.storedvalue;             }                  set             {                 if (this.propertyType.IsValueTypeValid(value) && this.IsValueAllowed(value))                 {                     this.storedvalue = value;                 }             }         }      That only leaves specific `IProperty` classes: `StringProperty`, `IntegerProperty` and `FloatProperty` where there is only one override, `SetLimits()` because it relies on comparison of values. Everything else can be in the base class:               public override void SetLimits(object lowerlimit, object upperlimit)         {             // Is false by default             this.HasLimits = false;                  // Makes no sense to impose limits on a property with discrete values.             if (this.AllowedValues.Count != 0)             {                 // If the passed objects are in fact doubles, we can proceed to check them.                 if (this.IsValueTypeValid(lowerlimit) && this.IsValueTypeValid(upperlimit))                 {                     // In order to allow comparison we need to cast objects to double.                     double lowerdouble = (double)lowerlimit;                     double upperdouble = (double)upperlimit;                          // Lower limit cannot be bigger than upper limit.                     if (lowerdouble < upperdouble)                     {                         // Passed values are OK, so set them.                         this.LowerLimit = lowerdouble;                         this.UpperLimit = upperdouble;                              this.HasLimits = true;                     }                 }             }         }      This way, I think I have a system that allows me to have a collection of `IProperty` that can actually hold data of different types (int, float or string) where for each type of `IProperty` I have the ability to implement value limits etc (i.e. stuff that is different, depending on the data type)... However, I still have the impression that there are either better ways to do this sort of thing or that I am over engineering things. Therefore, any feedback on this is still welcome. **EDIT 2** After more searching online I believe the last bits of code posted here in the previous edit are leaning towards the Adaptive Object Model "pattern" (if it really is that). However, most resources on this topic seem to be quite old and I'm wondering if there are now better ways to achieve these types of things.


What are some small, but extendable game ideas to use for inspiration?

I recently came across the game Dopewars(or more generically, Drugwars). Now this is an extremely simple game to implement. A trivial basic implementation could be done in a couple of days, at the most. And it's extremely extendable. Now, my question is what other games are out there that follow this same kind of "difficulty level" for implementation? A game that is actually entertaining, yet trivial to implement, and can easily be extended?


Can jQuery be used server side?

I know that you can use JavaScript server side with node.js, but can we use jQuery for backend as well? Or will I just have to learn CoffeeScript instead of jQuery?


How do browsers paint a render tree to the screen?

I'm interested in building a browser-like rendering engine. I understand a bit about how OpenGL and GUI toolkits work. But how do browsers actually put pixels on the screen? Are they like software rasterizers that scan every line and paint whatever's in the render tree? Or do they act like GUI toolkits and call functions to display elements at certain coordinates? Are there any libraries that focus specifically on the painting portion of the browser's critical rendering path?


Best RAD Tools for Web Application

I am planning to develop a web based **invoicing** application. It will be used by individuals to log and review their invoices. Their data must be saved to a common database but kept separate from other logins (ie data must not shared across users/logins). I suspect I will need the following...   1. a login page / authentication   2. forms to enter an individual's unique customers and items   3. a form to enter invoices   4. solid reporting tools / dashboard capabilities The current knowledge base is Microsoft suite (ie C#, .Net) **Can anyone advise the best RAD Tools / environment to achieve this outcome? Cheers!**


How to connect a Django app with a Java Web app using JMS

I'm dealing with my DB systems course project, it's a stock exchange simulation app using Oracle 10g, the deal is that the support is for Java, but i'm going to do this in Python. The last iteration for the project is to connect two apps using message queues (MQ Protocols), if both apps are in Java the TA proposed to connect them using JMS, can you advise me on how to connect a Django app (my app) with a Java app (partner's app). I have found that MQ Protocol is based on a universal standard, so that must not be a hard problem to solve. Another option i've looked is Spring Pytthon, a framework that facilitates this connection. So ehat is the best option.


In Agile, should I create a code-review task?

My team uses Agile as a development approach. Currently, each task has four states which are todo, in progress, testing, and done. We've just started doing code reviews, and I wonder if I need to create a code-review task or I should add time for code-review to the estimation?


How to execute a file within a subdirectory

So I have a small setup file that needs to install a few run-time files. The files are located within sub directories of the root of the drive. The drive letter will be different on every customers machine, so I was trying this and several other methods to no avail.                           // File is being ran from D:\ "eg: D:\setup.exe"                 // All my runtimes are in the Tools\Runtime direcorties                 string path = Directory.GetCurrentDirectory();                 string ext = "/q /norestart";                 string location = "\\Tools\\Runtimes\\Net\\";                 string step1 = "dotnetfx35.exe";                 var process = Process.Start(path + location + step1 + ext);                 process.WaitForExit();      As you pros and more experienced programmers know, for some reason... It doesn't work I keep getting file not found.


What's the problem with Scala's XML literals?

In this post, Martin (the language's head honcho) writes: > [XML literals] Seemed a great idea at the time, now it sticks out like a > sore thumb. I believe with the new string interpolation scheme we will be > able to put all of XML processing in the libraries, which should be a big > win. Being interested in language design myself, I'm wondering: Why does he write that it was a mistake to incorporate XML literals into the language? What is the controversy regarding this feature?


Best practices for geolocation

We are writing a flight search engine. We want to pre-fill the departure airport for mobile users with the closest one to their location. To do that, our plan is to   1. Find a list of airports with their latitude/longitude.   2. Find the user geolocation using something like HTML5 Geolocation (which asks the user for permission).   3. Calculate the distance between the user's location and every airport to find the closest one.   4. Fill the departure form. Is this a standard way of proceeding? I am a junior programmer and I am not used to this kind of problem. Is there any obstacle I should bear in mind while developing my solution? I have the feeling the algorithm to calculate the distance between one point and 300 locations might get a bit heavy.


PHP - Internal APIs/Libraries - What makes sense?

I've been having a discussion lately with some colleagues about the best way to approach a new project, and thought it'd be interesting to get some external thoughts thrown into the mix. Basically, we're redeveloping a fairly large site (written in PHP) and have differing opinions on how the platform should be setup. **Requirements:** The platform will need to support multiple internal websites, as well as external (non-PHP) projects which at the moment consist of a mobile app and a toolbar. We have no plans/need in the foreseeable future to open up an API externally (for use in products other than our own). **My opinion:** We should have a library of well documented native model classes which can be shared between projects. These models will represent everything in our database and can take advantage of object orientated features such as inheritance, traits, magic methods, etc. etc. As well as employing ORM. We can then add an API layer on top of these models which can basically accept requests and route them to the appropriate methods, translating the response so that it can be used platform independently. This routing for each method can be setup as and when it's required. **Their opinion:** We should have a single HTTP API which is used by all projects (internal PHP ones or otherwise). **My thoughts:** To me, there are a number of issues with using the sole HTTP API approach:   1. It will be very expensive performance wise. One page request will result in several additional http requests (which although local, are still ones that Apache will need to handle).   2. You'll lose all of the best features PHP has for OO development. From simple inheritance, to employing the likes of ORM which can save you writing a lot of code.   3. For internal projects, the actual process makes me cringe. To get a users name, for example, a request would go out of our box, over the LAN, back in, then run through a script which calls a method, JSON encodes the output and feeds that back. That would then need to be JSON decoded, and be presented as an array ready to use.   4. Working with arrays, as appose to objects, makes me sad in a modern PHP framework. **Their thoughts (and my responses):**   1. Having one method of doing thing keeps things simple. - _You'd only do things differently if you were using a different language anyway._   2. It will become robust. - _Seeing as the API will run off the library of models, I think my option would be just as robust._ **What do you think?** I'd be really interested to hear the thoughts of others on this, especially as opinions on both sides are not founded on any past experience.


Releasing a project under GPL v2 or later without the source code of libraries

I wrote a system in Java that I want to release under the terms of GPL v2 or later. I've used Apache Maven to deal with all the dependencies of the system, so I don't have the source code of any of the libraries used. I've already checked, all the libraries were released under GPL-compatible licenses (Apache v2, 3-clause BSD, MIT, LGPL v2 and v2.1). Can I distribute my work under GPLv2 or later and provide the libraries on the same package as **separate works** , without having to apply GPL on them (as stated by **GPLv2 sec 2** ), even if they are necessary to compile and run the system? If so, I know I am bound only by the original licenses of each one, and than I know what to do.


Is it possible to access javascript return value outside of function?

How would one access javascript function's return value outside of the function? For example could you tell a function to return something somewhere else in the code? Theoretical example:               milkmachine = function(argument){         var r;         var k;         //do something with arguments and variables         return r;     }     var rainbow = milkmachine(); //rainbow == r     milkmachine.return(k);     var spectrum = milkmachine(); //spectrum == k


What is the correct order to read these books?

I'm a junior C# developer, I learned at home and now I got my first job :) I want to buy these books. But what is the correct order to read these books? Code Complete: A Practical Handbook of Software Construction Clean Code: A Handbook of Agile Software Craftsmanship Pragmatic Programmer


Is it best practice to create a back door for testing a web service?

We have a public RESTful web service which exposes functionality to third parties. We are writing automated tests against it. In order to set up all scenarios on it we need to change the data behind it. We also have a private RESTful web service which exposes functionality to other systems owned by us. However, this web service does not expose endpoints required to set up all the scenarios for the public web service. In this circumstance is it best to create extra endpoints, not needed in normal operational behaviour, on the private web service in order to support the testing of the public one? Or should we set up our data using other means such as sending SQL commands?


Dealing with Fanboys

We've all probably met someone like this, that developer who just _knows_ that his language is the one true language and won't shut up about it. How do you deal like someone like this? I don't want to offend anyone (especially since the fanboy in my workplace is the senior developer). But I want to be able to use my own choice of scripting language when I have to write a throwaway script that never makes it to the repository and no one else need know existed. Thoughts that I had to dealing with this:   1. Laugh it off - "Haha yeah maybe language X is a bit easier, I guess I'm a masochist!"   2. Go with it - I'd really prefer to avoid this as I can't afford the drop in productivity associated with picking up a new language.   3. Hide my language - Become a closet programmer and hide my monitor whenever I'm scripting or automating something. What would you suggest for this situation?


What is the best practice, point of view of well experienced developers

My manager pushes me to use his self defined best practices. All of these practices are based on is own assumptions. I disagree with them and I would like to have some feedback of well experienced people about these practices. I would prefer answers from people involved in the maintenance of huge products and people whom have maintained the product for years. Developers with 15+ years of experience are preferred because my manager has that much experience himself. I have 7 years of experience. * * * ## Here are the practices he wants me to use:   * never extends classes, use composition and interface instead because extending classes are unmaintainable and difficult to debug.    * What I think about that   Extend when needed, respect "Liskov's Substitution Principle" and you'll never be stuck with a problem, but prefer composition and decoration. I don't know any serious project which has banned inheriting, sometimes it's impossible to not use that, i.e. in a UI framework. Design patterns are just unusable. * * *   * In PHP, for simple use cases (for example a user needs a web interface to view a database table), his "best practice" is: copy some random php code wich we own, paste and modify it, put html and php code in same file, never use classes in PHP, it doesn't work well for small jobs, and in fact it doesn't work well at all, there is no good tool to work with. Copy & paste PHP code is good practice for maintenance because scripts are independent, if you have a bug somewhere you can fix it without side effects.   * What I think about that:   NEVER EVER COPY code or do it because you have five minutes to deliver something, you will do some refactoring after that. Copy & paste code is a beginners error, if you have errors you'll have the error everywhere any time you have pasted it's a nightmare to maintain. If you repsect the "Open Close Principle" you'll rarely get edge effects, use unit test if you are afraid of that. For small jobs in PHP use at least something you get or write the HTML separately from the PHP code and reuse it any time you need it. Classes in PHP are mature, not as mature as other languages like python or java, but they are usable. There is tools to work with classes in PHP like Zend Studio that work very well. The use of classes or not depends not on the language you use but the programming paradigm you have choosen. I'm a OOP developer, I use PHP5, why do I have to shoot myself in the foot? * * *   * When you find a simple bug in the code, and you can fix it simply, if you are not working on the code where you have found it, never fix it, even if it takes 5 seconds.   * He says to me his "best practices" are driven by the fact that he has a lot of experience in maintaining software in production (14 years) and he now knows what works and what doesn't work, what the community says is a fad, and the people advocating such principles as never copy & paste code, are not evolved in maintaining applications.   * What I think about that:   If you find a bug fix it if you can do it quickly inform the people who've touched that code before, check if you have not introduced a new bug, ideally add a unit test for it. I currently work on a web commerce project, which serves 15k unique users per day. The code base has to be maintained and has been maintained this way since 2005. * * * Ideally you include a short description of your position and experience in terms of years effectively maintaining an application which has been in production for real.


What is Java used for these days?

Java is fifteen years old. It started life as an alternative to C++ with a comprehensive standard library. Riding on the coattails of the Internet boom, it was popular for writing web applets. Its supposed portability was touted as a way to write desktop apps that would run on any platform. Now it's 2010. Applets are long gone. Desktop apps are giving way to web and mobile apps. Scripting languages are very popular, as is Flash, especially among web-centric developers. People have been chanting "Java's death is near" for several years. Yet a quick job search shows that Java is still a desired skill among programmers. So what is Java used for these days? What kinds of apps are you writing in Java? This should give us an idea of the "state of Java" today. Has the Java tide shifted from Swing desktop apps to Android mobile apps? If you write programs in a JVM language (such as Scala or Groovy), mention it.


Do sigils make source code easier to read?

In most programming languages, variables do not have identifying characters like they do in PHP. In PHP you must prefix a variable with the `$` character. Example;                var $foo = "something";      echo $foo;      I'm developing a new scripting language for a business application, and my target users do not have a programming background. Do these characters make code easier to read and use? One reason PHP uses the `$` is because without it PHP can't tell if a name is a function reference or variable reference. This is because the language allows strange references to functions. So the `$` symbol helps the parser separate the namespace. I don't have this problem in my parser. So my question is purely on readability and ease of use. I have coded for so many years in PHP that when I see `$foo` it's easy for me to identify this as a variable. Am I just giving a bias preference to this identifier?


What resources are there for facial recognition

I'm interested in learning the theory behind facial recognition software so that I can hopefully implement it in the future. Not just face tracking, but being able to recognize individuals. What papers, books, libraries, or source is available so that I can learn more about the subject? I have found libface which seems to use eigenfaces for recognition. If there are any practitioners out there, please share any information that you can. Edit: I found a good post on the subject here.


Entity Framework with large systems - how to divide models?

I'm working with a SQL Server database with 1000+ tables, another few hundred views, and several thousand stored procedures. We are looking to start using Entity Framework for our newer projects, and we are working on our strategy for doing so. The thing I'm hung up on is how best to split the tables into different models (EDMX or DbContext if we go code first). I can think of a few strategies right off the bat:   * **Split by schema**   We have our tables split across probably a dozen schemas. We could do one model per schema. This isn't perfect, though, because dbo still ends up being very large, with 500+ tables / views. Another problem is that certain units of work will end up having to do transactions that span multiple models, which adds to complexity, although I assume EF makes this fairly straightforward.   * **Split by intent**   Instead of worrying about schemas, split the models by intent. So we'll have different models for each application, or project, or module, or screen, depending on how granular we want to get. The problem I see with this is that there are certain tables that inevitably have to be used in every case, such as User or AuditHistory. Do we add those to every model (violates DRY I think), or are those in a separate model that is used by every project?   * **Don't split at all - one giant model**   This is obviously simple from a development perspective but from my research and my intuition this seems like it could perform terribly, both at design time, compile time, and possibly run time. What is the best practice for using EF against such a large database? Specifically what strategies do people use in designing models against this volume of DB objects? Are there options that I'm not thinking of that work better than what I have above? Also, is this a problem in other ORMs such as NHibernate? If so have they come up with any better solutions than EF?


Is deserializing complex objects instead of creating them a good idea, in test setup?

I'm writing tests for a component that takes very complex objects as input. These tests are mixes of tests against already existing components, and test- first tests for new features. Instead of re-creating my input objects (this would be a large chunk of code) or reading one from our data store, I had the thought to serialize a live instance of one of these objects, and just deserialize it into test setup. I can't decide if this is a reasonable idea that will save effort in long run, or whether it's the worst idea that I've ever had, causing those that will maintain this code will hunt me down as soon as they read it. Is deserialization of inputs a valid means of test setup in some cases? To give a sense of scale of what I'm dealing with, the size of serialization output for one of these input objects is 93KB. Obtained by, in C#: `new BinaryFormatter().Serialize((Stream)fileStream, myObject);`


Wiki/markup in enterprise as documentation

Why it is less common to use wiki/markup in enterprise as documentation? They use Word document instead. Wiki/markup are in text format, which is version control friendly.


Macintosh OS10.8 user experience with 'identified developer' downloads?

I work on a Windows/Mac cross platform application that is sometimes downloaded from web sites. It is sometimes re-branded by and sold by third parties. I'm the 'windows guy', my Mac counterpart is on vacation. I'm getting some questions from a customers about what the Mac user experience will be if we sign the Mac installer with an Apple Developer certificate in our build system with our company name. For some reason this customer doesn't want to sign the app themselves, but doesn't want our company name to pop up in front of the user. Assuming the user's OS 10.8 Gatekeeper is set to allow downloads from both the Apple App Store and from 'identified developers', does the user see any warning dialog that provides certificate information similar to he Windows User Access Control prompts? In my tests it looks like internet downloaded Apple signed apps are just trusted by OS10.8, and will run without anything resembling a Windows UAC prompt. The user experience seems to be: 1) Download application from internet signed by an 'Apple identified developer'. 2) Click the application on web browser download list or using finder. 3) Application installer runs with no warning or caution dialogs. Is this correct? Also, is there some way on OS10.8 for the user to view in human readable form the 'identified developer' certificate information of a signed file?


Using captured non-local variables in C++ closures

On this wikipedia page I have found the following sentence regarding closures in C++11: > C++11 closures can capture non-local variables by copy or by reference, but > without extending their lifetime. Does this mean that an existing closure might refer to a non-local variable that has already been de-allocated? In such a case, is there any special care / best practice that one has to follow when using captured non-local variables inside a C++ closure?


Requesting quality analysis test cases up front of implementation/change

Recently I have been assigned to work on a major requirement that falls between a change request and an improvement. The previous implementation was done (badly) by a senior developer that left the company and did so without leaving a trace of documentation.      Here were my initial steps to approach this problem:     1. Considering that the release date was fast approaching and there was no time for slip-ups, I initially asked if the requirement was a "must have". Since the requirement helped the product significantly in terms of usability, the answer was "If possible, yes".   2. Knowing the wide-spread use and affects of this requirement, had it come to a point where the requirement could not be finished prior to release, I asked if it would be a viable option to thrash the current state and revert back to the state prior to the ex-senior implementation. The answer was "Most likely: no".   3. Understanding that the requirement was coming from the higher management, and due to the complexity of it, I asked all usability test cases to be written prior to the implementation (by QA) and given to me, to aid me in the comprehension of this task. This was a big no-no for the folks at the management as they failed to understand this approach. Knowing that I had to insist on my request and the responsibility of this requirement, I insisted and have fallen out of favor with some of the folks, leaving me in a state of "baffledness". Basically, I was trying a test-driven approach to a high-risk, high-complexity and must-have requirement and trying to be safe rather than sorry. Is this approach wrong or have I approached it incorrectly? P.S.: The change request/improvement was cancelled and the implementation was reverted back to the prior state due to the complexity of the problem and lack of time. This only happened after a 2 hour long meeting with other seniors in order to convince the aforementioned folks.