String encoding in string instances from different languages

I recently got a requirement to develop a chat-like application, or rather, a foundation of classes and methods that would allow certain applications to have chat-like features. The framework must be usable in at least two languages: Visual Basic 6 and C#. If `VB6-Application A` were to transmit string data to `CSharp-Application B`, when the data is received by `CSharp-Application B` and placed into a `string`, can I assume the string will contain the same information it contained when `VB6-Application A` sent it? (i.e. it will contain the same sequence of bytes that was sent from the original string instance in the VB6 app.)


Open Source sponsored feature development

I am considering to sponsor a development of some particular features in some Open Source tools. I would like the results of the work to be available publicly, and if possible, to be included in the main product line. The features are usually something which is of general use, but not very critical, and no one has currently a plan to develop it. For illustration, imagine I would like to use MinGW for Win32 development, but I miss a post mortem debugging option, I would like this feature to be implemented and I am willing to pay $1000 for it. Is there some common way how to proceed, or is this wildly per-project dependent? Are there some general guidelines how to contact the product developers, or are there some common meeting places where smart open source people who might interested to participate in such sponsored development meet, which I should visit to advertise the sponsoring option? Are there some specific ways how to talk about the job to be more attractive to people participating in open source (e.g. it might be more interesting for them to participate in a contest than just to take a payed job, which might have a bit of mundane feel)? Or perhaps is this something which you think has little chance to succeed, because perhaps money has very little value for open source developers? Any tips and experiences from someone who has some experience of open source sponsorhip from any side (sponsor or the developer) are welcome.


"Resource center": should the resources be exposed as public constants, or through getters?

I'm working on an application that has to do with music. Since the beginning of the work on the app, I had a public class named `MusicalResources`. The class had `public static final` `Note`s and `Chord`s. Any object that needed a note or a chord accessed it through this class, like so: `MusicalResources.C3` (`C3` being a `Note`). I had some problems with this class later in the project, and decided to gradually replace it with a new class, `NoteFactory`. It is also a static class, but instead of featuring lots of public constants, it features a public method `getNote` that takes the name of a note (e.g. `"C2"`) and returns the matching `Note` object. This allows me, hypothetically, to control the way I get the notes I return to the caller. I can keep them all in a Hashtable and always return the same ones, or I can instantiate a new one on each call, whatever. However, I'm actually not sure what's wrong with the original `MusicalResources`. It _feels_ like it causes me problems, but I'm still not sure _how_. So my question is: when there's a "central resource" place in your app, should you expose the resources through getters, or through `public static final` fields?


MATLAB - error using struct for mmreader

I am trying to use mmreader to upload a video into MATLAB. I am trying to follow the example in the documentation, however at the line               move(1:nFrames) = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),'colormap',[]);      I get the following error:               ??? The following error occurred converting from struct to mmreader: Error using ==> which Argument must contain a string.          Error in ==> VIDEO2 at 16 mov(1:nFrames) = struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),'colormap',[]);      Any ideas what may be wrong?


Creating an object that is ready to be used & unset properties - with IoC

I have a question regarding the specifics of object creation and the usage of properties. A best practice is to put all the properties into a state such that the object is useful when its created. Object constructors help ensure that required dependencies are created. I've found myself following a pattern lately, and then questioning its appropriateness.   The pattern looks like this...                public class ThingProcesser       {         public List<Thing> CalculatedThings { get; set; }              public ThingProcesser()         {             CalculatedThings = new List<Thing>();         }              public double FindCertainThing()         {             CheckForException();             foreach (var thing in CalculatedThings)             {                 //do some stuff with things...             }         }              public double FindOtherThing()         {             CheckForException();             foreach (var thing in CalculatedThings)             {                 //do some stuff with things...             }         }              private void CheckForException()         {             if (CalculatedThings.Count < 2) throw new InvalidOperationException("Calculated things must have more than 2 items");         }       }      The list of items is not being changed, just looked through by the methods. There are several methods on the class, and to avoid having to pass the list of things to each function as a method parameter, I set it once on the class. While this works, does it violate the principle of least astonishment? Since starting to use IoC I find myself not sticking things into the constructor, to avoid having to use a factory pattern. For example, I can argue with myself and say well the ThingProcessor really needs a List to work, so the object should be constructed like this.                public class ThingProcesser         {             public List<Thing> CalculatedThings { get; set; }                  public ThingProcesser(List<Thing> calculatedThings)             {                 CalculatedThings = calculatedThings;             }         }      However, if I did this, it would complicate things for IoC, and this scenario hardly seems appropriate for something like the factory pattern. So in summary, are there some good guidelines for when something should be part of the object state, vs. passed as a method parameter? When using IoC, is the factory pattern the best way to deal with objects that need created with state? If something has to be passed to multiple methods in a class, does that render it a good candidate to be part of the objects state?


Designing database related methods, which is better to return: true/false or row affected?

I have some methods that perform some data changing in a database (insert, update, and delete). The ORM I'm using return row-affected int values for those type of method. What should I return for "my method", in order to indicate the success/failure state of the operation? Consider the code that is returning an `int`: A.1               public int myLowerLevelMethod(int id) {         ...         int affectedRows = myOrm.deleteById(id)         ...              return affectedRows;     }      Then usage: A.2               public void myOtherMethod() {         ...         int affectedRows = myLowerLevelMethod(id)              if(affectedRows > 0) {             // Success         } else {             // Fail         }     }      Compare to using boolean: B.1               public boolean myLowerLevelMethod(int id) {         ...         int affectedRows = myOrm.deleteById(id)         ...              return affectedRows > 0;     }      Then usage: B.2               public void myOtherMethod() {         ...         boolean isSuccess = myLowerLevelMethod(id)              if(isSuccess) {             // Success         } else {             // Fail         }     }      Which one (A or B) is better? Or pros/cons of each?


Architecture to handle service concurrency on resources exposed via REST API

REST API frameworks like Python Eve handle concurrency control via an entity tag. This ensures that several clients which loaded the same resource will not overwrite the changes of each other, because they will find a modified entity tag upon write and be able to update their copy before writing. This is critical for web applications where a page or resource can remain for a lot of time in the browser before being sent back with some changes. My question is about one or several backend services integrating in this scenario. If a service is modifying some resources, it should take concurrency with clients into account. The possible ways that i see are:   1. Just update resources through the REST API   2. Reuse the concurrency logic from the REST framework in order to coherently modify the resources The first solution seems to be quite inefficient especially in the case of bulk updates, while the second builds a strong constraint among different components, which would have to be written in the same language, use the same version of the framework, etcetera. Albeit this seems to be a quite common use case, I could not find documentation about the recommended way to do it, even in other frameworks like Django or Rails. I see this as a common architectural question: how should services and REST APIs integrate in an ideal way, with respect to concurrency? I hope that it is fine to ask a cross technology question, since we may benefit from learning how the problem is handled in several frameworks.


Round Robin - how to determine the optimal quantum of time?

I have to calculate the proper quantum of time for Round Robin process scheduling algorithm. As I read in Tanenbaum's book, the quantum of time should cover like 80% of the running time of all processes. Is there a formula how to find the optimal quantum of time?


How to model a one-mandatory-of-many relationship

**I have following class model that I'm quite happy with:** ![Class Model](http://i.stack.imgur.com/M7knB.png) A `Whole` has a special mandatory `Part`. Furthermore it has a collection of parts, that contains at least the mandatory part, but may contain many more. In the OO model parts don't need to know where they belong. **So now I came up with this RDB model:**               Whole:        id - primary key        special_part_id - non-nullable, unique, foreign key to Part          Part:        id - primary key        whole_id - non-nullable, foreign key to Whole      The only constraint that is not checked here is `Whole = Whole.special_mandatory_part.whole`. However, with this table layout I'm not even able to insert rows. Might be worth mentioning that I'm using an ORM, but even with plain SQL I would not know how to do it. So my questions are:   * Is this DB design bad, and if so why?   * ~~If not, how would you insert rows?~~   * What design would you recommend and why? I'm aware of this very similar question. However, because of the `not null` constraint my problem is slightly different (worse I'd say) and I'm not satisfied with the given answers. **UPDATE** Just found an answer on how to insert rows with a table layout like this.


Pushing a new version of a live web application in a Git based workflow

I have a question regarding workflow in web development. I'm building my project in Symfony, and it's in Git. Right now, I have three environments, dev (local), staging and prod. The project itself is hosted on GitHub in a private repo. I'm wondering what a good way is to update the staging & production environments. Should I somehow setup a push based system so I can push the prod/staging branch directly to my server, and use Git hooks to regenerate cache files and run database migrations? Right now on similar projects I use a manual pull system, where I SSH to the server, pull down changes from the prod Git branch and manually run cache/migrations. This obviously is not ideal.


Should Software Engineering and Computer Science be separate majors?

For decades, the accepted degree to get to become a software developer was "Compter Science."   We've had a few questions already about whether that degree really prepares students to develop software. Some schools have, in the last 8 years or so, started offering multiple distinct majors in programming. Using the curriculum from my school:   * **Computer Science** , which starts out with some intro programming courses in the first year, and then focuses on theoretical computer science, algorithms, and a bit of OS stuff. Most classes involve several smaller projects and homeworks, done solo or in pairs.   * **Software Engineering** , which starts out with the same intro programming courses, does a few classes of theory, and then goes into software development practices (testing, process methodologies, sofware metrics, requirements gathering) and software design (distributed system design, info system design, real-time/embedded design, subsystem design, etc) Different schools do it differently, so the above is just a real-world example I'm familiar with. What I ask is: Is there a need for distinct majors in programming?


Service layer design

I am developing an MVC website in PHP, and for the first time, I would like to implement a service layer. I have some design considerations I would like to get some advice on. The backend will by no means be a large enterprise system, so I am looking to keep things relatively simple while still leveraging the benefits of a service layer. The idea is that my controllers will interact with services, which in turn will interact with DAOs. My main question is how granular my services should be. I am familiar with the concept of service granularity in SOA, but have never implemented this in practice. For instance, to handle user registration, should I have a `RegistrationService` class, or should I have a `UserService` which contains a `register` method along with other user-related services? The former approach means that I will have a service layer full of small or fine- grained services, but I guess that is a good thing. The latter seems to hinder service reuse and result in large classes with many methods. Instead, perhaps I should combine the two approaches to ensure that my services can be reused? For instance, have a `RegistrationService` which interacts with a DAO class. Then, I could have a `UserService` class with a `register` method. This method interacts with the fine-grained `RegistrationService`. This way, the `RegistrationService` can easily be reused to compose more coarse-grained services. Surely there are examples where the reuse would be more likely; for instance, placing an order would need to use/orchestrate many different services. I guess you could call this a "layered" approach, which I have seen discussed before. Could I structure this in a way such that my service layer will not become a mess? I would love to hear your thoughts on this, whether you have other suggestions, recommendations and experiences or comments on the ideas I presented above. Thank you in advance.


Does setting a function public affect the C# compiler's ability to inline the function as an optimization?

This could be either for the .NET or Mono compilers. I know that under certain conditions the compiler can inline functions (e.g. small, single call site, etc.) as an optimization. However, if the function is public, then it needs to have an external entry point. In these cases, is duplicated code generated (public entry point which isn't used by the internal code since the internal code uses the inlined version), or does marking it as public prevent the compiler from doing such an optimization?


Writing my problem solving approach on paper?

I'm a freshman Computer Science student and we just started doing some actual projects in Python. I have found I'm very efficient when I use the pen and paper method that my professor suggested in class. But when I can't write my problem down and work my algorithms out on paper I am really slow. During labs, I always seem to have to take the assignment back to my dorm. When I get there and write it out I solve the problem that took me the whole class in like 5 minutes. Maybe it's because I get stressed seeing people solving labs before me. Or maybe it's the pen and paper method. I was browsing through forums and someone wrote that if you have to write your programs on paper then you shouldn't be a programmer. I'm really worried because I'm so much better when I can see what the program is doing and track my way through it before typing actual code. Am I doing something wrong? Edit: Sorry for being unclear, but when I said writing on paper I meant my problem solving approach (e.g writing examples, making tables with values, etc.) not my actual code. I just use the paper to get my ideas out.


How to do locking and not use a database?

I have a project which involves re-writing pretty much all the back end of a legacy application. It uses XML for persistence and was originally written as a single user system. With one large XML file that could be accessed by multiple users and hence get corrupted, I was thinking about introducing a SQL database where a user could work on his resource and let the database worry about concurrency. With the short deadlines, I was wondering if we could keep the xml persistence (as well as all the business logic) and introduce locking in some other way. Is this possible?


In the context of semantic versioning, does a change in the default configuration warrant a new major version?

My module is enabled by default (i.e. when you add the module). There's also a configuration you can _optionally_ use, which supports an `enabled="true|false"` setting. This way the module can be disabled after it's been added, without the need to remove the module. But I realized the module doesn't play nicely with another module that is also enabled by default. I am considering changing my module so it's not be enabled by default. This would break for anyone that has not explicitly enabled it with the `enabled="true"` configuration setting. Should I wait for v2.0 for this? semver.org mentions the public API and breaking changes, not configuration. Is it generally accepted that configuration is part of the public API?


Writing Testable Code vs Avoiding Speculative Generality

I was reading some blog posts this morning, and stumbled across this one: > If the only class that ever implements the Customer interface is > CustomerImpl, you don't really have polymorphism and substitutability > because there is nothing in practice to substitute at runtime. It's fake > generality. That makes sense to me, as implementing an interface adds complexity and, if there is only ever one implementation, one might argue that it adds needless complexity. Writing code that is more abstract than it needs to be is often considered to be code smell called "speculative generality" (also mentioned in the post). But, if I'm following TDD, I can't (easily) create test doubles without that speculative generality, whether in the form of interface implementation or our other polymorphic option, making the class inheritable and its methods virtual. So, how do we reconcile this tradeoff? Is it worth it to be speculatively general to facilitate testing/TDD? If you're using test doubles, do these count as second implementations and thus make the generality no longer speculative? Should you consider a more heavyweight mocking framework that allows mocking of concrete collaborators (e.g. Moles versus Moq in the C# world)? Or, should you test with the concrete classes and write what could be considered "integration" tests until such time as your design naturally requires polymorphism? I'm curious to read other people's takes on this matter -- thanks in advance for your opinions.


How to prevent corrupting an hierarchical XML tree?

We have an XML tree which stores the relationship between folders and video files. So each folder could be the artists name and below it we have the videos of the artist. Also each folder can have other sub folders. This tree structure can be accessed by multiple users where some users could be deleting videos, others moving videos between folders and others possibly renaming folders. What I need is a mechanism where I lock parts of the tree when one user is working on it and when multiple users all work on their parts of the tree, when they make their changes, the tree is not corrupted. Is this possible to implement when using XML?


Learning a new concept - write from scratch or use frameworks?

I have recently been trying to learn about MVVM and all of the associated concepts such as repositories, mediators, data access. I made a decision that I would not use any frameworks for this so that I could gain a better understanding of how everything worked. I’m beginning to wonder if that was the best idea because I have hit some problems which I am not able to solve, even with the help of Stack Overflow! **Writing from scratch**   I still feel that you have a much better understanding of something when you have been in the guts of it than if you were at a higher level. The other side of that coin is that you are in the guts of something that you don't fully understand which will lead to bad design decisions. This then makes it hard to get help because you will create unusual scenarios which are less likely to occur when you working within the confines of a framework. I have found that there are plenty of tutorials on the basics of a concept but very few that take you all the way from novice to expert. Maybe I should be looking at a book for this? **Using frameworks**   The biggest motivation for me to use frameworks is that they are much more likely to be used in the workplace than a custom rolled solution. This can be quite a benefit when starting a new job if it's one less thing you have to learn. I feel that there is much better support for a framework than a custom solution which makes sense; many more people are using the framework than the solution that you created. The level of help is much wider as well, from basic questions to really specific, detailed questions. I would be interested to hear other people's views on this. When you are learning something new, should you/do you use frameworks or not? Why? If it's a combination of both, when do you stop one and move on to the other?


Why Does Microsoft Frequently Use Generic Product Names?

Microsoft seems to use such generic names for their core products that it seems like it must be or have been part of a deliberate strategy. It is so common that I think it may have originated as a way to overawe some business customer or junior college striver -- who vaguely knows that SQL servers exist -- that SQL servers are Microsoft-specific products. Same with mail exchange server. Namely: SQL Server (most general term possible, despite which they claim a trademark) Exchange Server (see rfc's from the 1980's onward describing mail exchanges and calling them precisely that) Windows (the generic term used with windowing applications since their invention) Office (if you are inclined to protest that it's really Microsoft Office, go to the product splash page and look for the word 'microsoft') Has anyone ever come across a discussion of this from someone involved in the early naming decisions or marketing, or have any knowledge if this is in fact a pattern intended to associate in the public's mind core general technologies with Microsoft products (while stretching the outermost limits of trademarkability)?


If one is to learn a new programming language each year, what should the list be?

In chapter one of "The Pragmatic Programmer" the first learning goal is: > **Learn at least one new language every year.** Different languages solve > the same problems in different ways. By learning several different > approaches, you can help broaden your thinking and avoid getter struck in a > rut. [...] To achieve this over a career, the list of languages is likely to get quite long (particularly if you do not want to "progress" into management). Clearly the education of a programmer (or whatever form) is going to get you started with a core of commercially useful languages (the usual list from job posting: C, C++, Ruby, Python, JavaScript, C#, Java, VB, ...). Additionally a formal or informal learning programme is likely to have covered functional approaches (via something like Haskell, LISP or an ML derived language) But once a reasonable subset of that list is learned- what's next, _and why_?


How to teach programming a person who completed CS studies but for 5 years was working in other profession?

I have a colleague who want to go back to programming after 5 years of doing something else. Five year ago he was working with C++ / linux, delphi, and a lot with mSQL . He asked me to help him to go back to programming. I started to support him (in C# and Java) but I see that he is less and less motivated to practice. Probably he is getting frustrated about slow progress or overwhelm by things he had forgotten. I am looking currently for a way how to encourage him. Currently I think about two possible approaches:   1. find an opensource project that he can start to work    2. set up a project together (e.g., on assembla.com) and try to develop together something that is interesting for him.  Maybe I should advice him to start with script languages (e.g., groovy, jython) that let to program faster and to not write so much boiler code?


Best way to bring an idea to a corporation

I have this idea that will change education and hopefully generate a lot of money, but there is absolutely no way I can develop it without the help of a certain company. Is there a way to bring it to them, and protect my IP at the same time? I don't want them to steal it. I suppose I could apply for a patent...


How to design my code so that it can use alternative information to help create an object

I have a class named `Product`, which takes a product model number and number of wheels for that product as part of its creation information, and then it instantiates the product by doing a computation on the number of wheels and on various base parameters For example, `Product(5, 22)` creates a model 5 product with 22 wheels on it, where that particular product's weight and dimensions are _computed_ from the number of wheels and from the base specifications for that model number. Right now base specifications are part of the class itself and are hardcoded into the class, along with the computation formulas. My Issue: in the (legacy) code I am working with, I cannot always use the model number directly. It may not be available. Instead, an unrelated `product_id` is given, where the link between `product_id` and `model_number` is in the database. I want to keep my class as simple as possible. As such I do not want to introduce another constructor that allows `product_id` as an input parameter, in addition to the existing `model_number`, as it will be duplication of code. Also, I am not too keen on putting database logic inside the class, but maybe I can, as thinking about it now, this may be a good candidate for a database- wrapper class, i.e. active record (where my base specifications can be moved off from the code and into the database). Question: How do I create and return the object while following good object oriented principles when the `model_number` I typically use for its creation is not available, but another parameter is available instead (`product_id` in this case), which links 1:1 to `model_number`? Sample solutions that I don't quite like:   * Do not involve the database -- since I am working with just a few Products at this time, and Products do not change often, I can create a "conversion function" that serves as a map between `product_id` and `model_number` and not touch the database. Similarly, create a `Convert` object that has same functionality and use it before creating the object. Problem: duplicating DB functionality in the code.   * Put DB functionality inside code and add alternate constructor. Problem: multiple entry-points of Product creation for the class create code duplication.  **Update:** There basically are 3 aspects here:   * base data (whether hardcoded or part of the database)   * finding base data by various parameters be it model number or other identifying information   * doing computation using base data as per model number


brackets in php templates

I have a script, and now it's the perfect time to have an option to change `theme` templates. I was looking forward to store these files in `php` files, or html files. with `CSS` file. I looked over some codes and I found that they use brackets to refer to the variable. Here's an example of a template block:
     {title}     {content}
      I know that I can use `PHP` vars usering `<?=$var;?>`. However, I think the one above is better, and I looked over the web to find anything about it but I couldn't. My Question is how I can use these brackets in my php or html code. to let the user changing the template only not the code!


Can AfferoGPLv3 code be used in GPLv3 code?

Can software with AGPLv3 license be used with GPLv3 project? Can the resulting project be GPLv3, or must it have the special requirements of AGPLv3? I am not very smart from clause 13 of GLPv3 that mentions AGPLv3. > Notwithstanding any other provision of this License, you have permission to > link or combine any covered work with a work licensed under version 3 of the > GNU Affero General Public License into a single combined work, and to convey > the resulting work. The terms of this License will continue to apply to the > part which is the covered work, but the special requirements of the GNU > Affero General Public License, section 13, concerning interaction through a > network will apply to the combination as such. Must the resulting, combined work be AGPLv3 or not?


What are the methods to estimate source code value?

I've been working on some project on my free time for the past few months. Recently I've been approached by friends to build a startup, and this source code would be very valuable to us. As a co-founder, this code could count for something in the company's capital, and be exchanged for shares. But how can you estimate its value? Do you just multiply industry-standard wages by the time I spent on it, or are there other methods?


Why should most logic be in the monitor objects and not in the thread objects when writing concurrent software in Java?

When I took the Realtime and Concurrent programming course our lecturer told us that when writing concurrent programs in Java and using monitors, most of the logic should be in the monitor and as little as possible in the threads that access it. I never really understood why and I really would like to. Let me clarify. In this particular case we had several classes.               Lift extends Thread     Person extends Thread     LiftView     Monitor, all methods synchronized.      This is nothing we came up with, our task was to implement a lift simulation with persons waiting on different floors, and theses were the class skeletons that were given. Then our lecturer said to implement most of the logic in the monitor (he was talking about class Monitor as THE monitor) and as little as possible in the threads. Why would he make a statement like that?


Performing client-side OAuth authorized Twitter API calls versus server side, how much of a difference is there in terms of performance?

I'm working on a Twitter application in Ruby on Rails. One of the biggest arguments that I have with other people on the project is the method of calling the Twitter API. Before, everything was done on the server: OAuth login, updating the user's Twitter data, and retrieving tweets. Retrieving tweets was the heaviest thing to do since we don't store the tweets in our database, so viewing the tweets means that we have to call the API every time. One of the people in the project suggested that we call the tweets through Javascript instead to lessen the load on the server. We used GET search, which, correct me if I'm wrong, will be removed when v1.0 becomes completely deprecated, but that really isn't a concern now. When the Twitter API has migrated completely to v1.1 (again, correct me if I'm wrong), every calls to the API must be authenticated, so we have to authenticate our Javascript requests to the API. As said here: > We don't support or recommend performing OAuth directly through Javascript > -- it's insecure and puts your application at risk. The only acceptable way > to perform it is if you kept all keys and secrets server-side, computed the > OAuth signatures and parameters server side, then issued the request client- > side from the server-generated OAuth values. If we do exactly what Twitter suggests, the only difference between this and doing everything server-side is that our server won't have to contact the Twitter API anymore every time the user wants to view tweets. Here's how I would picture what's happening every time the user makes a request: ![setup](http://i.imgur.com/qH2yB.png) If we do it through Javascript, it would be harder on my part because I would have to create the signatures manually for every request, but I will gladly do it if the boost in performance is worth all the trouble. Doing it through Ruby on Rails would be very easy since the Twitter gem does most of the grunt work already, so I'm really encouraging the other people in the project to agree with me. Is the difference in performance trivial or is it significant enough to switch to Javascript?


How to avoid jumping to a solution when under pressure?

When under a particularly strict programming deadline (like an hour), if I panic at all, my tendency is to jump into coding without a real plan and hope I figure it out as I go along. Given enough time, this can work, but in an interview it's been pretty unsuccessful, if not downright counter-productive. I'm not always comfortable sitting there thinking while the clock ticks away. Is there a checklist or are there techniques to recognize when you understand the problem well enough to start coding? When is it most productive to think and design more vs. code some experiments and figure out the over-all design later? Here is a list of techniques for taking a math test and another for taking an oral exam. Is there is a similar list of techniques for handling a programming problem under pressure? **ANSWERS:** I think this is a valid answer: How To Solve It. I found that link as an answer to Steps to solve or approach towards a solution. There were also some really good tips at Is thinking out loud during an interview really the best strategy?. A great and concise argument for TDD is the first answer to TDD Writing code vs Figuring out the answer to a problem?.


C# or .Net features to cut off assuming no backward compatibility needed?

Any product or framework evolves. Mainly it's done to catch up the needs of it's users, leverage new computing powers and simply make it better. Sometimes the primary design goal also changes with the product. C# or .net framework is no exception. As we see, the present day 4th version is very much different comparing with the first one. But thing comes as a barricade to this evolution- backward compatibility. In most of frameworks/products there are features would have been cut off if there was no need to support backward compatibility. According to you, what are these features in C#/.net? **Please mention one feature per answer.**


Best software for licence and user management?

I am currently working on implementing a web shop on my site to sell some software products. This web shop needs a customer and a product database so it can give licenses to users. It would be time consuming for me to implement this user, product and license management system from the scratch so I am asking, for those who have experience with this kind of stuff, what are considered to be the best out of the box products? EDIT Here are some additional details. All of the software is developed in house, so source code integration is possible but this part is already present. Software will check for a valid licence etc. I already have a code that will generate licenses. I am asking about the "server side" of the problem. Let mi clear that up. There are two kinds of software being sold:   1. Desktop applications - User goes to the web shop, enters credit card data and buys an licence for one of these applications. Then user enters the license and application works.   2. Web based applications - User goes to the web shop also enters credit card data and then user gets an username and password so he can login to the web application and use it. I need a central database of all the buyers and all the licenses that they bought. So is there any system (in form of a web application) that can manage buyers in that way and provide a API for a web shop (or any other application) to query the database, add new buyers, add new licenses ...


Recently I've been working on projects that heavily use threading. I think that I'm OK at designing them; use stateless design as much as possible, lock access to all resources that more than one thread needs, etc. My experience in functional programming has helped that immensely. However, when reading other people's thread code, I get confused. I am debugging a deadlock right now, and since the coding style and design are different from my personal style, I am having a difficult time seeing potential deadlock conditions. What do you look for when debugging deadlocks?


Group messaging of computers over internet

I want to be able to send messages between computers on the internet network but with minimal functionality requirement are- 1)computers can join/leave the group (I expect the group size to be a maximum of 5-10) 2)any message generated by any computer will be sent to every other node (this is the main requirement and I have short messages which need to be sent in shortest possible time: suggest network layer protocol to be used here), message wont be resent or ack (except leave)..but I still want to maintain high reliability, can I maintain it without receiving acks? one problem would be to communicate on the internet I will need some sort of NAT support? how can this be managed without a stun server? Should I use a p2p library? as I think most of the features they offer wont be needed by me could anyone suggest some here? I'm working in C++.


Quit my job (for a new job). Old job wants me to be available for contracting. Steps to take?

The company I am leaving has asked that I make myself available to answer questions and/or debug programs occasionally should the need arise. I'm not opposed to this. After searching google for some kind of standard contract for this sort of thing, I didn't see any. Is there a standard contract for this sort of thing that you use? Are there any other steps I should take to ensure this kind of arrangement works smoothly?


Best way to delimit variable elements of a path in code documentation?

Often some element of a path is variable, but the path as a whole needs to be documented in some manner for later programmers. Especially when using *nix systems, almost any character is a valid symbol for the path. Given that, I would like to delimit the variable portions of my path to prevent misunderstanding, but in a way that also survives best across different display environments (especially the browser). Methods I have seen include (example path in users home directory):   * /home/<username>/foo - needs special escape for web browser context   * /home/your_username/foo - unfortunately the variable element tends to be overlooked   * /home/{username}/foo   * /home/:username/foo Which have you seen most often or had the most success with and why? If a double delimiter method (which seems to be the most common/successful), what lead your choice of delimiters?


Biggest mistake you've ever made

Similar to the question I read on Server Fault, what is the biggest mistake you've ever made in an IT related position. Some examples from friends: > I needed to do some work on a production site so I decided to copy over the > live database to the beta site. Pretty standard, but when I went to the beta > site it was still pulling out-of-date info. OOPS! I had copied the beta > database over to the live site! Thank god for backups. And for me, I created a form for an event that was to be held during a specific time range. Participants would fill out the form for a chance to win, and we would send the event organizers a CSV from the database. I went into the database, and found ONLY 1 ENTRY, MINE. Upon investigating, it appears as though I forgot an auto increment key, and because of the server setup there was no way to recover the lost data. I am aware this question is similar to ones on Stack Overflow but the ones I found seemed to receive generic answers instead of actual stories :) What is the biggest coding error/mistake ever…


Why normalization improves numerical precision?

I was reading the following article: Polynomial interpolation of GPS satellite coordinates, Milan Horemuz and Johan Vium Andersson 2006 and it states the following: "The estimation procedure of the ai coefficients is done with the Matlab function polyfit, which estimates the coefficients in a least squares sense. **To improve the numerical precision, the dataset p is normalized** by centering it at a zero mean; by subtracting its mean value p; and scaling it to a unit standard deviation by dividing each observation with the standard deviation σp as follows..." My question is how does the value normalization improves the numerical precision of computational operations?


Should the methods of a class call its own getters and setters?

Where I work I see lots of classes that do things like this:               public class ClassThatCallsItsOwnGettersAndSetters {              private String field;              public String getField() {             return field;         }              public void setField(String field) {             this.field = field;         }              public void methodWithLogic() {             setField("value");             //do stuff             String localField = getField();             //do stuff with "localField"         }     }      If I wrote this from scratch, I would have written the `methodWithLogic()` like this instead:               public class ClassThatUsesItsOwnFields {              private String field;              public String getField() {             return field;         }              public void setField(String field) {             this.field = field;         }              public void methodWithLogic() {             field = "value";             //do stuff                         //do stuff with "field"         }     }      I feel that when the class calls its own getters and setters, it makes the code harder to read. To me it almost _implies_ that complex logic is happening in that method call even though in our case it almost never is. When I'm debugging some unfamiliar code, who's to say that the bug isn't some side effect in that method? In other words, it makes me take lots of side trips on the journey of understanding the code. Are there benefits to the first method? Is the first method actually better?


What to do with private fields with getters and setters in Java

When are Getters and Setters Justified is an excellent question which focuses on using getters and setters as part of the external interface. What I am struggling with is ... by having getters and setters there is now multiple ways to update the state of the object since private fields can updated directly bypassing the setter or can be updated by the setter. Take the example below ... _size is the private field and it has two methods `getSize()` and `setSize(int size)`. If incrementing _size is coded up like the `increment` method, all is good. On the other hand, using `increment2` can put Order into an illegal state. Is there a way to prevent developers from accidentally bypassing the getter / setter and use the private fields directly!? If not, what convention should be used to ensure that the object is never put into an invalid state?               public class Order {              private int _size = 0;              public int getSize() {             return _size;         }              public void setSize(int size) {              if (_size < 0)                  throw IllegalArgumentException("...")                  _size = size;          }              public void increment(int increment) {             setSize(getSize() + increment);         }              public void increment2(int increment) {             _size = _size + increment;         }                     }


How faster is an 'if' construct compared to an immediate 'if' statement (IIF) and when should I use it?

How does the traditional `if` statement compare with that of the _immediate if statement_ (IIF, the one usually written as `condition ? value_if_true : value_if_false`) in terms of speed of execution? Also, in what scenarios should we be ideally using the IIF?


Best way to store revision information for quick access to view or revert changes

What I am looking for is the most optimal solution for storing content revisions in an MSSQL database. We have an application that allows users to make changes to small HTML content blocks similar to a wiki, but we need to have tight audit control over the changes. At any point in time, the manager might want to look at previously submitted contents or revert the entire HTML block back to the previous state. I had it setup in the past where we had a primary table that stored the HTML information (along with various other meta tags) and then an audit table that kept a copy of the entire data row everytime a change was made. What I am wondering is if this is the best way to go, or should I just keep 1 table with all the current records and the changes in it and just have a flag that lets me know which one is the current one?


Are "Clean Code" practices really that clean and useful?

I am currently doing an internship in a large corporation and they are undergoing many changes in software delivery structure (moving to Agile). In the past couple of months I have noticed this religious attachment to `Clean Code` practices and the book being like a bible for the developers. Now, one of the most important features of the clean code is self-explanatory code which is based on understandable naming and rigorous re-factoring. This is followed by `no commenting` rule. I understand that this clean code is a long term investment which will ease following code maintenance and improvement, but... is this really worth all this fuss? Would anyone share their experience on Clean Code and any opinion whether I am just too conservative or it is just a temporary trend.


In freelance software development, what kind of penalties should firms have when they miss deadlines?

I was talking with a co-developer. He has a client that wanted to make sure that he delivers on time. The client wants repercussions for missed deadlines. While I do not do freelance work, I couldn't give an answer. So, my question is: What repercussions do you (freelancers) agree upon with your client if you miss deadlines on your deliverables (aside from being fired)?


How many types of programming languages are there?

Basically, I want to learn lots of programming languages to become a great programmer. I know only a handful to depth and **I was hoping someone could elaborate on how many _classes_ or _types_ of programming languages there are**. Like how you would lump them together if you had to learn them in groups. Coming from a Java background, I'm familiar with static typing, but I know that in addition to dynamic typing there has to be such variety in available languages that I would love to see a categorical breakdown if possible.


Just how bad is it not to Dispose() SqlConnections?

Personally, I break out in hives if I don't put ADO objects that implement IDisposable in using statements. But at my current contract, I've found that their homegrown enterprise framework "data access provider" code does not 1) implement IDisposable and 2) call Dispose() on anything it uses, at any point, ever. Users have been complaining a great deal about performance issues in the Winforms applications that heavily use this framework for data access, and though there are a LOT of other problems in the code that could be hitting performance, this one just screams at me and is more low-hanging-fruit than the others. So, beyond saying something like "Dispose is there for a reason, use it," what can I tell these people to convince them that this is really, really bad?


When to stop reviewing code?

I am working in a team of 4 members. we have started reviewing code 2 months ago. we are using Gerrit as code review tool. while reviewing code initially we have found lot's of problem in the code i.e. no proper code comments. method are too big. no null pointer checking. no proper exception handling etc. but now a days it looks code has improved. so when i am reviewing code i am not getting that much problem in the code. so my question is should we continue code review even there is not that much flaws in the code? or will we stop?


How should someone used to FP thinking read imperative code?

I graduated from university about five months ago, and have been working in a local startup for past four months. While at university, I studied Haskell, F# etc on my own. We were taught Java at the university, but I was exposed to functional programming very soon, and have spent far more time with it than I did with imperative programming. As a result, my brain is wired for a functional thinking. The company I have joined uses Python, and the code is heavily imperative. I am having a very hard time reading imperative code. I cannot keep a track of mutations. When an for-if-else-for-... nesting goes more than four levels deep, I completely lose the track of what's happening in the code. To add to it, Python is a dynamic language, so there are no types in the code. It's been weeks since I have been trying to understand a part of our codebase (which is supposedly 'moderately complex'), but I haven't made any appreciable progress so far in understanding it. Please offer me some practical techniques on how I should go about understanding that code. Thanks in advance! **Edit:**   Maybe I should also mention that there aren't really many comments in the code, and the names are also not very intuitive.


I am in a situation where I have a Web Application (WAR) that is accessing a REST service provided by another application. The REST service uses Basic HTTP Authentication. So that means the application calling the REST service needs to store user credentials somehow. To further complicate things, this is an enterprise, so there are different 'regions' the application moves through which will have different credentials for the same service (think local development, development region, integration region, user test region, production, etc...) My first instinct is that the credentials should be stored by the JEE container and the application should ask the container for the credentials (probably via JNDI?). I'm beginning to read about Java Authentication and Authorization Service (JAAS) but I'm not sure if that is the appropriate solution to this problem. How should a JEE application store credentials for logging in to an external system? * * * A few more details about my WAR. It is a Spring-Integration project that has no front-end. The container I am working with is Websphere. I am using JEE 5 and Spring 4.0.1. To this point I have not needed to consider spring-security... does this situation mean I should re-evaluate that decision?


MVC: my controller seems useless half of the time. Is this a problem?

Often when I design a program with MVC, the controller is useless half of the time. What I mean is this: something happens on the view (e.g. a button click). The view then notifies the controller. The controller then directly delegates to the model and does nothing else because it has nothing to do. For example: User presses button 'Color Blue' > view tells controller `controller.colorBlue()` > controller tells model `model.colorBlue()` > model colors something blue. In this example, the controller seems useless. It adds nothing. The view might as well have talked straight to the model. The other half of the time, however, the controller _does_ do some kind of mediation between the view and model. My question is this: how common is this in MVC structures? **Is it reasonable that half the time my controller seems unnecessary? Or is this a problem?** Is this common? How should I approach this? If my question isn't clear enough, please say so.


Shouldn't Android's TextView.getText() return String instead of possibly mutable CharSequence?

I've just spent hours debugging some code because I forgot (actually never considered it) that `TextView.getText()` returns `CharSequence` that may be in fact a mutable class... Shouldn't it return (immutable) `String` instead? I mean I can't imagine a situation when you want to share a state with a text field, at least not by default. Isn't that something that can be objectively called a design mistake in a library?


How do we isolate dependencies for a .Net app deploy in a way which is safe for a strongly-named assemblies?

To design in such that it is easy to deploy dependencies with your app, and so that development environments are easy to set up, it is advantageous to isolate an app's dependencies from it's environment. That means the app can get its dependencies from a package manager, and it will not be affected by it's deployment environment (such as the GAC). This principle comes from the Dependencies section of the very interesting "Twelve-Factor App" standards. In .Net, I guess this would mean explicitly specifying to use dependencies from the bin folder of an app? I am concerned that this might cause problems for shared, strongly-named assemblies. In this Microsoft article, Ferrandez says locking conflicts can occur if apps do not share strongly-named assemblies via the GAC, since the assembly is loaded into a shared domain. The 12-factor app describes the pieces needed to satisfy this principle as a _dependency declaration manifest_ and a _dependency isolation tool_. Does anyone have an established setup for isolating dependencies which is working for you, and is safe for strongly-named assemblies? Are we in the .Net world stuck with separating all our apps into VM's to achieve isolation? * * * > Personal context: I maintain a SAAS app where each server instance runs a > few services/apps which engage in some inter-process communication. They > have some strongly-named dependencies in common. Having the dependencies in > the GAC makes deployment complex, setting up dev environments a pain, and > restricts freedom to choose deployment environments. Even without the strong > naming or shared dependency issue, I am interested to know how people do > dependency declaration and/or isolation. Thanks!


Is agile more than just small waterfalls?

I've mostly used the waterfall methodology on my projects, but now I'm expanding my horizons into agile methodologies. From what I've read so far, and maybe I've read the wrong things, agile means small waterfalls. Instead of a big waterfall spread over one or two years, you have small waterfalls that last weeks or maybe a few months at most. Is my understanding correct or is there more to it than that? What are the agile philosophies?


Understanding the Open Game License

I'm thinking about using the basic mechanics behind the D20 system royalty- free, however, I'm unsure if the OGL allows that. Any thoughts appreciated. And if I can't use the D20 system royalty-free, then any suggestions on other well tested systems appreciated as well.


Do you use project management on your personal projects?

I got some projects at home, and I want to get them done already.   I was wondering, is it common to use project management for this?   Even though it would only be for me, do you use some kind of project management   for personal projects?


How are operating systems compiled and booted the very first time?

I'm interested in how operating systems work. I've been reading some articles about Linux and seem to understand how it all generally comes together, but I feel like there's a chicken and egg dilemma when it comes to constructing an operating system. Since Linux is written in C (and Assembly), which needs a compiler to be compiled, how does one actually compile an operating system for the first time? Do you first write a boot loader out of your existing OS? Or do you do something else? Do you have to dual-boot for the first time? Or you need two machines? What did Linus first end up with when he started his project? What did his very first result look like? What's the very first thing you need to design and write when you're programming an Operating System?


Is it a good idea to schedule regular time to clean up code?

I'm managing a small team of developers. Every so often we decide we're going to spend a day or two to clean up our code. Would it be a good idea to schedule regular time, say 1 week every 2 months, to just cleaning up our codebase?


Writing an API that is syntactically valid in multiple programming languages

I'm planning to write a single API that is syntactically valid in most major programming languages (to the greatest extent possible, so that only minimal amounts of code will need to be re-written when moving from one language to another). I think the simplest way to do this would be to write a group of functions that consisted entirely of function calls and variable assignments, since the syntax for function calls is almost exactly the same in all major programming languages. Of course, I'd need to write "wrapper" functions for if-statements and while- loops, since the syntax of each of these is different in each programming language. Here's a proof-of-concept for one "polyglot" function that should work in most programming languages:               //JavaScript syntax     function proofOfConcept(){         printSomething("This is just a proof of concept."); //the function printSomething will         //                      need to be implemented separately in each programming language.     }          //Java syntax     public static void proofOfConcept(){         printSomething("This is just a proof of concept."); //the function printSomething will         //                      need to be implemented separately in each programming language.     }          //Python syntax     def proofOfConcept():         printSomething("This is just a proof of concept."); //the function printSomething will         //                      need to be implemented separately in each programming language.          //C syntax     void proofOfConcept(){         printSomething("This is just a proof of concept."); //the function printSomething will         //                      need to be implemented separately in each programming language.     }      Would this be a useful design strategy, or is there a better way to do this? I think this would be a useful strategy for developing libraries in multiple programming languages, althogh it would require a small number of "language- specific" functions to be written for each target language.


Why would more CPU cores on virtual machine slow compile times?

[edit#2] If anyone from VMWare can hit me up with a copy of VMWare Fusion, I'd be more than happy to do the same as a VirtualBox vs VMWare comparison. Somehow I suspect the VMWare hypervisor will be better tuned for hyperthreading (see my answer too) I'm seeing something curious. As I increase the number of cores on my Windows 7 x64 virtual machine, the overall compile time **_increases_** instead of decreasing. Compiling is usually very well suited for parallel processing as in the middle part (post dependency mapping) you can simply call a compiler instance on each of your .c/.cpp/.cs/whatever file to build partial objects for the linker to take over. So I would have imagined that compiling would actually scale very well with # of cores. But what I'm seeing is:   * 8 cores: 1.89 sec   * 4 cores: 1.33 sec   * 2 cores: 1.24 sec   * 1 core: 1.15 sec Is this simply a design artifact due to a particular vendor's hypervisor implementation (type2:virtualbox in my case) or something more pervasive across more VMs to make hypervisor implementations more simpler? With so many factors, I seem to be able to make arguments both for and against this behavior - so if someone knows more about this than me, I'd be curious to read your answer. Thanks Sid [ _edit:addressing comments_ ] @MartinBeckett: Cold compiles were discarded. @MonsterTruck: Couldn't find an opensource project to compile directly. Would be great but can't screwup my dev env right now. @Mr Lister, @philosodad: Have 8 hw threads, using VirtualBox, so should be 1:1 mapping without emulation @Thorbjorn: I have 6.5GB for the VM and a smallish VS2012 project - it's quite unlikely that I'm swapping in/out trashing the page file. @All: If someone can point to an open source VS2010/VS2012 project, that might be a better community reference than my (proprietary) VS2012 project. Orchard and DNN seem to need environment tweaking to compile in VS2012. I really would like to see if someone with VMWare Fusion also sees this (for VMWare vs VirtualBox compartmentalization) **Test details:**   * Hardware: Macbook Pro Retina      * CPU : Core i7 @ 2.3Ghz (quad core, hyper threaded = 8 cores in windows task manager)     * Memory : 16 GB      * Disk : 256GB SSD   * Host OS: Mac OS X 10.8   * VM type: VirtualBox 4.1.18 (type 2 hypervisor)   * Guest OS: Windows 7 x64 SP1   * Compiler: VS2012 compiling a solution with 3 C# Azure projects      * Compile times measure by VS2012 plugin called 'VSCommands'     * All tests run 5 times, first 2 runs discarded, last 3 averaged


Does Java promote a separation between class definitions and implementations, as is  C++?

I have a homework assignment and I need to evaluate which approach is better according to GRASP "Protected Variation". I found a question on Stack Overflow about the separation of header and code files in C++. However, what I want to know why Java does not follow C++ in promoting the separation between class definitions and class implementations. Are there any advantages with the Java method, over the C++ method?


What was the earliest use of cryptographic tokens in URLs?

I was wondering: it now seems to be more and more common to see people/framework putting cryptographic tokens in the URLs their webapps are generating (to prevent quite effectively against quite some attacks). It is advised by OWASP etc. However I was wondering: what was the earliest known usage of this technique (specifically inside Web URLs)? I've found a message on Usenet dating from 2003 (for a Java webapp) describing the technique by someone who, obviously, independently discovered it (he's asking for know "prior art"):               Every single link in any of the jsp page transmitted to the client is      generated with a checksum that act as a signature for the URL      The description clearly shows it's a cryptographic checksum being used (and the way it works seems very close to the modern "tokens" OWASP advocates etc.). Interestingly enough the person describing it says that "it cannot hurt" but that it may not be that useful since that Java is relatively immune to buffer overflow. The author couldn't have imagined that this technique would has stopped most XSS and CSRF exploits dead in their track way before these techniques were even invented... So my question is simple: what are the oldest know usage of this technique you know of? **EDIT** Upon re-reading the old description, I think in that message from 2003 the technique is even more advanced than the "per-session tokens" that OWASP advocates in that every single parameters are checked against forgery (but I'm not sure)


Which version of Java should I use for learning?

I am a QA engineer interested in mobile development and automation.I have basic programming experience (intermediate level Python, C++ programmer) and as most companies choose Java for writing frameworks I need to pickup Java. I use Ubutnu 12.04 LTS and I will be using Head First Java as learning material. When I searched for JDK options I found Oracle Java 6 and 7 and Open JDK. I read somewhere in Ubuntu forums that Java 6 is not recommended on Ubuntu systems and I am a little bit confused about which version should I use, that would be compatible with the book and the OS.


All programming functions always return to the If or If/Else statement?

After learning, coding, and coding even more than ever now, I have noticed a trend in a lot of programming which I do. The trend is that the _majority_ of my functions are `if{}` or `if{} else{}` statements when it comes to performing the functions in my code. I narrowed out the option of it just being the project which I am working on. The project is building a PHP Framework or Application (whichever you want to call it). The vast majority of my code for the `autoloader.php`, `application.php`, and all of the _heavy-lifting_ files are performing their functions of making sure everything loads correctly and builds the environment. After working with very complex functions within my code to do this and that, they are all wrapped within an `if{}` or `if{} else{}` statement. Is this a common trend for the majority of programming? Or am I over reacting to something which I am seeing a lot of? Does the most complex functions in coding always go back to the basics of the legendary `if{}` or `if{} else{}` statement?


Decoupling when constructors have non-contractual parameters

By non-contractual parameters, I mean parameters that are not interfaces or service dependencies, something like `class Person(string name)`. I am writing a webpage scraping application, and so far I've written it in the wrong order (hence the creation of this question). I made a class to parse HTML documents (from string format) and give me all the urls and images in it. That class has the following description:               public class PageParser     {         private readonly string _html;              public PageParser(string html) {             _html = html;         }              public IEnumerable<string> GetImages() {             /* not important */         }              public IEnumerable<string> GetLinks() {             /* not important */         }        }      This code works great, unit-tested, 100% coverage, etc... The problem is now how do I write unit-tests for code that uses this class without worry about the constructor of this class. I only need this new class to work with the behavior of the `PageParser`. The pseudo code for this new functionality is as follows:               public Report CreateReport(string url)     {         var html = _webClient.DownloadString(url);               var parser = new PageParser(html);                var images = parser.GetImages();         var links = parser.GetLinks();              var relevantLinks = links.Where(l => l.Contains('something'));              return _reportBuilder.Create(images, relevantLinks);     }      The problem that I have is I don't want to have a bunch of unit-tests that have epically sized HTML documents for all my various test cases the `CreateReport` method can have. The options I have come up with are: **1) Leave everything as is** Leave the class structure as is, just live with having tests with large setup variables **2) Expose the page parser (+interface) from a Factory** Create an interface for `PageParser`, and create a factory with corresponding interface.               interface IPageParserFactory     {         IPageParser Create(string html);     }          class PageParserFactory : IPageParserFactory     {         IPageParser Create(string html)         {             return new PageParser(html);         }     }      Then the resulting pseudo code would look something as follows.               // ... download string          var pageParser = _pageParserFactory.Create(html);          // ... create report      **3) Move the parameter html to each method and create an interface** (so now the class has no construction dependencies)               interface IPageParser     {         IEnumerable<string> GetImages(string html);         IEnumerable<string> GetLinks(string html);     }      **4) Something else entirely** If there's another pattern that solves this problem I would like to know it.


Should I make package private my DAO interfaces?

I have several DAO classes that implement an interface. In the other hand, I have Service classes that use those DAO implementations. So far all the DAO interfaces are public and I was thinking if would it be better to make them package private and to put the service classes in the same package so they are the only ones being able to use them. The reason is because I wouldn't like that programmers could use DAO implementations in a Controller or a web service without using the service layer. A programmer could think for example that adding a new order is as simple as calling the addOrder dao method, ignoring that indeed there is a service method that does more than that. What do you guys think?


Algorithmic approach for text analysis of ingredients and instructions

# Background Looking to separate lists of ingredients from instructions. Users scan recipes from 3x5 cards, magazines, cookbooks, etc. OCR software converts scanned images into plain text--typically a single text paragraph without line breaks (see below for an example). # Problem Users must manually separate the list of ingredients from the instruction text. I would like to automate this step as much as possible (perfection not required; reducing manual effort by 80% is a win). # Assets System assets include:   * 350 culinary verbs (e.g., cook, boil, mash)   * 400 equipment nouns (e.g., bowl, thermos, toothpick)   * 8300 normalized ingredient nouns (i.e., no plurals, no duplicates)   * Natural Language Processor that parses ingredients into quantity, measure, noun, and adjectives. # Ideas   * Use a neural network and unsupervised training   * Use Bayesian statistics to separate the ingredients from instructions   * Use word clustering with text mining techniques? # Question What algorithm(s) would provide the greatest accuracy to identify the most likely boundary between ingredient and instruction text? # Input Example input text produced by the OCR:               Maple-Roasted Parsnips with Pecans and Cranberries Earthy parsnips roasted until tender with cranberries, pecans and spices would make a nice side dish for roast pork, Cornish hen, turkey or chicken, baked ham, or baked salmon fillets. Preparation time: 15 minutes, plus soaking time Cooking time: 40 minutes Makes: Six servings 1/3 cup dried cranberries 1 1/2 lbs parsnips 1/4 cup maple syrup 1/4 cup chicken or vegetable stock 2 Tbsp lemon juice 1 Tbsp melted butter 1/4 tsp ground cinnamon 1/8 tsp ground nutmeg I salt and freshly ground black pepper to taste 1/2 cup pecans halves 1 Tbsp chopped fresh parsley or mint LYLE STAFFORD, TlMES COLONIST Maple-Roasted Parsnips with Pecans and Cranberries make a nice side dish to complement pork, Cornish hen, baked ham or salmon fillets. Place the cranberries in a bowl. Cover with one cup of warm water and let stand at room temperature one hour. Drain cranberries and reserve. Preheat oven to 375 F. Peel parsnips and cut lengthwise in half. Slice the parsnips, widthwise, into 1/2-inch pieces. Place the parsnips in a 9x13-inch baking dish. Add the maple syrup, stock, lemon juice, butter, cinnamon, nutmeg, salt and pepper, and mix to combine. Roast the parsnips, uncovered, 20 minutes. Mix in the pecans and cranberries and roast 10 minutes more. Give the parsnips a stir and then roast another 10 minutes, until nicely glazed and tender. Spoon into a serving dish, sprinkle with parsley or mint, and serve. Curried Parsnip and Apple Soup with Almonds, Yogurt and Mint Mild, curry-spiced, Indian-style parsnip soup accented with sweet apple, fresh mint, rich almonds SUNDAY, FEBRUARY 3, 2013 B3 cooking with parsnips and tangy yogurt. Preparation time: 20 minutes Cooking time: 25 minutes Makes: Six servings 3 Tbsp vegetable oil 1 lb parsnips, peeled, halved lengthwise and sliced 1/2 medium onion, chopped 1 Tbsp coarsely chopped fresh ginger 2 Tbsp all-purpose flour 1 Tbsp mild curry powder 4 1/2 cups chicken or vegetable stock 1 Tbsp lime juice 1 large or 2 small red apples, peeled, cored and cubed I salt to taste I plain yogurt to taste 1/4 cup toasted, sliced almonds (see note) 2 Tbsp chopped fresh mint Place the oil in a medium to large pot set over medium heat. Add the parsnips, onion and ginger and cook until softened, about five minutes. Mix in the flour and curry powder and cook and stir two minutes more. While stirring, slowly pour in the stock. Mix in the lime juice and apples. Bring the soup to a gentle simmer. Simmer soup until the parsnips and apples are very tender, about 15 to 20 minutes. Purée the soup in a blender or food processor, or in the pot with an immersion blender. Return the soup to a simmer; season with salt. Ladle the soup into bowls. Top each bowl with a dollop of yogurt, and a sprinkling of almonds and mint, then serve. Note: To toast the almonds, , place in a non-stick skillet set over medium heat. Cook the almonds a few minutes, swirling the pan from time to time, until lightly toasted. Q) 1] 3 ~§ lp to . CS ‘ I V ® ?aii§‘;?’§‘7e-SF E E d fragrant, ‘DO ‘YOU ‘V C LIAC -°DI EASE‘? \\ , , : V'' N ‘\ ''» / 5 i \ \


Defining a random "safe" path for a game character

I am writing a game in Java and it can be likened to the recently popular game "Flappy Bird" in the sense that the character moves up and down and the users touch and must avoid the obstacles. The obstacles are going to be asteroids of varying sizes. I want to spawn these in at a random y co-odinate and with a random size, and then have them move across the screen. The character must then avoid these. It cant be completely random however as that may result in an non-traversable path. Thus I thought it would be best to define a random safe path first and then fill in the surrounding area with these obstacles. Is this the best approach to solving this problem, and if so is there correct and efficient way of doing this?


On implementing a dynamic proxy in PHP

I'm trying to implement dynamic proxies in PHP and I'm running into a problem of implementing interfaces. My current approach to building a dynamic proxy is by having a class which uses the __call magic method. The issue is that this class implements no interface and/or extends no other class. So if I have a method which accepts only objects of a certain type through PHP type hints, I cannot pass an object of my dynamic proxy type. One case I'm currently dealing with is a LazyLoader class, which checks the method being called to see if it should perform the loading procedure. My data source method for loading a user, instead of returning a User object, returns a LazyLoader object, which will load the user's friend list lazily. Many other data source methods will do similar things. The issue is that, there, I return a LazyLoader object and not a User object. So whenever I use a data source object to load a User object, I'll get back a LazyLoader object, which I can't pass to methods/functions which take a type hinted User parameter. Any way to dynamically make a LazyLoader object "be a" User? **Edit:** I could make several kinds of lazy loaders which extend the right class. For example, I could have a UserLazyLoader, a FinanceSheetLazyLoader and so forth. This is a possibility, but I'd like to see if I could solve this issue in a more generic way first.


Is hiring a junior developer as a technical trainer a good idea?

So my friend's boss brought in four junior candidates with some work experience, she is one of them. Her manager wants them to be experts on the subject matter of tomcat in a matter of two months in order to justify them as billable to other clients as a technical trainer. My biggest concern is this, they only have a year to no experience in development but no production support experience. Is it possible to turn these greenhorns into gurus in a short amount of time with the use of text and forums? Also they don't have a proper sandbox to play with, i.e. any servers. I am helping in my spare time but I don't feel she has enough time to become a SME. What can I do to help her become an expert or what can I say to her that the position may not be a good fit?


Looking for an information system for collaborating on files metadata

I am looking for an information system which has the following features:   * upload files and add custom properties depending on file type (e.g., author, composer, painter, singer);   * support for sructured properties (e.g., `painter` is not just a string, it is an object with own properties: firstName, lastName, dateOfBirth, placeOfBirth, etc.);   * describe third-party files (given their URLs);   * version control of descriptions;   * search for files and other objects by their properties;   * edit descriptions of files created by others (ability to edit depends on one's reputation, as on StackExchange);   * voting on files (influences reputation), flagging them. I was thinking about implementing it myself using Semantic Web technologies, but still can't believe that there is no very similar system. If there is no such a system, are there any components that I could reuse? If it does matter, I prefer Python, but most software in Semantic Web world is written in Java, so I resigned to the fact that I will have to write some code in Java.


Why did javascript libraries like knockoutjs, backbonejs, and angularjs only come out in 2010?

Being a relatively new web-developer I am surprised that these libraries didn't exist before. Is there a particular technical or historical reason that at around Sep 2010, a sudden development and interest in client-side javascript RIA applications and libraries? http://www.google.com/insights/search/#q=backbonejs%2Cangularjs%2Cknockoutjs%2Cjquery%20tmpl&cmpt=q


How to submit a part of project based when other parts are not completely implemented yet

I have been given an online task in which I am supposed to develop a service which is based on some other class/service which has not been implemented yet but I have a rough API for that and the results return by my class would be used by some other class/service I am not sure what would be the best way to return this. I mean shall I have some dummy/mock implementation for the service I am expecting or using in my class and also for the service that would use the result returned by my class or is it Ok to just develop my part and assume things based on the rough API spec. For example : I am in Team C and have to implement CService service. My class will call Team A's AService service (this is not implemented yet but I have a rough spec for this) and the results returned by my class would be used by Team B's service.


Using Statement lambda in exception handling

Following is a code snippet from MVP Win Forms application and this explanation would be helpful when answering the questions. My DAL doesn't handle exceptions and it will be propagated up to the calling method in the presenter classes where the exception will be handled. I'm using a single handler called `ExecutAction(Action action)` so I'm catching exceptions in one place rather than repeating code in every method. At the moment, I'm not logging errors. Just alert the user for an action and try to keep the system alive if possible. When showing messages to users, Presenters will use a static class called `MessagingService`. (`ShowErrorMessage()`). So that I can customize all massage boxes in one place.                       private void Search()             {                 ExecutAction(() =>                 {                     var info = _DataService.GetByACNo(_model.AccountNumber);                              if (info != null)                         {                             _Model = info ;                             this.SetViewPropertiesFromModel(_Model, _View);                         }                         else                         {                             MessageBox.Show ("Bank account not found");                         }                     });                 }                           private void ExecutAction(Action action)                 {                     try                     {                         action();                     }                          catch (NullReferenceException e) { MessagingService.ShowErrorMessage(e.Message); }                     catch (System.Data.SqlTypes.SqlTypeException e) { MessagingService.ShowErrorMessage(e.Message); }                     catch (System.Data.SqlClient.SqlException e) { MessagingService.ShowErrorMessage(e.Message); }                 }             }      Should I include general exception handler to this, to be able to handle any unforeseen exceptions? Also could you show me a better way to handle showing messages than using a static? Does use of lambda statements in every method call (`ExecutAction(() =>`) degrade code readability? When showing user messages how to show a custom message like "Check the server connection" etc. first and then if the user wants more information (like StackTrace / technical details) he /she could press a button like `More Info` which is in the MessageBox dialog?


putting methods in base class that doesnt make sense/belong there

I've been lately thinking over design principles and patterns and a question did strike me. Let us say, I want to design a racing game. I want to design the classes for a variety of cars.   * each car may have different feature   * the most common features can be put in the base class - 'Car' Now, I learned that you should always strive to work with abstractions. All the code that tries to manipulate the car will try to call the abstract methods on `Car` like `Car.Accelerate()`, `Car.TurnLeft()`, etc... But what about the specific features? Like some cars might have rocket thrusters or a parachute and you might want to use them (I know this sounds ridiculous, but my point here is 'There might be special features in derived classes that might not justify the actual type(or base type) of that specific class')? So, what about them? Would you rather raise few more abstract methods in base class making it less cohesive, or would you put some if blocks and type casts (to get the actual class object and use that method) making it more coupled?


Explaining technical things to non-technical people

I often have to explain technical things and technical decisions to my _extremely_ non technical manager and I'm pretty awful at it. What are good ways to essential dumb things down for the rest of the world who don't have a passion for programming? Example questions I've been asked:   * Why are you using Django instead of Java (Didn't accept that it was cheaper either)   * Asking me to rephrase things in non technical words, my sentence was "Certain HTML tags are not allowed". How can I possibly dumb that down?   * Other stuff that makes perfect sense to me, but is just _so_ basic I don't know how to explain it   * Why this, why that, why everything! Also, how do I tell my manager to look the basic stuff up on Google, like "What is Pylons?" I'm ready to rip my hair out, these questions are driving me insane!!


Resources for up-to-date Delphi programming

I'm a developer in a small department and have been using Delphi for the last 10 years. Whilst I've tried to keep up-to-date with movements there are a lot of changes that have occurred between Delphi 7 and (current for us) 2010. Stack Exchange and here have been great for answering the "how do you" questions, but what I'd like is a resource that shows great examples of larger scale programming. For example is there anywhere that hosts examples of well written, multi form applications? Something that can be looked at as a whole to illustrate why things should be done a certain way?


Is it okay to call functions when event occurs, or after that?

So I was not sure how to structure this title, feel free to edit it. My question is: When I have a Game Loop, I have 3 main blocks. Handle Events, Update game state, and draw. Let's say for example I check for keyboard/mouse events, and I want to move my character when buttons are pressed. Whenever `KEYDOWN` event occurs, should I immediately call `Player.move`? Or should I toggle `move_left/move_right bools`, and then call `Player.move` when I'm in the Update game state block. I was wondering this becouse, for example a function performs a long algorithm and I call it when an event occur's, calling the function will take some time, and meanwhile I might press more button's/events. I think I will lose some of those events becouse in that time the algirthm function was runing. Or, I can toggle a bool when the event occurs, and after checking for ALL events, I perform functions based on the bools. PS: Feel free to edit this post in a more constructive question.


Why aren't there automated translators from one programming language to another?

Most programming languages are Turing complete, which means that any task that can be solved in one language can be solved in another one, or even on Turing machine. Then why aren't there automatic translators that can convert programs from any given language to any other language? I've seen couple attempts for two languages, but they always work only on a limited subset of a language and can hardly be used for converting real projects. Is it possible, at least in theory, to write 100% correct translator between all languages? What are the challenges in practice? Are there any existing translators that work?


What is (was) an update channel?

I was checking out what version of Firefox I'm using and it was telling me that I'm on the 'release update channel'. So I googles "Update Channel" and I finds this seemingly antiquated MSDN article which has a confusing bit of ASP.NET pre-processed into the article to give you the sense that you both should not use this technology and should never have used this technology. > Microsoft Active Channel technology is obsolete as of Windows Internet > Explorer 7 and should not be used. Users want an easy and convenient way to > download and install new versions of software. Software Update Channels are > specialized channels that you can use to notify users of software updates > and also deliver and install the updates on their computers. Users who have > downloaded your software and subscribed to your Software Update Channel are > notified when new versions of your software become available. When notified > of an update, users can click a gleaming icon representing your channel, > which returns them to your download site so they can obtain the new version. > Users can also choose to have software updates delivered and installed on > their computers automatically. > > Active Channel technology is obsolete as of Internet Explorer 7 and should > not be used. This article introduces you to the terminology, benefits, and > implementation of Software Update Channels. After reading this article, you > will understand how easy it is for users to discover and interact with this > technology, and you will know how to create your own Software Update > Channels. Links to relevant overviews, references, and tutorials are > provided at the end of the article. So, I ask you. Is this still some sort of metaphor for getting software easily to your clients. If I store the info for my programs updates in a database, is there existing non-obsolete Microsofty technology that could take a generated XML file and tell people using my software that there are updates available and you should probably download them?


Should a primary key be immutable?

A recent question on stackoverflow provoked a discussion about the immutability of primary keys. I had thought that it was a kind of rule that primary keys should be immutable. If there is a chance that some day a primary key would be updated, I thought you should use a surrogate key. However it is not in the SQL standard and some RDBMS' "cascade update" feature allows a primary key to change. So my question is: is it still a bad practice to have a primary key that may change ? What are the cons, if any, of having a mutable primary key ?


When should I copy a pointer inside a function?

I'm trying to teach myself programming and I'd really appreciate some help with this issue. I've just read a tutorial on pointers but I have a problem with the example. The function copies one string to another. In the original function a copy is being made with ptr. What is the meaning of this? because as far as I can see it's unnecessary. Is there anything wrong with my revised function or am I missing something? //Tutorial example               char *my_strcpy(char *destination, const char *source){         char *ptr = destination;         while(*source != '\0'){             *ptr++ = *source++;         }         *ptr = '\0';         return destination;     }      My revision               void my_strcpy2(char *destination, const char *source){              while(*source != '\0'){             *destination++ = *source++;         }         *destination = '\0';     }      Thanks.


Is there a 'boilerplate' lightweight NDA I can use to cover sharing proprietary code with a third party?

I want to engage a freelancer to work on some software that was developed internally. We're agreed that it'll be difficult for them to quote/estimate the work without access to the existing source code, and I'm happy to give them access to that code but would like something on paper before I do so. There is nothing in the code that's hugely confidential or sensitive, but it would be negligent of me to share our code without getting them to acknowledge in writing the terms under which we're sharing it. Does anyone have, or know of, a one-side, "lightweight" NDA that they've used to cover sharing of code at the pitch/estimate phase of a job before? I'm in the UK, so ideally UK law but I'm happy adapting something. Yes, we have lawyers. Getting them to write something is hugely expensive. Getting them to read something is much cheaper.


What's the best way to design a data and php model for a multi-account system?

I'm doing some high-level sketching of a system that will require users to register, when they do they get an account and can invite others to that account. To be clear, an account would be similar to a private workspace, and the users will belong to that account and cannot exist outside of that account. The users will be identified by a unique username (likely their email) and this will give them access to the account on a one (account) to many (emails / users) basis. Each record generated in that account is visible only to those users who belong to that account. Is there a good pattern for modeling this type of system? Being extremely new to programming, I'm imagining a field in each table that references the account #, but this makes virtually every entity a one to many. Is there a better way?


How should I handle the publishing of an iPhone app under someone else's name?

I've agreed to build an iPhone app for a client that was referred to me. I'm a full-time software engineer by day, but this is only my 2nd iPhone app and I agreed to do it without upfront funding as it would give me a project to further learn the API as well as increase my portfolio of iPhone apps. The client suggested as payment, that we split the profits 50/50. Normally I would not think this was fair but in a situation like this, I was ok with it since my family's life does not depend on it. As we are nearing the end of development on the app, I asked the client if they would prefer their personal name be put on the project, or if they minded that it was my name (since I have the developer license). Naturally, they requested their name. I've not told them all that that entails because I would relinquish management of the app and profit divisions to them. My question to this community, and pardon if this is not the proper place, is **am I going about this the right way?** **Should I request a partnership be setup?** **Should I insist my developer name goes on it? What would you do?** Additionally, I'm going off of his word that this is a niche product with high demand (its in the medical field) so we will be able to charge a bit more for it.


Where is sympy library used?

I'd admire the functions of sympy library, what it does is really awesome. The integration functions are really few guys intellectual work. But where exactly we use them practically on computers? If not sympy, do we really need such libraries? If we need them, what languages would satisfy our needs?


In .net, why can't values of intrinsic data types (such as DateTime) be null?

First the history: I found out DateTime data types cannot be null (Yes they can be nullable using the ? nullable declaration). I was told this is because they are value types and placed on the stack (not on the heap). I can understand why the stack is quicker and why value types need to (mostly) be placed on the stack, what I do not know is.   1. Is it true the real limitation of why a value type cannot be null is because the stack cannot handle null values?   2. If yes - Why? If No what is the real limitation.  I understand in .net we often don't care about exact memory allocation, yet it is important in performance applications to take the stack and heap into consideration, so I'm trying to wrap my head around this. Thanks in advance for your expertise on a difficult question. EDIT: Another thing to add are nullable types hence placed on the heap or stack?


Implement a file system for ios devices

I've read that ios apps can communicate via unique urls. An online tutorial on tutsplus says > Communication between apps provides your application with an opportunity to > take advantage of other application’s functionality, send and receive data > between apps, and provide a rich user experience that “just works”. I have to admit that since I have no experience with objective c and cocoa I only scanned the article. But as far as I've understood the url based communication, your app can register a unique url that serves as a socket for communication. Is this not the perfect basis for a crude file system ? I know that all ios apps run in a sandbox and can only access their own data. I do recognose the merits of this design decision but still it seems cure and curse at the same time. This is not meant to be a discussion about apple's ecosystem and the concept of ios apps. **My question is simply:** Can url communication be used to create a file storage that works like a simple "desk" ? I would love an app that could store and host my files to allow a simpler workflow between different apps. Is this technically possible or did I misunderstand the url system ? Would apple allow an app like this in the app store ?


Teaching software concepts: formal definition is a necessary evil?

Recently I had to teach what my PM declared a "Best Practices Course" on programming. I decided to have them read a chapter per week of Uncle Bob's Clean Coder book while I followed a somewhat related syllabus during that week e.g. if a chapter of the book is about object orientation then I teach the S.O.L.I.D. principles; if a chapter covers testing then I teach BDD. Anyhow, when I asked for feedback I drew a lot of criticism because I always gave the "formal" definition of the concept e.g. > Let q(x) be a property provable about objects x of type T. Then q(y) should > be provable for objects y of type S where S is a subtype of T. And then tried to explained somewhat but a little less formally: > If we have a type B being a subtype of A, then we should be capable of doing > anything with B that we can do with A. And in the test I scored some answers like these: > if you give me the formal definition of the concept, you get a 0.7 points; > if you give me a non-formal definition of a concept you may get 0.7 points > based on the completeness. The rest of the point is by giving an example of > the concept. Thus everyone thought this was somewhat unfair as I somewhat pushed for memorizing definitions. Of course this was not my intention but I believe that completeness was a requisite as in previous tests they answers in form of wandering examples e.g.: > Having a lot of code in the function indicates that it is doing a lot of > things and also have a lot of concerns; making difficult to apply changes in > the code to have a better function very difficult. And this somewhat could have been better understood by citing the separation of concerns and single responsibility principles along with refactoring. Thus, I tend to believe that knowing the concepts formally and have a clear relation of the concept and the meaning is indicative of good communication skills and professionalism. Which is somewhat a goal of the course: that they communicate the ideas better by using established concepts. So, are formal concepts a necesary evil or I just screwed and should have managed the score differently?


What stage of development do activity network diagrams belong to?

Activity network diagrams are used to determine the forward and backward paths for a project, and consequently to determine the critical path or maximum time to development.      I'm already familiar with using work breakdown structures which break down functional requirements into necessary and sufficient deliverables, but I'm unsure of what stage of project planning activity network diagrams fit into.   for clarity my interpretation of the planning cycle.: https://docs.google.com/file/d/0B6m1-u6HxISZeGNCQ2JudXNyZ1U/edit?usp=sharing Please could someone help me clarify this matter?


In what language should I name my business classes?

I'm requesting best practice with this question. This is only an issue if the customer company is strictly national has a native language other than English, I think. If the customer has a lot of mainly very domain specific (say, German) expressions, mixed with some lesser domain specific namings. The language of our code comments, class/method/variable names is English. Would you translate all domain specific names?