why not use unmanaged safe code in c#

There is an option in c# to execute code unchecked. It's generally not advised to do so, as managed code is much safer and it overcomes a lot of problems. However I am wondering, if you're sure your code won't cause errors, and you know how to handle memory then why (if you like fast code) follow the general advice? I am wondering this since I wrote a program for a video camera, which required some extremely fast bitmap manipulation. I made some fast graphical algorithms myself, and they work excellent on the bitmaps using unmanaged code. Now I wonder in general, if you're sure you don't have memory leaks, or risks of crashes, why not use unmanaged code more often ? PS my background: I kinda rolled into this programming world and I work alone (I do so for a few years) and so I hope this software design question isn't that strange. I don't really have other people out there like a teacher to ask such things.


Get rid of long/Complex if..else statements using Chain of Responsibility?

I've an HttpHandler, which allows users to login to a system by passing in an encrypted code. Inside the `ProcessRequest` it performs quite a few steps.   1. Retrieve the encrypted code from request (could be in Form/X-Header/Query)   2. Decrypt it. (Results in an JSON string)   3. Deserialize to a dynamic type   4. Determine the type of request, could be login/register/activate   5. Validate request   6. Load user subscription   7. Load User entity   8. If Req.Type = Login -> Login using FormsAuth   9. If Req.Type = Register -> Create user   10. If Req.Type = Register -> Send Activation email This goes on. Currently this is something like a long if/else statement which I'm trying to refactor. I'm thinking of using the Chain Of Responsibility pattern to convert these steps in if/else to a chain which executes sequentially. However, this will be different from original CoR as only last few steps will actually "handle" the request, first steps will just do some pre-processing and make stage for last steps to perform it's job. My main problem is, different steps in the chain will work on different input data. First few steps (Decryption, Deserialization, etc) will work on strings while latter half should ideally work on deserialized dynamic object. I don't like the way it sounds. Am I trying to fit a round lid to an square bottle? Is this not a scenario where CoR can/should be applied? Are there any other patterns/strategies I could use to solve such scenarios. I thought of using the decorator pattern as well, but that doesn't suite me very well, as I'd like to be able to switch certain steps in and out (ex: email activation) for some scenarios. NOTE: I've seen this question as well, but not sure if it answers my question.


Correct way to inject dependencies in Business logic service?

Currently the structure of my application is as below Web App --> WCF Service (just a facade) --> Business Logic Services --> Repository -> Entity Framework Datacontext Now each of my Business logic service is dependent on more than 5 repositories ( I have interfaces defined for all the repos) and I am doing a Constructor injection right now(poor mans DI instead of using a proper IOC as it was determined that it would be a overkill for our project). Repositories have references to EF datacontexts. Now some of the methods in the Business logic service require only one of the 5 repositories, so If I need to call that method I would end up instantiating a Service which will instatiate all 5 repositories which is a waste. An example:               public class SomeService : ISomeService     {        public(IFirstRepository repo1, ISecondRepository repo2, IThirdRepository repo3)        {}             // My DoSomething method depends only on repo1 and doesn't use repo2 and repo3        public DoSomething()        {             //uses repo1 to do some stuff, doesn't use repo2 and repo3        }                public DoSomething2()        {          //uses repo2 and repo3 to do something, doesn't require repo1        }             public DoSomething3()        {          //uses repo3 to do something, doesn't require repo1 and repo2        }     }      Now if my I have to use `DoSomething` method on `SomeService` I end up creating both IFirstRepository,ISecondRepository and IThirdRepository but using only IFirstRepository, now this is bugging me, I can seem to accept that I am un-necessarily creating repositories and not using them. Is this a correct design? Are there any better alternatives? Should I be looking at Lazy instantiation `Lazy<T>` ?


Is there any benefit by switching from C# to Java?

I've been a .NET developer for about six years. In those six years, I've worked at exactly **one** .NET shop that followed any kind of actual design pattern or industry best practice. That realization has frustrated me where I'm at the point of considering making a switch to Java and leveraging my C# experience because the Java community seems to have a larger handle on proper software engineering than the .NET community, which seems more focused on RAD techniques and quasi-procedural code and don't want to improve at all. For example, the average Java shop is probably using an MVC framework like Spring, Seam or venerable old Struts, is using Hibernate, is probably writing unit tests, knows how to use source control properly, and while there's the danger of the architecture astronaut is more than likely applying design patterns and following good practices like the SOLID principles. In contrast, the average .NET shop uses untyped DataSets, writes all the code to solve a problem in event handlers of WebForms, thinks testing means loading up the built-in web server and playing with the application, if they use source control at all use something like Visual SourceSafe and think it's great, and has no idea what the single responsibility principle even means or why it's a _good thing_. Attempts at introducing things like ORMs, design patterns, unit testing is usually met with a blank stare or outright rejection due to not even understanding why those things are better than the debugger or writing code in an event handler of a widget - it's like talking to a brick wall. I am aware of "ALT.NET" (I follow it myself), but I am finding an environment that knows about that, let alone follows it, and it seems to be like finding needle in a haystack, and trying to change an organization to use it has always ended badly for me, to the point where I've actually been shown the door and let go for wanting to do things better than the company had been doing before I joined. Would there be **any** benefit at all to my trying to leverage C# skills and make a transition to Java? I'm running out of options trying to find a .NET shop that actually follows real software engineering concepts instead of just throwing out code, and I'm starting to think my chances of finding that kind of place will greatly increase if I'm not using a technology stack that pushes the opposite as the right way.


How do you get the usernames/passwords onto a STUN or TURN server for long-term credential authentication?

The STUN and TURN specifications allow for client authentication using usernames and passwords, and call this authentication via long-term credentials. In fact, TURN requires that clients authenticate by this means. However, I would assume that almost all deployments run their STUN or TURN servers separately from their database server. For example, for a VOIP application that uses TURN servers, presumably all of the user data would be stored in a database, user account management might be primarily handled by a web server, while the clients would still need to be able to authenticate into a separate TURN server. What's the best practice for the STUN/TURN server to access the usernames and passwords from the database to authenticate clients? If most deployments or your solution relies upon a particular STUN/TURN server implementation that supports specific features, any recommendations as to STUN/TURN servers would be appreciated as well.


Can I get a job in the aerospace industry as a software developer if I'm self-taught?

I'm an employed, self-taught application developer. Although I love development, I'm fairly bored. To offset this (and because I love to learn), I study advanced mathematics, physics, engineering and advanced topics in computer science, among other things. I'm grateful for the good job I have, it pays the bills and feeds my family, but I want to do more. I'm very interested in the aerospace industry, but lack an engineering or computer science degree. I would like to develop software that aids in the design of aircraft, or software that contributes to the functionality or operation of an aircraft. I feel like I can hold my own during discussions of these topics, and also feel like I possess enough knowledge at this point to make a foray into the field. I had a troubled youth. I'm married now with children, and have settled down, but I'm still fairly young. Again, I'm grateful to have a solid job where I can do what I love and get paid well, but I feel like the stupid decisions that I made during my youth, combined with my decision to actually learn computer programming instead of going to college have really smoked me, as far as career opportunities go. Recently, I've been working on a jet engine design suite and test simulator using Haskell. Maybe if I finish this, I can show it to someone and get a job despite my lack of degree and troubled past? I can't unrealistically assume it would be worth much to a giant like Lockheed, but maybe they will think it is cool or something. Is there anyone out there that can relate, and if so, were you able to miraculously able to finagle a way into this field, or another advanced field? What can I do to make it in this industry? Do I need to enroll in college, or is there some sort of hack I can employ? Are you an aerospace software engineer? What is this field like in reality? Need an intern?


Reasons for C++ Prototyping

I'm a beginning programmer, trying to get a grasp on everything, so pardon the probably mundane theoretical question: I see in a C++ tutorial that prototyping is needed to let the compiler know that a function(?) is coming up and not to throw up any errors. Why does it not search throughout a document to find the function it's looking for? Maybe the question I'm asking is; what is the purpose for prototyping? And can it be used in other languages?


Can the strategy pattern be overused?

Example: A file, representing a serialized version of an object, needs to be read and deserialized. It would simple to implement this if we only cared about a single serialization format, but many such formats exist (JSON, YAML, etc.). One way to handle this would be to create an abstract serializer type/interface with methods such as `deserializeToArray`, `deserializeToObject`, and so on, and pass this interface as a dependency in order to decouple any dependent classes from any concrete implementation. This could be further generalized by having the serialization methods actually be implementations of another interface, which we'll call `Transform`. So here we're effectively using the Strategy pattern once again, this time encapsulating a family of algorithms for transforming one kind of data into another desired object or array format. Is this perhaps an overuse of the Strategy pattern? Are there better ways to structure things here or patterns more fitting for this sort of problem? Are there disadvantages to using several nested Strategy patterns as in this example?


Eliminating tab characters in a new language

I'm working on a new programming language, which determines structure with indentation instead of braces in the manner of Python and CoffeeScript. Obviously placing lines indented with spaces next to lines indented with tabs will mess up that kind of syntax, so I'm disallowing that - any given source file must use one or the other, not both. I'm wondering whether it would be better to mandate one or the other across the board just to eliminate the possibility of time wasted on argument? Spaces seem to be slightly more popular than tabs, so if I were going to do that, I suppose I would mandate indenting with spaces (despite the fact that I personally prefer to use tabs). Are there any situations where eliminating the possibility of indenting with tabs, would cause a problem?


Designing persistence schema for BigTable on AppEngine

I have tried to design the datastore schema for a very small application. That schema would have been very simple, if not trivial, using a relational database with foreign keys, many-to-many relations, joins, etc. But the problem was that my application was targeted for Google App Engine and I had to design for a database that was not relational. At the end I gave up. Is there a book or an article that describes design principles for applications that are meant for such databases? The books that I have found are about programming for App Engine and they don't spend many words about database design principles.


Git workflow for small teams

I'm working on a git workflow to implement in a small team. The core ideas in the workflow:   * there is a shared project master that all team members can write to   * all development is done exclusively on feature branches   * feature branches are code reviewed by a team member other than the branch author   * the feature branch is eventually merged into the shared master and the cycle starts again The article explains the steps in this cycle in detail: https://github.com/janosgyerik/git-workflows-book/blob/small-team- workflow/chapter05.md Does this make sense or am I missing something?


Is making webpage basing on ajax and modal a good idea?

Hello I'm new to web development and I'm making simple webpage for managing parts. I came with idea of making something like "One page". Render layout once and later replace body content with ajax calls. Because of each "part" of the webpage like StorageList consists of views `like create,details,edit etc` I decided to show those pages in modal windows over the main page and get this: ![enter image description here](http://i.stack.imgur.com/Uh4rp.png) These modals are also loaded using ajax. As you can see "Ajax. Ajax everywhere" :) And now my question is my approach good or making this page basing on the ajax calls and dynamically loaded content will cause me any problems in future in maintaining?


What are some reasonable stylistic limits on type inference?

C++0x adds pretty darn comprehensive type inference support. I'm sorely tempted to use it everywhere possible to avoid undue repetition, but I'm wondering if removing explicit type information all over the place is such a good idea. Consider this rather contrived example: `Foo.h`:               #include <set>          class Foo {     private:              static std::set<Foo*> instances;          public:              Foo();         ~Foo();              // What does it return? Who cares! Just forward it!         static decltype(instances.begin()) begin() {             return instances.begin();         }              static decltype(instances.end()) end() {             return instances.end();         }          };      `Foo.cpp`:               #include <Foo.h>     #include <Bar.h>          // The type need only be specified in one location!     // But I do have to open the header to find out what it actually is.     decltype(Foo::instances) Foo::instances;          Foo() {              // What is the type of x?         auto x = Bar::get_something();              // What does do_something() return?         auto y = x.do_something(*this);              // Well, it's convertible to bool somehow...         if (!y) throw "a constant, old school";              instances.insert(this);          }          ~Foo() {         instances.erase(this);     }      Would you say this is reasonable, or is it completely ridiculous? After all, especially if you're used to developing in a dynamic language, you don't really _need_ to care all that much about the types of things, and can trust that the compiler will catch any egregious abuses of the type system. But for those of you that rely on editor support for method signatures, you're out of luck, so using this style in a library interface is probably really bad practice. I find that writing things with all possible types implicit actually makes my code a lot easier for me to follow, because it removes nearly all of the usual clutter of C++. Your mileage may, of course, vary, and that's what I'm interested in hearing about. What are the specific advantages and disadvantages to radical use of type inference?


Choice between 1-dimensional and 2-dimensional array

I'm implementing the Chessboard class to represent the chessboard. I've to implement the **transformations** (reflections and rotations) on the chess board possible. The possible transformations includes the combination of:                1. Vertical Reflection      2. Horizontal Reflection      3. Diagonal Reflection      Thus, we've **8** possible transformations for chess board. There are **64** squares on the Chessboard numbered **[0..63]**. Thus, to represent the total resulting values after the transformations is **8*64** (No.of Transformations * Chessboard_Size). There are two fundamental ways to represent the **transformed_board** using Arrays:               One-Dimensional Array with transformed_board[8*64]     Two-Dimensional Array with transformed_board[8][64]      **Questions** :   * Which approach is better?   * What are the pros and cons of each approach?   * How will effect the performance with respect to time factor?


How can a student programmer improve his teamwork skill?

I am a student right now. Recently, I am working in a project as a leader with three other students. Due to the lack of experience, our project is progressing slowly and our members are frustrated. They do not feel sense of accomplishment in the project. I am pressured and frustrated, too. But as a team leader, I think I need to push them. But I do not know how to do. Do I help them solve coding problem or just encouragement? But if I pay too much attention on it, it would slow down my own progress. It is a not technical question, but it is very common in software development. I hope veteran programmers would give me some suggestions. Thanks!


Why aren't Entities allowed to reference other entities inside an aggregate except the root?

I have read in several places this following rule concerning Aggregates: > Entities in one aggregate can hold references to any other Aggregate Root, > but never to an Entity or Value Object inside the other Aggregate. What can go wrong if an Entity was holding a direct reference to an entity in another Aggregate root? Can someone please explain why such rule is important? and preferably illustrate with an example, please?


Javascript Naming Convention

I've been using Javascript for quite a while, but I've always ignored the common naming conventions that I see online (camelCase). I know it all depends on the developer's preference, but why camel case for Javascript? I'm originally a PHP programmer and I kind of have my own naming convention and I use it everywhere I can, including Javascript. Well, I have to sacrifice my naming convention when it comes to Java though as the program flow depends on those names sometimes. Anyway, my convention goes like:               var variable_name = 'I always use underscores to separate words';     var another_variable = 'I also tend to use single quotes all the time';          function epic_name_here (some_paramaters ...)     {          // Curly brackets on separate lines         do_something();     }          if (x == y)     {         // Same goes here     }      I have taken this kind of code-writing style from working a lot with phpBB, their docs encourage people to use this style. Why do I see a lot of people writing Javascript in camelCase? And will it be a problem if I don't use it?


Several interdependent models, each with several data sources — how to avoid hell and nightmare

I'm currently working on a project that requires a complicated model structure and I'm struggling with picking the right architecture. First of all, there are several interdependent models. Change in one model can trigger changes in several other models. For example, user inputs a query, first model checks the database for type of the query and the second model requests its data depending on that query type. Secondly, each model can have several data sources. Data sources are used conditionally, dependent on system configuration. The app needs to function seamlessly, — for example, if one data source doesn't return required information, model must try and use another one. An important thing also is that the codebase will eventually be expanded with other models. So models, data sources etc. must be very modular. Currently there are several ways I can organise the model layer:   1. 'Dumb' models re-created by factory objects when input data (or a related model) changes. Model dependencies are resolved in an operation object, encapsulating the whole update routine. Operation object is configured and run by a domain model. I don't know where to inject a data source though.   2. 'Smart' models with update logic encapsulated in them. Each model queries a sort of a mapper/data-source-manager, which works as a proxy for different data sources. Models report their updates to a domain model. Dependencies are resolved by a model-controller or dependency manager object. Which architecture is more appropriate here? I'm leaning towards the first one as it is (to my mind) better to work with immutable models, updating the whole tree on change of input. This approach gives several benefits: for example it is easier to serialize as the presence of model equals to a finite state. But I'm really unsure about data sources...


Is Microsoft's Visual Studio Express 2012 for Windows Desktop no longer free? Or, why does it say product has expired?

I wanted to try this product when I heard there was a free version of Visual Studio. So I downloaded something from Microsoft called "Visual Studio Express 2012 for Windows Desktop" and I never really used it much. Now when I start it, for the first time in awhile, it says that the product has expired. I was under the impression that it was simply freeware, so is it true that there is no permanently free version of this IDE which anyone has the freedom to download without cost? My theory is that Microsoft's website is finicky about easily finding what you want there. So maybe I just downloaded the wrong thing. I went to this page: Microsoft Under some purple header text titled "Visual Studio Express 2012" and some sub-text that says "Visual Studio Express 2012 products provide free development tools for creating modern applications on the latest platforms." I feel like it has just got to be the right place to download the IDE. So I clicked for Windows Desktop, downloaded it, installed it. Product has expired. Conclusion? It is not free. I thought I would ask here if this is true so that I can be certain. I still think Microsoft is just finicky though. Maybe I should have downloaded 2010?


1 Interface 2 Implementations and an EJB exception

In my JavaEE project I have an interface like this:               @Local     public interface DataAccess { ... }      And two stateless beans implementing it:               @Stateless     public class DataAccess_Online implements DataAccess { ... }          @Stateless     public class DataAccess_Offline implements DataAccess { ... }      And I get the exception: > Cannot resolve reference Local ejb-ref.... because there are 2 ejbs in the > application with interface ...DataAccess The problem is clear, there may only be one class implementing DataAccess. But it would be convenient if I could use two. In the client I want to work on the Interface DataAccess only, so I don´t have to distinguish between online/offline in my code, they both offer the same methods. In the client I have an dependency injection:               @EJB     DataAccess da;      And I see how this is a problem with two implementations for DataAccess, but what should I change to make it work? The client always starts with the online version of DataAccess, but after a while he could request the offline version, so the offline version only needs the same interface, if I need a DataAccess injection it will always be the online version. How can I use two implementations of an interface together with @EJB dependency injection?


Is there a major difference between JMF 1.0 and JMF 2.1.1

Alright, this question stems from the fact that there are very few online resources for learning JMF. The books that are available are quite old, some of them out of publication.   This question is an extension to my other question where asked I for the name of a book that I could use to learn JMF.   So, is there a major difference between JMF 1.0 and JMF 2.1.1?   Should I go ahead and buy a book that covers JMF 1.0?


Why did the web win the space of remote applications and X not?

The X Window System is 25 years old, it had it's birthday yesterday (on the 15'th). As you probably are aware of, one of it's most important features is the separation of the server side and the client side in a way that neither Microsoft's, Apples or Wayland's windowing systems have. Back in the days (sorry for the ambiguous phrasing) many believed X would dominate over other ways to make windows because of this separation of server and client, allowing the application to be ran on a server somewhere else while the user clicks and types on her own computer at home. This use obviously still exists, but is marginalized at best. When we write and use programs that run on a server we almost always use the web with it's html/css/js. Why did the web win, and X not? The technologies used for the web (said html/css/js) are a mess. Combined with all the back-end-frameworks (Rails, Django and all) it really is a jungle to navigate thru. Still the web thrives with creativity and progress, while remote X apps do not.


Reasons behind polymorphism related behaviour in java

I read this code somewhere               class Foo {         public int a;         public Foo() {             a = 3;         }         public void addFive() {             a += 5;         }         public int getA() {             System.out.println("we are here in base class!");             return  a;         }     }          public class Polymorphism extends Foo{        public int a;        public Poylmorphism() {            a = 5;        }        public void addFive() {            System.out.println("we are here !" + a);            a += 5;        }             public int getA() {             System.out.println("we are here in sub class!");             return  a;         }              public static void main(String [] main) {             Foo f = new Polymorphism();             f.addFive();             System.out.println(f.getA()); // SOP 1             System.out.println(f.a);      // SOP 2         }     }      For SOP1 we get answer 10 and for SOP2 we get answer 3. Reason for this is that you can't override variables whereas you can do so for methods. This happens because type of the reference variable is checked when a variable is accessed and type of the object is checked when a method is accessed. But I am wondering, just why is it that way? Can anyone explain me what is the reason for this behaviour


Tools like pc-lint or QAC can be used to perform static code analysis on a code base. In my experience the static analysis often yields a huge amount of noise, i.e. warnings on things that are not real bugs but somehow violate one of the rules in a given rule set. Turning off certain rules (either for good in the rule set or via special comments in the code) can be a real cumbersome process. What are the real benefits of static code analysis?


What is your advice for a new recruiter?

Next month a friend of mine is starting a job as a technical recruiter for a temp firm. He will be recruiting lower level temps for a Google/MS/Apple level company. As a largely non technical guy, what advice do you think would be most helpful for him to have? I have seen a number of horror stories about recruiters, so want to help him not to cause any of those in the future.


What is a good speed for a webscraper?

I'm currently working on a webscraper that is going to be processing about 2 million pages in total. But I'm not entirely sure how to benchmark it. Currently it processes about 100,000 pages in an hour at about 2mb/s. It isn't saturating the the bandwidth of the server but I've tried a lot of ways to make it quicker but to no avail. CPU is running 50% or so on average.


Why does Java MessageDigest.getInstance() have a String as a parameter?

I presume it's that way so it could be extended with custom algorithms, but wouldn't it be more convenient to apply, let's say, factory method pattern here and avoid the whole `NoSuchAlgorithmException` thing? Something like:               MessageDigest.getMD5Algorithm();      or               MessageDigest.getInstance(DigestAlgorithmFactory.getMD5Algorithm())      I'm guessing there's a bigger picture here, but I just can't see it.


Looking inside Microsoft's header files

When I open up the some of the often used header files like vector.h or cstdlib.h it just seems like a mess of #ifndefine #define #endif statements. Can anyone decode that mess and give me a glimpse into whats going on in there?


What is a 'Null Terminated String' ?

I have just started reading C++, and I came across a term "Null Terminated String", I read about it but couldn't understand what it actually stands for. I also want to know what is the difference between a c-string(also referred as "Null terminated String") and a c++ string.


Client Portal Review Software

Can anyone share any software/techniques they use when showing clients graphical elements, storyboards, elements, etc. for the web project being worked on? I would like to have a way that the client can log in and see updates to what is going on and see the elements that have been created over time of the project. This could be status updates, creative elements, links to prototypes, wireframes, etc. Thank you in advance for any ideas that have worked best for you.


Development processes, the use of version control, and unit-testing

### Preface I've worked at quite a few "flat" organizations in my time. Most of the version control policy/process has been "only commit after it's been tested". We were constantly committing at each place to "trunk" (cvs/svn). The same was true with unit-testing - it's always been a "we need to do this" mentality but it never really materializes in a substantive form b/c there is no institutional knowledge base to do it - no mentorship. ### Version Control The emphasis for version control management at one place was a very strict protocol for commit messages (format & content). The other places let employees just do "whatever". The branching, tagging, committing, rolling back, and merging aspect of things was always ill defined and almost never used. This sort of seems to leave the version control system in the position of being a fancy file-storage mechanism with a meta-data component that never really gets accessed/utilized. (The same was true for unit testing and committing code to the source tree) ### Unit tests It seems there's a prevailing "we must/should do this" mentality in most places I've worked. As a policy or standard operating procedure it never gets implemented because there seems to be a very ill-defined understanding about what that means, what is going to be tested, and how to do it. ### Summary It seems most places I've been to think version control and unit testing is "important" b/c the trendy trade journals say it is but, if there's very little mentorship to use these tools or any real business policies, then the full power of version control/unit testing is never really expressed. So grunts, like myself, never really have a complete understanding of the point beyond that "it's a good thing" and "we should do it". ### Question I was wondering if there are blogs, books, white-papers, or online journals about what one could call the business process or "standard operating procedures" or uses cases for version control and unit testing? I want to know more than the trade journals tell me and get serious about doing these things. ### PS: @Henrik Hansen had a great comment about the lack of definition for the question. I'm not interested in a specific unit-testing/versioning product or methodology (like, XP) - my interest is more about work-flow at the individual team/developer level than evangelism. This is more-or-less a by product of the management situation I've operated under more than a lack of reading software engineering books or magazines about development processes. A lot of what I've seen/read is more marketing oriented material than any specifically enumerated description of "well, this is how our shop operates".


Virtual Machines And Unit/Integration Testing Web Application

I am in the process of adding unit testing to a project I am working on at work and a suggestion came up that I should use VMs to populate the database with good data. This was suggested as an alternative to what I usually do which is use yaml fixture file to load the data. While I think that using a VM for the unit testing database might have some benefits, overall I do not see it as a great solution. The first concern I have is the speed of running tests. I don't know how long it would take to bring up and tear down a new VM instance based on a snapshot but my guess is that it would be longer to the data insertions that the yaml data fixture files do. Unit tests should run as fast as possible because they should be executed at least once before any push to the version control repository and that can happen several times a day (even more when in bug fixing mode). The next concern is having the data in a known state for all tests. Sure, the first test that is executed on the VM's database is going to know what state the database is in however once a test modifies data, that could screw up the other tests. With the yaml fixture data files, each test is guaranteed to know what state the database is in. The last major concern is the complexity using a VM setup would probably entail (of course I could be wrong since I have never had a setup like this before). Obviously we can't just run phpunit with using VMs in the setup. First we would have to create a script that basically creates and deletes the VM. This would have to either work on all OSes or we would have to force everyone to work in a VM environment (and running a VM within a VM seems like it is really going to be even slower). The VM suggestion was to combat the issue of managing yaml fixture data files however to me it seem like managing yaml file would be the easier of the two options. Has anyone ever worked in an environment where developers would use VMs for the database that unit testing (or integration testing or whatever you want to call it) required and was is successful?


Hackathon and Scope

I enjoy going to hackathons as it gives numerous benefits (like free pizza), but I have never successfully navigated the projects through to a good ending. Most hackathons in my area are approximately 8 hours of actual coding. What is the best way to manage a project in such a short time period? From creating the idea to some sort of semi-working product. In such a short time, should a project have one feature and if it gets done, another feature can be started? Should everyone work on the same feature? How should leadership be formed? Should there be leadership or direct democracy? It always seems that either the scope of the project is too much, or major time will be lost on solving some sort of problem.


From console to GUI applications

I'm a beginner programmer and all I've worked with so far are console applications in C++. Coding wise, how is the graphical side of programs created? I understand the logic that I am using from console apps will be the same, but how do programmers create the graphics that this logic is then used in? I know this is sort of an ambiguous question but basically I am trying to understand how I would go about creating a program that is not a console application, such as a video game or an iPhone application.


Software licensing and Copyright of Open source

I have seen some source code containing Copyright notice in the beginning of the file. Most of them are either GNU General Public License or Apache License. If I want to develop any open source software what are the steps should I follow? Do I need licensing my software by registering somewhere, or I just add the text like described in Apache License 2.0. If I modify source code of another open source software then what should I do? Should I seek permission from them?


Should ORM data access methods be wrapped or used directly?

We're using an internally-built ORM. Each table is represented by a Model class, which inherits from a base model class that has a handful of methods like GetAll, GetWhere (to get rows with specified column values), GetFirstWhere, etc. to access data from the table. There's a question of whether these methods should be protected (so that any database access needs to call a public wrapper method for the exact query) or public methods (so that code anywhere can call GetAll, GetWhere, etc.) I see some pros and cons for both sides. Which style would be considered best practice and more maintainable? **Protected** _Pros:_ it's easy to see all queries against a table, just open the Model file. This could be useful for checking whether the table is indexed properly, etc. _Cons:_ extra work and cognitive overhead for every data access. I now have to check whether a query method already exists and create it if not; I have to look up method names, which tend to be specific like "GetThisThingByIDAndName"; also, if I want to change a query, I need to make sure nothing else was using that method or create a new method. Many of these queries are only ever going to be used once, and in practice there end up being tons of these methods whose names don't always clarify exactly what the method does. **Public** _Pros:_ the standardized data access interface allows developers to easily memorize the few data access methods and use them consistently across tables, which makes development faster and simpler. Also, they can make changes directly where the query is taking place without breaking something elsewhere in the codebase. _Cons:_ requires a search to find all queries against a table. If not careful, there could be some duplication.


How does a clicked event work at a low level?

Specifically in regard to a drag and drop operation, how does a button, text box or whatever know that it has been clicked (or vice versa how does the display manager know what it clicked). I read some about the COM way of dragging and dropping and I think I get the general idea: on mousedown, detect what was clicked. While mouse is still down and cursor position moves a certain amount store the data associated with the drag source. When the mouseup event fires, drop the data if the mouse cursor is over a drop target. If it is not a drop target then cancel the operation. You can expand this to the scenario where you click and drag to select multiple files.. how does the UI know what files it selected? Does the display manager have a calculated pixel range for every element and compare mouse position clicks to that? If so, how does the display manager know this? If the answer is too long or difficult to explain here, can you point me to some resources that I could read? I understand that you store data on a mouse click event, but that is a higher level "just call these API functions" view of it.


Mobile App Development Language Converter?

I was talking with a friend about developing a mobile app (android/iphone) but I've never messed around with mobile app development code before. My friend flippantly told me that I don't _"need to know mobile app code..."_ because _"there are converters out there that convert your code to mobile app code."_ My question is two-fold:   1. Is this true? Where can I find these fabled converters and are they any good?    2. I'm pretty handy with PHP/Javascript/Java (in order of skill level). Which mobile application language would be a good starting place? Or... which of my following code languages "convert the best" to mobile app language?


Does printing out numbers involve converting the numbers into characters?

In programming languages, when numbers (either integer, or real) are printed out, are they firstly converted to the codes of the readable characters that are meant to represent the numbers, and then the codes are then decoded into the readable characters? For example, in C, functions such as `printf` can print out the value of an integer variable `a` to screen or files. Suppose the value of `a` is 1. Does `printf` first convert the number `1` to the number `0x31` which is the ASCII code of character `1` and then decode `0x31` to character `1` in its output? Thanks and regards!


How to run C++ code in browser using asm.js?

An asm.js application is very fast (near native C++ speed): http://kripken.github.io/mloc_emscripten_talk/micro4b.png But how is it possible to write one in C++, convert it to LLVM code, then do some trick with emscripten/asm.js ? I haven't found any tutorial about it. And if I write the code in C++, then how to use the js API-s, for example XMLHttpRequest, WebSockets, Canvas or WebGL?


Do Windows Installers for internal business applications make sense?

I'm trying to build a general understanding for what's common in this situation so that I can decide if it makes sense to pursue it further.   1. Are installers welcome in a typical corporate environment with the following?      * Change control process     * Dev/QA/Production environments     * Designated deploy teams for various areas (firewall, database, windows, etc.).   2. Is there a "litmus test" that could be applied to an application to see if it is a good candidate for creating an installer? *      * Are installers simple enough that every application should have one?     * Are installers even the right tool?   3. Is it reasonable to expect developers to learn something like WiX to support installers?      * Maintainability in general is a concern, i.e., is creating an installer a niche skill? > ## * > > For example, I have a set of winform applications that are in a shared > directory on a production server. Specific groups can run the applications > from this directory but only system admins can modify the executables. The > current deploy process involves having an admin copy/paste the executables > and libraries to the shared directory. > > Since the applications are not installed on the individual users' machine, > does it make sense to create an installer for deploying new versions of > these applications to the shared directory? Edit-- I felt that the answers here gave some solid advice so I wanted to share what I came up with for my current project where I needed to build a large number of applications and deploy them to individual folders. I found a NuGet package called _PublishedApplications that mimics the behavior of _PublishedWebsites for web projects. The idea is you install the NuGet package to your projects and it adds a target that will copy the build artifacts to a _PublishedApplications directory in the output path. This behavior is activated by running MSBuild from the command line and specifying an `outdir` property:               msbuild /p:Configuration=Release /p:outdir=C:\path\to\outdir MySolution.sln      This will give you a directory structure similar to the following:   * C:\path\to\outdir      * _PublishedApplications\        * Project1\          * `dlls, exes, etc.`       * Project2\          * `...` From there, creating a zip that can be extracted in the various environments is fairly painless.


How should I structure modules in an Angular.js application?

I am fairly new to Angular.js, and one that confuses me is how to best use modules in an application. It seems to me that modules can contain any of the other common constructs in AngularJS (controllers, directives, filters, services, etc.), but from here I am unsure which module(s) should contain which things.   * Should I have one module that contains all of the other objects in my application? This seems the easiest to set up, but this smells of the God Object Anti-Pattern to me.   * Should I divide modules up by types of objects? i.e. one module for controllers, one for directives, etc.?    * Should I divide them by use? So that all directives, services, and filters that are used for part of the application are together?   * some other strategy I haven't yet seen / thought of? Any help would be greatly appreciated.


Unit testing and coupling

As a developer I should strive for low coupling between classes. But low coupling doesn't mean "No coupling" so sometimes I have to allow some code flexibility and use "new" inside a domain model. (I'm sure everybody does this in real production code) If I use "new" inside a method to create an object and I have to unit test this method I got a problem. Because I can't mock the objects I can't test the method in isolation. I know I can use dependency injection or I can send objects as parameters but I'm not talking about this clear cases. Is this acceptable in practice?   Is there a better way? (I can't always inject)   Is this a unit test or an integration test? PHP example:               class Car {        protected $objDoor;        public function createComponents() {            $this->objDoor = new Door();        }     }


Is having functionality in DB a road block to scalability?

I may not be able to give the right title to the question. But here it is, We are developing financial portal for wealth management. We are expecting over 10000 clients to use the application. The portal calculates various performance analytics based on the the technical analysis of the stock market. We developed lot of the functionality through Stored procedures, user defined functions, triggers etc. through Database. We thought we can gain huge performance boost doing stuff directly in database than through C# code. And we actually did get a huge performance boost. When I tried to brag about the achievement to our CTO, he counter questioned my decision of having functionality implemented in database rather than code. According to him such applications suffer scalability problems. In his words "These days things are kept in memory/cache. Clustered data is hard to manage over time. Facebook, Google have nothing in database. It is the era of thin servers and thick clients. DB is used only to store plain data and functionality should be completely decoupled from the database." Can you guys please give me some suggestions as to whether what he says is right. How to go about architect such an application?


Need some clarity on the GPL

Suppose someone writes some code, and publishes it as open source under the GPL. Later they decide to close source their application and put it for sale. Is that in violation of the GPL? All code in the closed source app was written by the said author. Since he "owns" the code, I would think he can choose to re-license it however he wishes. Is that right?


How does Facebook strip html/apostrophes for XSS but also display it?

I'm not quite sure if this is a question for programmers.se rather than stackoverflow, but here goes. So Facebook [or any other large company] when given something like an apostrophe or html, can strip it of its malicious intent, but still display it properly. My current sanitizing function in PHP just strips those characters/makes them harmless via htmlentities() and such. So if I wrote an HTML tag, I would want it to be sanitized but also displayed on the website. How do I do this?


What's the deal with code reviews?

I've been wondering about code reviews recently, based on how many questions I've seen on here talking about them. Between my internships, contracts, and full time jobs, I've worked for six different companies, and only one of them has done code reviews. At the last two places I've worked, code was good (or at least good enough) if all the unit tests passed, and it got the stamp of approval from our tester. We were all compotent programmers, so if the code worked, we were happy. Now, there were a handful of times where something came up months or years down the line that might have been caught in a review, but they were so few and far between that I'm not sure it'd be useful. I guess my question is:   1. Do you consider reviews to be useful?   2. How often do you do them?   3. How much of your time is spent reviewing code?


Best practice to propagate preferences of application

What is your approach with propagation to all classes/windows of preferences/settings of your application? Do you share the preference_manager class to all classes/windows who need it or you make variables in each classes/windows and update them manually each time setting are changed? * * * Currently I have a `PreferencesInterface` class that hold all preferences and is responsible to default all values with a dedicated method called on create and when needed, all values are public, so non getters/setters, also it have virtual `SavePreferences`/`LoadPreferences` methods. Then I have `PreferencesManager` that extends from `PreferencesInterface` and is responsible for actually implementation of `SavePreferences`/`LoadPreferences`. I've made this basically for _cross- platform_ so that every platform can have a different implementation of actual storage (registry, ini, plist, xml, _whatever_ ).


Advice Needed: Developers blocked by waiting on code to merge from another branch using GitFlow

Our team just made the switch from FogBugz & Kiln/Mercurial to Jira & Stash/Git. We are using the Git Flow model for branching, adding subtask branches off of feature branches (relating to Jira subtasks of Jira features). We are using Stash to assign a reviewer when we create a pull request to merge back into the parent branch (usually develop but for subtasks back into the feature branch). The problem we're finding is that even with the best planning and breakdown of feature cases, when multiple developers are working together on the same feature, say on the front-end and back-end, if they are working on interdependent code that is in separate branches one developer ends up blocking the other. We've tried pulling between each others' branches as we develop. We've also tried creating local integration branches each developer can pull from multiple branches to test the integration as they develop. Finally, and this seems to work possibly the best for us so far, though with a bit more overhead, we have tried creating an integration branch off of the feature branch right off the bat. When a subtask branch (off of the feature branch) is ready for a pull request and code review, we also manually merge those change sets into this feature integration branch. Then all interested developers are able to pull from that integration branch into other dependent subtask branches. This prevents anyone from waiting for any branch they are dependent upon to pass code review. I know this isn't necessarily a Git issue - it has to do with working on interdependent code in multiple branches, mixed with our own work process and culture. If we didn't have the strict code-review policy for develop (true integration branch) then developer 1 could merge to develop for developer 2 to pull from. Another complication is that we are also required to do some preliminary testing as part of the code review process before handing the feature off to QA.This means that even if front-end developer 1 is pulling directly from back-end developer 2's branch as they go, if back-end developer 2 finishes and his/her pull request is sitting in code review for a week, then front-end developer 2 technically can't create his pull request/code review because his/her code reviewer can't test because back-end developer 2's code hasn't been merged into develop yet. Bottom line is we're finding ourselves in a much more serial rather than parallel approach in these instance, depending on which route we go, and would like to find a process to use to avoid this. Last thing I'll mention is we realize by sharing code across branches that haven't been code reviewed and finalized yet we are in essence using the beta code of others. To a certain extent I don't think we can avoid that and are willing to accept that to a degree. Anyway, any ideas, input, etc... greatly appreciated. Thanks!


Resources for understanding iOS architecture

I recently finished reading Randall Hyde's excellent book Write Great Code: Volume 1: Understanding the Machine, and I have a much better knowledge of what's going on under the hood now. I want to start making iPhone apps, and there are lots of guides for that. Embracing my inner Hyde, however, I want to first learn about the iOS system architecture. Apple has a really good overview here: iOS Technology Overview Before I start, I wanted to know if there were any other good resources for **understanding iOS architecture and using that knowledge for iPhone programming**. Thanks.


External modules security

I am developing some external modules for an application. These modules are BPL files and if present in the application folder the application loads them and uses whatever is available inside. How can I prevent the sharing of these modules by my clients? I need them to be authorized to use the modules (module by module). To have some sort of license, registration of the module, what is the best method? Thanks


Coding styles when using several disparate libraries

I am working on some C++ code that uses several libraries, including some C libraries, that all have different coding styles. It will be open sourced once it reaches a usable stage. Which would cause the least confusion for a short- term contributor who checks out the code to fix one bug or add one feature?   * Have one consistent coding style throughout the entire application, even if it occasionally doesn't match the typical coding style of the libraries used.   * When a library is heavily used in a certain module, conform to the typical coding style of that library (i.e. the coding style used in the library's own code and documentation) in that module. My thought is that the latter will make it easier for experts in that particular library to make one-off contributions, and make it easier to incorporate tutorial/example code during development. However, it also makes the coding style inconsistent throughout the application. What are the pros and cons of each approach?


Huge long addition overhead compared to Native call?

A run a simple test JDK 1.7.0_45 (Windows 7, 64bit): Test 1:                   long start = System.nanoTime();         for (int i=0; i < 1000000; i++) {             System.currentTimeMillis();         }         elapsed = System.nanoTime() - start;      Versus Test 2:                   long start = System.nanoTime();         long adjust = 313231;         for (int i=0; i < 1000000; i++) {             long result = System.currentTimeMillis() + adjust;         }         elapsed = System.nanoTime() - start;      On my system, first test ran at arund 28 nano/call. The second at around 1250 nano/call. That is a whopping 44x overhead. Can anyone explain such a huge difference?


Java web app, with plugin framework and ability to connect to source for updates

I've searched all around for some good sources, but either have been searching for the wrong keywords, or I'm just missing something. I'm looking to redevelop a web app I've been using for some time now. Many parts are out of date, and we're constantly throwing in little hacks to attempt to give it new life. So what I'd like to do is re-engineer it from the ground up, built on some sort of plug-in framework. Before I continue, I'm more or less an intermediate Java programmer. In some ways, I'm hoping to use this project as a big learning experience. I've read a lot about OSGi, and it seems that's the most complete framework. Ideally, I would like an end result web app which I can run one instance as my hosting environment, and other instances can connect to it to grab new and updated plug-ins. Eventually I'll want to lock down these plug-ins based on some undecided criteria of who can get them (basically some will simply be updates, others will provide new functionality and should be "purchased" through an external system). But that will probably be handled in a later phase. There should be an administration view for managing bundles in a hot environment (looking to avoid having to restart the server for an update). I know all these things are possible, I'm just trying to find some good resources for reference. All the OSGi tutorials I'm finding seem to be too simplistic. If anyone here can guide me in the right direction on any or all of the items I'm looking for, it would be much appreciated. Also, this is my first post, so I'll take any comments/criticisms about the content of my post. Thanks!


Why does Java not put the filename in args?

In C and C++, the main method holds the filename in the first position of the array at argv[0]. In Java, however, the filename is not included in the args string array. Is there a practical reason for this? I understand that this makes iterating through command line arguments 0-based instead of 1-based, but is there a benefit? Was the filename just deemed to be useless?


Question on System Requirement

I have a scenario where a specific webservice must be consumed based on the state to setup user info. For instance if the state is NY or NJ call service A , if state is WA call service B etc. But specifying what service must be called is I guess is "HOW" to setup a user info and not a "WHAT". So should I just have single requirement stating system must have the capbality to setup up user info based on state? EDIT: I would also like to add that the services implemented for different states might want different info to be provided in addition to basic details such as first name and last name. Should the services , input to the services , output from the service , what the program needs to do with the output etc be part of system requirements? I guess all these deal with "HOW" more than "WHAT" - hence is it in the requirements realm?


Fastest Functional Language

I've recently been delving into functional programming especially Haskell and F#, the prior more so. After some googling around I could not find a benchmark comparison of the more prominent functional languages (Scala,F# etc). I know it's not necessarily fair to some of the languages (Scala comes to mind) given that they are hybrids, but I just wanna know which outperforms which on what operations and overall.


Architecting an application with a single page javascript driven UI

I have a single page application where everything in the UI is javascript driven so any operation requiring data or updating of data is done via Ajax requests. The way things are setup right now is that my Ajax called are made to one ajax.php file which takes care of routing them to the proper service method. This works well but there's one problem. Whenever I have operations that require a user ID, I don't want to pass them as part of an ajax request so as to prevent tampering. Since I have a session running server-side, I have a Security service from which I can retrieve the user ID of the user currently logged in. The security does so by using a Session object that abstracts the access to the session (in my case, $_SESSION in PHP) implementing an interface. My security service gets injected into other services as needed, so for example, if I have a PostService->findUserPosts() method, that method uses the getUserId() method of the injected SecurityService object to figure out the user ID instead of having it passed as an argument. The problem is I suspect (and others seem to agree) that not passing in the user ID to the service is bad design. But how do I get around doing that without sending the user ID via ajax? I can think of a few options, none of which I really like or know of a good way to implement: 1) Add a controller layer on the server side, in which case I can call SecurityService->getUserId() in the controller and pass in a separate call to PostService->findUserPosts($userId); the problem with this approach is that it requires me to add a bunch of controllers that are for the most part pretty redundant. As it is, I already a PostService->findPosts() method that basically just calls PostGateway->findPosts(). I can live with that redundancy because there will be a lot of places where the service will need to do more. But adding a third layer with a controller with a findPosts() method, that seems too much of a pain. 2) Pass the user ID in the ajax request and come up with some kind of tampering mechanism to make sure the ajax request can't be altered. I could do that by hashing the URL string of my request and appending that as a parameter, and then on the server comparing the hash. This is more obfuscation than anything though, since the hash would need to be generated client side, which means somebody looking through the code could figure out how the hash is generated. 3) Keep things as they are, bearing in mind that my user ID is at least not hard coded and various implementations of the Session object could be used, that way the user ID can be retrieved in multiple ways, not tying me to the PHP $_SESSION object. 4) Use a hybrid method of #1 and the current setup where if I need to access session info I use a controller, otherwise I call the service directly. This could work, though it doesn't feel like a clean, unified approach. I tried to figure this out with two separate questions dealing with separate smaller problems, but I think the lack of context made it difficult to answer, so figured I'd formulate a question with the entire problem. Suggestions are welcome. Suggestions are welcome. Or should I say, much needed! **UPDATE:** maybe a valid compromise would be to have a PostService->findByUser($userId) method and then have a UserService->findPosts() method that gets the userId from SecurityService the same way PostService is doing now?


What to look at when deciding which technologies to use on a new project?

So, we are starting a new project soon, and there are a lot of decisions that must be made. The one I am most interested in is: **What all do you have to take into consideration when deciding what technologies to use?** There is always something that you miss and only half-way through the project do you realise, _"O yeah... I should have thought about that..."_ , and usually it's something that would have made you go with a different technology. I would like to hear what you guys think. Maybe get a nice comprehensive list up to help the architects everywhere to make more informed decisions.


Is the Java package name convention flawed?

We're all familiar with the Java package name convention of turning the domain name around. I.e. `www.evilcorp.com` would, by convention, chose to have their java packages `com.evilcorp.stuff`. Increasingly I'm getting fed up with this. As a commercial programmer, I encounter time and again that the software package name is completely irrelevant due to some rebrand, acquisition or similar. In the opensource world there's less name changes so there it makes sense. However it seems to me the shelf life of many pieces of (commercial/internal) software are much longer than that of the organisation making them. The problem is often made worse by software projects taking the marketing department's lead to use the name _du jour_ they use refer to a certain project. A name that will, without fail, change 3 months down the line to make the emperor's new clothes feel fresh and new. Because of this, I've mostly stopped using the reverse domain as package name. Granted, if this is done on a large scale, there's risk of name collisions, but surely this is mitigated by either using "unique" software names, avoiding generic words, or use the reverse domain for projects intended to be sold/released as libraries. Other thoughts?


How improve learning habits, best practices?

> During the freshman year of high school, I had decided to master pre- > calculus on my own during a summer recess. So I spend 2-3 months reading > each chapter and solving all odd problems (to be able to check against the > answers at the back of the textbook). While I've learned the material, in > retrospect, I think it wasn't the best time-efficient approach. Fast forward > 15 years, past my university years and years on a job, I seemingly cannot > master anything in depth; I sort of only scantly familiarize myself with a > material. I only read the material or watch on-line video courses (such as > Khan academy lectures, free video courses offered by leading universities, > etc). I feel that I don't even know how to study or concentrate anymore. > Always multitasking. Please advise on the development of effective study > habits. How do you study independently these days? Friends I am looking for the **actionable** steps, and not just philosophy. What and How I can arrange my study to effectively master a material.


Ticketing System / Development Phase

At the stage of a project right before you actually start putting code in the editor how do you organize the project and your "tasks". Ticketing systems are great but I can't seem to find a way to make them worthwhile on a project until after launch. When tracking bugs and gathering enhancement ideas for later versions. What is a good methodology or "system" that you have used in the past that has helped keep a project organized and moving forward. A way to track your tasks and notes?


Hashing Algorithm: Deleting an element in linear probing

While using Linear probing method to implement hashing, when we delete and element, the position of the deleted element is declared as a tombstone/ mark it as deleted. Why can't we just shift all the elements from the current position until the next empty element is encountered? Won't this save the time when too many tombstones are encountered later and a rehashing might be required? Am I missing something? Please tell me if I need to clarify my question. Thanks a lot!


Things to do before going to production

I am finishing up a decently sized Python/Shell project, and I'm wondering if there's a 'best practice' list of things to do when finishing up development. So far I've done:   * pylint   * pycallgraph   * grep'ed for :TODO: and :FIXME:   * find orphan code   * some more documentation   * install scripts for client and server   * make sure comments match the reality (before I forget the finer points) What other things do you do, generally, or Python-specific?


Learning system instead of using sed/replace for reviewing test results

For every build of my software I run it through a series of tests that execute a number of commands on a command line and captures the results. Most of the time the output is a combination of: \- Static information that is, and should be, the same between every run. \- Dynamic information that is not easy to predict. For the purpose of testing this software I desire to only verify that the static information is the same between each test. Currently I use sed on the captured output of my automated tests to filter out the dynamic information. Any differences between test runs are then identified using the filtered data resulting from applying the sed rules. Because of the large variety of command output that is processed, maintaining the sed rules has become an onerous job. Is there a system, that with a large sample of executed test results, can show uncommon changes between two files contained in that large sample of test results? To clarify, if I were to diff two files, I would only want to see differences for items that changed 5% of the time between all the files involved. Any other data that changed 95+% of the time would be excluded as differences when comparing two of the files within the large set of test results. In this example, among the large set of test runs, the first column is almost always consistent: Run 1:               1/*/1    6643   2433   12343   232424    112       2/1/1    2311    455    1342    60233   5231     2/1/2    2355   1223      93    12389   1342      Run 2:               1/*/1    3121    112   98832      451   1233       2/1/1    6342   2345   84421     3456   8362     2/1/2   72453      5     421    64321   7634      Run 3:               1/*/1      12     65     312      653    973       2/1/1   12442  54231   46012        6    734       2/1/3     734     28     623       76   1834        On top of the three runs above, there are hundreds of samples of this same commands output generated for each incremental build of the software. When performing a difference between each of the three examples above I would like to have the following results: No Differences between Run #1 and Run #2. Difference showing that "2/1/2" was changed to "2/1/3" when asked to show the difference between Run #3 and either of the other two runs. Currently I have a sed script that replaces all the "random looking" numbers above (counts, timestamps, etc) with hashmarks or other constant indicators so that all that is left to compare is the starting column. What options, if any, exist in this area? Is there a name for this kind of text comparison?


Optimize Reading of Multiple files

I have a unique problem which I'm hoping someone can assist with. I have One big text file, our **Production** file. The data in the file is delimited in the following format               Reference|Cost Centre|Analytics Base Value|....      UMBY_2288|023437|2883484|...      NOT_REAL|1343534|283434|...      The average size of this file is about 30MB. with about 120000 rows. and then I have about 20 **Regional** files. these files are similar to the Current big file in structure. except that they are smaller. average size 50000 rows. Now I have to loop through each line in the big Prod file. For each **Reference** code, I have to search through each of the 'Regional' files to see which ones contain that specific reference code. and then copying some of the data from that line into a report. There is no way of predetermining what files to look into. And each reference can be in multiple **Regional** files.. As you can imagine, looping through each row in each file, multiple times is a very time consuming process. Due to memory constraints, I can't load the files into memory. Does anyone have any smart ideas on how I can do this? I don't need code samples. just pointers on ways I could solve this problem. I'm developing the tool in C#.


How to transfer metadata using Bluetooth between an iPhone and an Android mobile?

I would like to develop a hybrid app to transfer data/meta data between an iPhone and an Android mobile device using Bluetooth. I could find BTStack and PhoneGap useful. But, is it possible to support meatadata using these? Ref :   https://code.google.com/p/btstack/w/list   http://www.randdusing.com/2014/02/19/bluetooth-low-energy-plugin-for-phonegap/


Computer Science or Computer Engineering for Data Science and Machine Learning

I'm a 25 year old data consultant who is considering returning to school to get a second bachelors degree in computer science or engineering. My interest is data science and machine learning. I use programming as a means to an end, and use languages like Python, R, C, Java, and Hadoop to find meaning in large data sets. Would a computer science or computer engineering degree be better for this? I realize that a statistics degree may be even more beneficial, but I'll be at a school which dosn't have a stats department or a computational math department.


What is the best retort to "premature optimization is the root of all evil"

Often I hear the sentiment ... "Why worry about performance, write slow code, get your product to market ... don't worry about performance. You can sort that out later" The culmination of this sentiment is: "... premature optimization is the root of all evil ... #winning" I was wondering, does anybody have a **good** retort to this one liner. Ideally an equally strong **one liner** that encompasses the reverse of this sentiment?


Implementing Lazy Registration

I'm interested in setting up Lazy Registration on my website. Ideally, I'd like people to be able to fill out a record that might include their name, email, address, etc. and then record it to a user record later. The problem is, sometimes the person filling out that form will already have a record on the site. At that point, if they enter a new address, this will overwrite the old one if there's already a record with that e-mail address (I don't want to create duplicate records for the same e-mail). Since this is an open website, I have to ensure if someone is changing an existing record, that somehow they have to verify they are who they say they are before the record can be changed. Right now I'm not sure what the best option is for confirming that. Is it better to:   * Avoid lazy registration altogether if this is a concern, and force users to log in if the form they are entering has the potential to change an existing record   * Embed a login into the form -- so if they enter an e-mail for an existing record, it displays a login form that they have to fill out before the data is confirmed   * Pop up an Ajax-based login form while they are filling out the form, if they enter details (email, etc) that match an existing record in the database


As a programmer, can you work with noise?

I'm here to post this question and know more about your thoughts on it: **Can you work with noise?** Sometimes, when you're developing something really tricky, your deadline is getting close, and someone enters your room talking to your colleagues, with loud talking, suddenly... your logic is gone! :-) About me, it's really funny and ironic this: when it comes to music, I can think better, maybe because I'm focused in my solution avoiding distractions and chit-chat. But I know people who told me that they can't work in silence. I just can't work with too much noise. How about you?


What's the scariest piece of Other People's Code you've ever had to maintain?

It's happened to all of us. Maybe the original author is no longer with the company, or maybe the boss just doesn't trust him to fix it (Kernighan's Law). Either way, they gave it to you, and you ended up having to fix it. What was it like? What was the problem? How bad was the code, and what did you end up doing with it?


Is verification and validation part of testing process?

Based on many sources I do not believe the simple definition that aim of testing is to find as many bugs as possible - we test to ensure that it works or that it does not. E.g. followint are goals of testing form ISTQB:   1. Determine that (software products) satisfy specified requirements ( I think its verificication)   2. Demonstrate that (software products) are fit for purpose (I think that is validation)   3. Detect defects  I would agree that testing is verification, validation and defect detection. Is that correct?


Naming convention for a method that both sets and gets

Let's say we have a method `setFoo` that sets a flag in a Bar object e.g.               class Baz {          public void setFoo(String foo)(            ...         }     }      inside setFoo, the method is doing some expensive load of the `Bar` object from the database.               class Baz {          public void setFoo(String foo)(            Bar bar = expensiveGetBar();            ...         }     }      To avoid the need to get the `Bar` object again, the developer changes the method to return it.               class Baz {          public Bar setFoo(String foo)(            Bar bar = expensiveGetBar();            ...            return bar;         }     }      Questions are:   1. Is this discouraged?    2. If yes, why and what is the alternative    3. Should the solution be adding some sort of cache instead?   4. How would you prefix the method? set? get? seget? geset?


About classes and their valid states

I get stuck each time I need to write a constructor for any class I design. The reason is that I am not sure what should go into a constructor and what should not. On googling for this, I got the answer that the constructor need to do only as much as to make sure that the opbect created is valid. But my query is > How do you know if an object is in the valid state? My class represents a chess board:               public class ChessBoard     {         List<ICellRow> lstRow;         int cellOffset;              //Other function              public ChessBoard()         {             //What should go in here?         }     }      How do you decide when a class has the minimum information to be in the valid state? In this specific example, makes the board class valid?


When should development branches be created?

We are moving our project's team from using a single Main/Trunk branch, to multiple Development/Work branches that should be regularly merged into Main. We're basing our new process on this article and the TFS Branching Guide (we are using TFS and Visual Studio 2010). There are currently between 1 and 5 people working on the project at any one time. Main must be stable at all times because we want the option to release whenever we need. We don't have fixed sprints - at least not yet - and at the moment release every 1-2 weeks. Right at this point in time each person is fixing bugs across the application. In a couple of weeks we will be starting development on a new large component for the app. One sticking point we are finding is **when development branches should be created**. We will be implementing multiple user stories in parallel depending on the skill set of the developer. We've thought about creating a branch for each developer but that doesn't make sense because there will always be some need for collaboration on a piece of work. We can't get by with a single development branch because we will want to merge to Main while other work is completed. Does anyone have some guidance on this?


Entity Framework limitation

I was wondering if anyone had the same need and why (if possible). My problem is: I can't create a model in EF using two tables from different DBs without some weird workarounds. For my scope that is very much necessary. Did any of you ever needed to do this? What did you do? And, like me, do you think MS should add this feature? Thank you all.


How will you handle NULL values in your application?

At what level do you prefer to handle Null values in your application? My personal preference at the moment is the DB. When I build a view, I ensure that I return a value in place of a NULL value. So if your front-end app were to connect to the application it would never have to handle nulls. In my VB6 apps, I made liberal use of the IsNull function to handle Nulls. Share your experiences.


Are there opportunities working as full-time paid programmer for Non-profit organizations

Some recent events in my life have made me want to contribute more to causes I believe in rather than just working for a profit-driven company. I have been thinking that if I could find a non-profit organization that I like and believe in then I might feel more fulfilled working for them. I have a decent amount of web development experience and currently work as a Java / Spring web developer. I realize the compensation wouldn't have the same "ceiling" potential as for- profit but am wondering if its possible to get at least something close to a market rate for work as I am planning to start a family sometime soon and still need a legitimate income. If anyone has any knowledge or experience about this sort of thing would be happy to hear from you. EDIT: Without getting in to too much personal detail, I have a relative who recently passed away who suffered from a mental illness so while it doesn't have to be an organization specifically dedicated to this, I am hoping to work for something along these lines at least where there is more of a social cause rather than just working on an open-source project whose only cause is the advancement of technology.


How do we avoid GPL violation when modifying and releasing a program using code coverd by this license?

A friend and I have started a project using code from another project, that is covered licensed under GPL. We have distributed it freely on our website, and under its download button, we've added a direct download link to the modified source code also for free. At the about section of the application, we have credited the guys who built the original code. Does the fact that we have a different project name violate the terms of the GPL? And also, if we include the original GPLv2 notice from the original app does that help us comply with it? If not, please state exactly what we have to do to comply with the GPL. The code we're using is an older version, released under GPLv2, and that project has been discontinued, and moved to a different one, where they're still developing. We haven't used any of their current coding, which is released under GPLv3.


Who gives direction to the overall product offering and innovation?

I sometimes wonder how CEOs or Founders of companies like Microsoft and Oracle manage the overall technology movement and product link-up. Take for example Oracle, it started with the database only and now, when you open their official site, the bibliography opens. Take for instance, Oracle database 11g. The core database is continuously improving and new features are being added. At the same time you need to keep a vigil on the current market trends, needs and competitors. Does Larry monitors each and every activity of technology advancement? What about new ideas and innovations? Who is responsible for these? Another example that puzzles me is .NET. With a new thing launching every second day, who is the .NET father and who suggests these guys to add classes for this and that. Who gives direction to the overall product movement and also integration with the other products? This is simply a beauty. This seamless integration or communication between the products and the technology as a whole is remarkable. (Not a biased view). Few years back I read a book titled: _Microsoft Secrets_. The author writes that at Microsoft, even the very senior person has to code because until and unless you are able to code, you can't better run a software company. I sometimes think Ballmer codes or not and what about Bill? Is he coding another OS at home?


Test descriptions/name, say what the test is? or what it means when it fails?

The API docs for `Test::More::ok` is               ok($got eq $expected, $test_name);      right now in one of my apps I have `$test_name` print what the test is testing. So for example in one of my tests I have set this to `'filename exists'`. What I realized after I got a bug report recently, and realized that the only time I ever see this message is when the test is failing, if the test is failing that means the file doesn't exist. In your opinion, do you think these `$test_name`'s should say what the test means if successful? what it means if it failed? or do you think it should say something else? please explain why?


Knowledge Transfer without a Plan

We are doing work for a particular client managing their CRM implementation. (The CRM itself is a product which has been largely customized to suit my client's needs). Now, they want us to manage the Oracle batch jobs/ETL as well. And for this, they are ready to provide us with Knowledge Transfer. (The Oracle batch jobs/ETL is managed in-house by the client now). After much persuasion, I got one of the Project Lead (designation-wise) to email the client asking for a KT Plan. (The Project Lead kept saying that they have never had KT plans before and all that for which I offered I will draft a template and even that was rejected!). Email from us to them - > Can you please share with us the KT Plan? Response from them - > Not sure what is expected from my side? The KT is planned for tomorrow from > 11 am onwards where Functional knowledge of existing ETL Data migration > package will be shared. How do you handle such a client? Most likely what is going to happen is this. The person who is giving the KT will say that I have given complete Knowledge Transfer and we will go back and say that "No, this was not covered. For this, they provided an overview alone and left it at that!" and so on... My Project Lead also did not respond to that email. He just said that the meeting is scheduled to happen at 11 AM (basically repeating whatever the email said and left for the day!). What could I possibly do? PS: Look for another job is a very helpful answer, but I am not looking for it. :-) **EDIT** The meeting went on well where they shared a Oracle DB package (which runs to 10K LOC). They told us that ETL which fetches data from other core systems to a Staging_DB is the ETL team (another team's) responsibility. This Oracle DB package will move the data from Staging_DB to my CRM_DB which is what we are to manage/modify. **What I did** Drafted the Minutes of Meeting as below:   1. Listed down what is In Scope and what is Out Scope   2. No documentation regarding the functionality of the Database Package   3. No reports for performance of existing Database Package to baseline the performance   4. ...   5. ... And then went back to my management and told them I need time to do the documentation, baseline the existing performance and so, I will come back with clarifications which the client is supposed to answer. Let us see how that goes.


How to connect mvc application using entityframework or ado.net?

I am an ASP.NET developer. I want to learn ASP.NET MVC. In fact I am learning it. But Now I am confused at a point. How can I connect my database to my application. Using entity framework or linq or ado.net. I have good knowledge about ado.net. But about entity framework I cant say anything. Now my problem is this whichever ebook or website I see every entity framework is used. So is it essential for me to learn first entity framework before ASP.NET MVC or not?


Is there such a thing as Programmer's block?

Is it possible for a programmer to suffer the equivalent of writer's block? What strategies are there to overcome it?


In the world of .Net, managed code and the web is there still a place for VBA?

Microsoft has moved away from the COM stack, VB6 is so last century and .Net rules the (MS) roost. Yet I find myself still banging out reams of VBA code am I dinosaur? The need for VBA is a new project automating Excel seeing as you ask. I've tried to doing the same kind of thing using VSTO and it was just too damn buggy/hard/inefficient with a broken development model. I can't get rid of the feeling that I'm missing something, OTOH I really can't see a better way of solving this problem. What are your thoughts?


Creating menu structure using DB - is that fine?

Also I have an application that basically consists of a lot of screen so user needs to navigate a lot (like go from A>B>C>D) etc. I have been thinking how to implement this (mainly hold the structure of the menuj) as it needs to be on-screen menu (custom, no menu strips etc.) and did not find any solution. Now I realized I could use a database for that, which would allow me also to change strings later with no impact. My idea would be to have a table for each level (1-5) with options available. Once the user selects an option, the program will select any items in the table (CurrentLevel+1) based on its ID. Seems really a good solution to me but I am not a programmer (rather than an analyst). Or even I could use specific table names and hold the table name in a specific column, for example: > User selects Settings > > Program checks that with Settings, there is a table associated "SETTINGS" > and query this table for all items available Makes sense?


When to use the whiteboard pattern versus direct calling

I'm creating the architecture for a new embedded project. The system has some inputs that go to wildly different outputs. The whiteboard pattern is very useful for this (see Listeners Considered Harmful: The "Whiteboard" Pattern), as it decouples the input component from the output components (a 1-to-N relationship). However, I'm struggling with the N-to-1 relationship (where one output gets data from wildly different inputs). Should I use the whiteboard pattern there? And what about the 1-to-1 relationship? Advantages that I see of the whiteboard pattern:   * separate deployment and testing of sources and listeners.   * the whiteboard (EventAdmin in the OSGi world) can be monitored separately.   * there is no build-time dependency. Disadvantages that I see:   * there is no compile-time check on the events (if someone makes a typo in the event topic or the data, you're screwed).   * overhead of the whiteboard (I've done measurements, and it's significant on our platform). I'm not quite sure how to balance these trade-offs.


Can I use Node to add email functionality to an existing site?

I have a client with an existing straight up HTML/JavaScript site. No back end of any kind. He wants to add email functionality to it and I was thinking of using Node to do this for two reasons:   1. It seems like an extremely lightweight way to do it   2. He's talking about adding further functionality in the future. What are the positives and negatives of this approach?


An executive at my workplace asked me and my group of developers the question: > How many lines of code can a C# developer produce per month? An old system was to be ported to C# and he would like this measure as part of the project planning. From some (apparently creditable) source he had the answer of "10 SLOC/ **month** " but he was not happy with that. The group agreed that this was nearly impossible to specify because it would depend on a long list of circumstances. But we could tell that the man would not leave (or be very disappointed in us) if we did not come up with an answer suiting him better. So he left with the many times better answer of "10 SLOC/ **day** " _Can this question be answered?_ (offhand or even with some analysis)


Architecture: for a Single website to be supported for different Clients

I have developed a system with one company profile. The system is built using WCF services, asp.net. Now another company wants to use our system as well. And they might need some customization and some of their data elements are different. So I am planning to create a separate database for the new company and branch the business logic layer. I thought of different options to architect this and ended up with the following. So what is the best way to design a system of this sort. **Approach A:** Expose the methods as two different WCF services one for each company. So there will be one WCF client interface (IClient) but two different Service classes for each company implenting them. `ClientAService : IClient, ClientBService : IClient.` **Problem:** The problem with this is all my datacontracts and datamembers are exposed to the client in 2 different namespaces. `(ClientAService.ObjectABC and ClientBService.ObjectABC).` So all the objects that I use in the website are conflicted. ie(when I have a list of `ObjectABC` in a datasource in the webpages, the website don't understand whether its from `ClientAService` or `ClientBService`. **Approach B:** Expose the methods as a single WCF Client, but 2 different business logic layer. But they will use the same datacontracts. So the methods will return the same datatype. so I will have one service class               ClientService : IClient          {     public <ObjectABC> Method1(String Companycode)     {     if(CompanyCode == "A")         return new AbusinessLogic().Method1();     else if(CompanyCode == "B")         return new BbusinessLogic().Method1();     }     }      **Problem:** The only problem I can think of right now for every new company, I have add the above else if part for all my methods. I am also open to know if this can done in any other better way than the stated options. note: I was told that there might be more companies to be added in future.


Adding complexity to remove duplicate code

I have several classes that all inherit from a generic base class. The base class contains a collection of several objects of type `T`. Each child class needs to be able to calculate interpolated values from the collection of objects, but since the child classes use different types, the calculation varies a tiny bit from class to class. So far I have copy/pasted my code from class to class and made minor modifications to each. But now I am trying to remove the duplicated code and replace it with one generic interpolation method in my base class. However that is proving to be very difficult, and all the solutions I have thought of seem way too complex. I am starting to think the DRY principle does not apply as much in this kind of situation, but that sounds like blasphemy. How much complexity is too much when trying to remove code duplication? EDIT: The best solution I can come up with goes something like this: Base Class:               protected T GetInterpolated(int frame)     {         var index = SortedFrames.BinarySearch(frame);         if (index >= 0)             return Data[index];              index = ~index;              if (index == 0)             return Data[index];         if (index >= Data.Count)             return Data[Data.Count - 1];              return GetInterpolatedItem(frame, Data[index - 1], Data[index]);     }          protected abstract T GetInterpolatedItem(int frame, T lower, T upper);      Child class A:               public IGpsCoordinate GetInterpolatedCoord(int frame)     {         ReadData();         return GetInterpolated(frame);     }          protected override IGpsCoordinate GetInterpolatedItem(int frame, IGpsCoordinate lower, IGpsCoordinate upper)     {         double ratio = GetInterpolationRatio(frame, lower.Frame, upper.Frame);              var x = GetInterpolatedValue(lower.X, upper.X, ratio);         var y = GetInterpolatedValue(lower.Y, upper.Y, ratio);         var z = GetInterpolatedValue(lower.Z, upper.Z, ratio);              return new GpsCoordinate(frame, x, y, z);     }      Child class B:               public double GetMph(int frame)     {         ReadData();         return GetInterpolated(frame).MilesPerHour;     }          protected override ISpeed GetInterpolatedItem(int frame, ISpeed lower, ISpeed upper)     {         var ratio = GetInterpolationRatio(frame, lower.Frame, upper.Frame);         var mph = GetInterpolatedValue(lower.MilesPerHour, upper.MilesPerHour, ratio);         return new Speed(frame, mph);     }


"sell" coding my next project in an unfamiliar language

I want to code my next work project in a language I'm unfamiliar with (python). I can think of plenty of reasons from my point of view why its a good idea (not least of all because it sounds fun). However my manager will probably ask me why. I'm a little stumped on the advantages from his point of view. **EDIT** : I normally code in C# **EDIT2** My reasons for wanting to code in another language;   1. It will make an easy project much harder so I will learn more and it will be more interesting   2. I have just read a book on python. I want the chance to apply it in a business application so I properly understand it   3. It will increase my skill set and make me more employable    4. Python looks fun


Where can I find an algorithm for creating 3D anaglyphs using a depth map image?

I'm looking for a generic algorithm to calculate a red/cyan anaglyph starting from the original image and its black/white depth map, as in this example? That algorithm is used, for example, in Photoshop but I can't find a readable explanation to reproduce it.


Exclusive use of a Jini server during long-running call

I'm trying to use Jini, in a "Masters/Workers" arrangement, but the Worker jobs may be long running. In addition, each worker needs to have exclusive access to a singleton resource on that machine. As it stands, if a Worker receives another request while a previous request is running, then the new request is accepted and executed in a second thread. _Are there any best-practices to ensure that a Worker accepts no further jobs until the current job is complete?_ Things I've considered:   * synchronize the job on the server, with a lock on the singleton resource. This would work, but is far from ideal. A call from a Master would block until the current Worker thread completes, even if other Workers become free in the meantime   * unregister the Worker from the registry while the job is running, then re-register when it completes. Might work OK, but something doesn't smell right with this idea... Of course, I'm quite happy to be told that there are more appropriate technologies than Jini... but I wouldn't want anything too heavyweight, like rolling out EJB containers all over the place.


What do you call a developer specializing exclusively in microsoft programming languages like T-SQL and C#?

What would you call this type of specialty? Is "Microsoft Developer" misleading?


Is there such a thing these days as programming in the small?

With all the programming languages that are out there, what exactly does it mean to program in the small and is it still possible, without the possibility of re-purposing to the large. The original article which mentions in the small was dated to 1975 and referred to scripting languages (as glue languages). Maybe I am missing the point, but any language that you can built components of code out of, I would regard to being able to handle "in the large". Is there a confusion on what Objects are and do they really figure as being mandatory to being able to handle "the large". Many have argued that this is the true meaning of "In the large" and that the concepts of objects are best fit for the job.


Will LAMP meet the following needs?

I remember a few years back, when I had a web-site I wanted to develop, that many people recommended I go the LAMP route. Unfortunately, I never got around to studying/practicing that. I'm currently revisiting the web-site idea. The web-site will be dynamic, transactional, and hopefully end up with around 1,000,000 pv/mo and 300,000 members within 18 months. Will LAMP adequately support a site like that (i.e. have you seen it under a site with those specs)?