title: Are there any .NET based framework for working with English language?

text: I'm writing a web application in which I need to analyze words (now just in English, but maybe in future in any language). I tried to write a framework to do the job, but it soon proved to be something really really hard. Finding stems, understanding part of speech, finding consonants, determining morphological patterns, etc. It's really getting harder with each new requirement. Is there any framework out there (preferably compatible with .NET or PHP frameworks) for working with human languages (English for example)? Some common methods of such framework could be:               List<Synonym> synonyms = SynonymFinder.FindSynonyms("Help");     Stem stem = MorphologyAnalyzer.GetStem("Determining");     Pronunciation pronunciation = Phonetics.Transcribe("Speech");


title: Using automated bdd-gui-tests to keep user-documentation-screenshots up do date?

text: Are there developpers out there, who (ab)use the `CaptureScreenshot()` function of their automated gui-tests to also create uptodate-screenshots for the userdocumentation? Background: Whithin the lifetime of an application, its gui-elements are constantly changing. It makes a lot of work to keep the userdocumentation uptodate, especially if the example data in the pictures should match the textual description. If you already have automated bdd-gui-tests why not let them take screenshots at certain points? I am currently playing with webapps in dotnet+specflow+selenium, but this topic also applies to other bdd-engines (JRuby-Cucumber, mspec, rspec, ...) and gui-test-Frameworks (WaitN, WaitR, MsWhite, ....) Any experience, thoughts or url-links to this topic would be helpfull. How is the cost/benefit relation? Is it worth the efford? What are the Drawbacks? See also: Is it practical to retroactively write specifications documenting a system via automated acceptance tests?


title: Scientific evaluation of programming methodologies

text: There are now a a variety of programming methodologies: Scrum, Extreme Programming, Kanban to just name a few. Most of them combine several more basic techniques (for example frequent iterations). However, nearly all of them state that their combination of technics is the only way to write good software. I don't think that there is one way that's best for each and every project. Instead I'm interested in independent scientific evaluations.   * What basic techniques work best for which kind of project?   * Is there any advantage in the combination of certain techniques? As I don't have time to go through primary literature I'm especially looking for a book. I know that there is Peopleware, but it is a bit old. There are already several related questions (Are there any scientifically rigorous studies of coding style principles?, Scientific evidence that supports using long variable names instead of abbreviations?...)


title: Efficient Summary calculation method or approach?

text: I have an object hierarchy with a number of leaf nodes that will contribute to summary values for the parent object (specifically: project cost and square footage). What's the most efficient way to tally up those values while the project is being designed? ### Additional details                Parent        ListOne          NodeA            NodeA.1            NodeA.2 ...          NodeB            NodeB.1            NodeB.2 ...        ListTwo ...        * There will only be one dot-# leaf node selected at a time, so it will be either NodeA.1 OR NodeA.2 but not both being selected.    * Whether or not NodeA and NodeB are selected are independent of each other. So I could have any combination of selected / active Nodes A -> Z One approach is simply to iterate through each List, each Node, and each Leaf Node and only sum the values when the leaf node is selected. Another approach would be to create an event handler for the parent project variables that each child can then fire against when their values change. The wrinkle here is that I'll have Node specific values that I'll want to track as well. In other words, I'm tracking Project Cost, List Cost and Node Cost. Another approach would be a hierarchy of event handlers that fire as the selected item changes and then notify their parent of the change. So the change in a leaf node would eventually cascade back up to the Project after a number of events having been fired. Right now, the overall project structure is pretty small - only three or four Lists, each with about six Nodes that have four to six Leaf Nodes each. Because of the smaller size, I'm not worried as much about computation time as I am about maintaining this and being able to extend it in the future as more Lists, Nodes, etc... are added. _Edit:_   The project driving this question is written in C# and actually has one more layer between the List and the final leaf nodes. I think the question is relevant to C++ and Java programmers since it's dealing with the responsibilities between children and parent objects when a value of the parent depends upon its children and grand-children. An answer tailored to C# would be gravy, but I'm looking for the most robust / maintainable approach in this case.


title: Is CodeFirst intended for large scale applications?

text: I've been reading up on Entity Framework, in particular, EF 4.1 and following this link ( http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first- development-with-entity-framework-4.aspx) and it's guide on Code First. I find it neat but I was wondering, is Code First supposed to be just a solution for rapid development where you can just jump right in without much planning or is it actually intended to be used for large scale applications?


title: What would the general design for an XSD to C# class converter look like?

text: I am looking to create a simple code generator to convert XSD definitions to C# classes. This is partly as a learning exercise, but I would also like to get some practical use out of it eventually. What would the general design of such an application look like? I assume that I will need to use one of the XML parsers in the .NET framework, but which one? And what will the resulting data structure look like? Will it be an expression tree? From there, what happens? Do I generate code by concatenating strings, or are there better, more sophisticated ways to do it? **Important:** I'm not looking for someone to write code for me (although very brief code samples are welcome, if they are applicable), and I don't need someone to do the research for me. I'm perfectly capable of reading about parsers, expression trees and code generators myself. I just need someone to help me with the broad brush strokes, so that I don't walk into too many blind alleys. I'm also aware of open source projects like XSD2Code, but I'd rather make the attempt myself first, for learning reasons, and because the resulting tool is likely to be highly specific to my particular scenario.


title: Expected sprint completion rate and load in scrum?

text: Recently at work there have been increased focus on completion rate and load on the developers in our sprints. With **completion rate** I mean, if we plan 20 user stories for a sprint, what percentage of these user stories are closed at the end of the sprint. And with **load** I mean, if we have a sprint with 3 developers of 60 hours each, i.e. 180 hours for the sprint, how many hours worth of user stories do we schedule for the sprint. So I am really interested in others experience with this, I guess this is something everybody working with scrum deals with. My question is, what completion rate and load are expected/usual, and how are your team doing with respect to these parameters?


title: How to enrich a simple two endpoint SOAP application to become enterprise level?

text: Imagine you have some exchange of data between two endpoints (webservices or let's call URL). Data can travel in any way (Xml, Json, GET, POST) it doesn't matter. I've got the source code of the first endpoint (I drawed it on the left). The second one is from a third party and will call back my infrastructure on a third endpoint (which is also part of my infrastructure). ![enter image description here](http://i.stack.imgur.com/nZI3k.png) I would like to implement some session / state to relate the first call to their callback. And I would also like to add distributed logging, support for problem solving in a production environment, configuration, performance monitoring, a dashboard, and so on. **What kind of consideration should I do in facing the design of this kind of architecture?** Let me clarify with an example (which answers to @SparKotॐ comment) I should **log** the first call and understand if the third party is calling me back or not. I can do this only if my "3rd party" caller Class (the white box higher on the lef) and the Class called from the "3rd party" (the white box lower on the lef) shares some logging infrastructure. How would you implement this? Possibilities are:   * Share a database    * Share a message queue   * Share a WCF service   * Share some AppFabric cache   * What else?   * Pipeline? Which consideration would you make about this tracking service? Should both my class being hosted on the same server? What kind of question would drive you to design the architecture which transform two simple WebClient.Open request into something which is more traceable and fault tolerant?


title: Coding Convention: C++ Header/Interface Files

text: I'm reading through a PDF on C++ programming from this page on Stanford's site. It says that when you're creating a C++ header file for a library interface, use a `#ifndef` preprocessor command to make sure you don't compile the same interface twice. So, your header would look something like this:               /**       MyFile.h     */          #ifndef _MyFile_h     #define _MyFile_h          // Function prototypes          #endif      But, I've always heard people say that using preprocessor commands like `#define` is (or quickly leads to) bad coding practice. I'm just starting to learn C++, so I don't want to get something ingrained that is bad. **Question: Is it "proper" coding style to use preprocessor commands as above?**


title: In which cases Robolectric is a relevant solution?

text: As you may now, Robolectric is a framework that provides stubs for Android objects, in order to make tests runnable outside the Dalvik environment. My concern is that, by doing this, one can fake a third party library, which is, I believe, not a good practice (it should be encapsulated instead). If you make assumptions about an interface you don't own, which is changed once your test has been written, you won't be always noticed about the modifications. This can lead to a misunderstanding between your implementations and the interface they depends on. In addition, Android use mostly inheritance over interfaces which limits contract testing. So here's my question: Are there situations when Robolectric is the way to go? Here are some links you can check for further information: test-doubles-with-mockito in-brief-contract-tests


title: Enforcing Constraints Upon Data Documents of Various Formats

text: This seems like the sort of problem that must have been solved elegantly long ago, but I haven't the foggiest how to google it and find it. Suppose you're maintaining a large legacy system, which has a large collection of data (tens of GB) of various formats, including XML and two different internal configuration formats. Suppose further that there are abstract rules governing the values these files may or may not contain. EXAMPLE: File A defines the raw, mathematical data pertaining to the aerodynamics of a car for consumption of the physics component of the system. File B contains certain values from File A in an easily accessible, XML hierarchy for consumption of a different component of the system. There exists, therefore, an abstract rule (or constraint) such that the values from File B _must_ match the values from File A. This is probably the simplest constraint that can be specified, but in practice, the constraints between files can become very complicated indeed. What is the best method for managing these constraints between files of arbitrary formats, short of migrating it over to an RDBMS (which simply isn't feasible for the foreseeable future)? Has this problem been solved already? To be more specific, I would expect the solution to at least produce notifications of violated constraints; the solution need not _resolve_ the constraints. ==============================   Sample file structures File A (JeepWrangler2011.emv):               MODEL JeepWrangler2011     {         EsotericMathValueX 11.1         EsotericMathValueY 22.2         EsotericMathValueZ 33.3     }      File B (JeepWrangler2011.xml):               <model name="JeepWrangler2011">       <!--These values must correspond File A's EsotericMathValues-->       <modelExtent x="11.1" y="22.2" z="33.3"/>       [...]     </model>      EDIT: Reflecting on this issue, it seems to me that a software solution would require something like the following:   1. Develop an abstract language to describe the structure of arbitrary formats.   2. Develop an abstract language to describe constraints between files.   3. Develop a tool that consumes format-structure-descriptions (item 1), constraint-declarations (item 2), and a file that maps various files (pointed to by file paths) to a format-structure-declaration and produces a list of violated constraints. It's a fascinating, non-trivial problem.


title: Ruby on rails not popular in big international IT companies?

text: Is the ROR used only in startups or also in bigger companies as well? What should be the reasons of their preference of Java over ROR?


title: Can you use Pi as a crude random number generator?

text: I recently saw this question over at math.SE. It got me thinking. Could Pi be used as a crude random number generator? I mean the results are well known(how long has pi been computed to now?) but, Pi does seem to be quite random when taken 1 digit at a time. Does this make any sense at all?


title: Is it common for a programmer not to know the difference between C and C++?

text: During an interview, I was asked whether I knew the difference between C and C++. I was wondering why such question being asked?


title: Where does the "mm" come from in GTKmm, glibmm, etc

text: I understand that the "mm" suffix [in various GTK-associated C++ binding libraries] _means_ "minus minus," but where exactly does it come from? I understand that there is a _programming language_ called "C--," but if there were bindings (and I'm pretty sure I've seen some), they would be suffixed "--". TL;DR: **Is there some page ongnu.org that explains the "mm" suffix in various C++ bindings or is it just a _de facto_ standard adopted by the open source community with no reasoning behind it?**


title: Migrating from VSS to TFS. What is the benefit of creating separate projects?

text: We have a Visual SourceSafe installation that 4 developers collaborate on. Inside that there are 30 or so independent projects in different top level folders. Is it necessary for us to create a new TFS "Project" for each of those 30 items, or can we simply place them in the same overarching project folder... possibly assigning permissions to each? The reason I ask is because I'm demo-ing the migration now and it takes a long time to migrate and create the "New Team Project" within Visual Studio in order to create a 1:1 correlation. What are the other benefits I may get from using separate projects in TFS?


What are the differences between a while loop and a for loop? It seems to me that they are the same.


title: Best Practices Returning Read-Only Object

text: I have "best practices" question about OOP in C# (but it sort-of applies to all languages). Consider having library class with object that is to be exposed to public, say via property accessor, but we do not want the public (people using this library class) to change it.               class A     {         // Note: List is just example, I am interested in objects in general.         private List<string> _items = new List<string>() { "hello" }              public List<string> Items         {             get             {                 // Option A (not read-only), can be modified from outside:                 return _items;                      // Option B (sort-of read-only):                 return new List<string>( _items );                      // Option C, must change return type to ReadOnlyCollection<string>                 return new ReadOnlyCollection<string>( _items );             }         }     }      Obviously the best approach is "option C", but very few objects have ReadOnly variant (and certainly no user-defined classes have it). If you were the user of class A, would you expect changes to               List<string> someList = ( new A() ).Items;      propagate to original (A) object? Or is it okay to return a clone provided that it was written so in comments/documentation? I think that this clone approach might lead to quite difficult-to-track bugs. I remember that in C++ we could return const objects and you could only call methods marked as const on it. I guess there is no such feature/pattern in the C#? If not why would they not include it? I believe it is called const correctness. But then again my main question is about "what would you expect" or how to handle Option A vs B.


title: What's the difference between a macro and a script?

text: Aren't both just a set of instructions that get executed by some interpreter? (contrary to a full-fledged program, which runs (gets executed) at some computer system?


title: Velocity does not plateau over time, why?

text: I have plotted my team burn up chart and its velocity per iteration. To me it looks really bad (velocity fluctuates a lot). What should I be looking for to diagnose the root cause of this behaviour? ![enter image description here](http://i.stack.imgur.com/68Duo.png)


title: Data representation with C# and WPF

text: I'm developing an application handling DB parts. I retrieve the data from the DB with stored procedures and prepared statements. Now I want to display the data in the GUI. What is the current technology used for that? Does one still use DataSet and DataTable for that?


title: How to learn to explain and differentiate types of design pattern concepts

text: What I have done   1. Identified important patterns to learn   2. Read the books    3. Implemented the patterns using favorite programming language    4. Identified pros/cons    5. Practiced some design patterns in real world projects   6. Found some example in Framework libraries Having done that I still struggle to   1. Explain them to seasoned interviewers   2. Clearly differentiate between structural and behavior design patterns. I believe my communication skill is not that bad, but somewhere I have not understood the concepts clearly. How to learn the design pattern concepts to become capable of what I miss now? (If that matters, I am talking about popular GOF design patterns like Strategy, Decorator, Observer, Command, etc)


title: How to best approach planning and budgeting of software performance optimization efforts?

text: There is a software system that has been with the client for some time now. If is feature-rich, mature, complex enterprise application that client uses in production. Due to the rapid expansion of the client's business the software system in subject cannot handle the volumes efficiently and overall performance does not satisfy the customer anymore. So the customer asks the vendor of the software system for improvements in performance and efficiency of the system. The customer also expects the vendor to prepare a plan and ballpark budget so the cost of such optimizations is roughly known upfront. What do you think is the best approach for such plan and high level budget that one could prepare for the customer? I'm asking the question because I've seen some of this kind of plans before and they are usually very vague and imprecise mainly due to the fact that such exercise is kind of chicken and egg dilemma. In order to know what exactly should be optimized and tuned in complex system the benchmarking, profiling and research is required. And that investigation is also the part of the planned project, so it is impossible to know upfront what efforts can such benchmarking results require to implement improvements.


title: Randomly generate directed graph on a grid

text: I am trying to randomly generate a directed graph for the purpose of making a puzzle game similar to the ice sliding puzzles from Pokemon.   This is essentially what I want to be able to randomly generate: http://bulbanews.bulbagarden.net/wiki/Crunching_the_numbers:_Graph_theory. I need to be able to limit the size of the graph in an x and y dimension. In the example given in the link, it would be restricted to an 8x4 grid.   The problem I am running into is not randomly generating the graph, but randomly generating a graph, which I can properly map out in a 2d space, since I need something (like a rock) on the opposite side of a node, to make it visually make sense when you stop sliding. The problem with this is that sometimes the rock ends up in the path between two other nodes or possibly on another node itself, which causes the entire graph to become broken. After discussing the problem with a few people I know, we came to a couple of conclusions that may lead to a solution.   * Including the obstacles in the grid as part of the graph when constructing it.   * Start out with a fully filled grid and just draw a random path and delete out blocks that will make that path work.  The problem then becomes figuring out which ones to delete to avoid introducing an additional, shorter path. We were also thinking a dynamic programming algorithm may be beneficial, though none of us are too skilled with creating dynamic programming algorithms from nothing. Any ideas or references about what this problem is officially called (if it's an official graph problem) would be most helpful. Here are some examples of what I have accomplished so far by just randomly placing blocks and generating the navigation graph from the chosen start/finish. The idea (as described in the previous link) is you start at the green S and want to get to the green F. You do this by moving up/down/left/right and you continue moving in the direction chosen until you hit a wall. In these pictures, grey is a wall, white is the floor, and the purple line is the minimum length from start to finish, and the black lines and grey dots represented possible paths. Here are some bad examples of randomly generated graphs: http://i.stack.imgur.com/9uaM6.png Here are some good examples of randomly generated (or hand tweaked) graphs: i.stack.imgur.com/uUGeL.png (can't post another link, sorry) I've also seemed to notice the more challenging ones when actually playing this as a puzzle are ones which have lots of high degree nodes along the minimum path.


title: Strategy for building an application to replace a large spreadsheet

text: I'm working on an application that is going to replace a rather large spreadsheet. The spreadsheet is used to budget purchases and things like that. It is the largest spreadsheet I have ever seen, and it required a lot of manual data entry, so this application is going to automate much of that. But as I'm working on this I've noticed its slow going. And I got to thinking this must be a common thing to do many companies will start with something like a spreadsheet, then when they get too big to maintain that, they will get a custom application built. So is there anything out there ( a framework or similar ) that does this sort of thing, migrating a spreadsheet to a custom application. I've had a quick Google but not really seen the kind of thing that I'm looking for. It's too late for this project, but I thought it would be worth having a look for next time. How do you guys tackle this problem?


title: How can Continuous Delivery work in practice?

text: Continuous Delivery sounds good, but my years of software development experience suggest that in practice it can't work. (Edit: To make it clear, I always have lots of tests running automatically. My question is about how to get the confidence to deliver on each checkin, which I understand is the full form of CD. The alternative is not year-long cycles. It is iterations every week (which some might consider still CD if done correctly), two weeks, or month; including an old-fashioned QA at the end of each one, supplementing the automated tests.)   * Full test coverage is impossible. You have to put in lots of time -- and time is money -- for every little thing. This is valuable, but the time could be spent contributing to quality in other ways.    * Some things are hard to test automatically. E.g. GUI. Even Selenium won't tell you if your GUI is wonky. Database access is hard to test without bulky fixtures, and even that won't cover weird corner cases in your data storage. Likewise security and many other things. Only business-layer code is effectively unit-testable.    * Even in the business layer, most code out there is not simple functions whose arguments and return values can be easily isolated for test purposes. You can spend lots of time building mock objects, which might not correspond to the real implementations.   * Integration/functional tests supplement unit tests, but these take a lot of time to run because they usually involve reinitializing the entire system on each test. (If you don't reinitialize, the test environment is inconsistent.)   * Refactoring or any other changes break lots of tests. You spend lots of time fixing them. If it's a matter of validating meaningful spec changes, that's fine, but often tests break because of meaningless low-level implementation details, not stuff that really provides important information. Often the tweaking is focused on reworking the internals of the test, not on truly checking the functionality that is being tested.   * Field reports on bugs cannot easily be matched with the precise micro-version of the code.


title: What are some of the more useful Keyboard Shortcuts for Visual Studio?

text: I keep learning new keyboard shortcuts for Visual Studio and I find some of them increase my productivity a lot. I was wondering what keyboard shortcuts in VS you found useful and why. I know I could find a list of shortcuts online somewhere, but I don't think that would be as beneficial to me as asking here since there are so many shortcuts and I think my eyes would just glaze over trying to read that list. Here are some that are extremely useful to me: **F12** \- Goes to the definition of any class or method. It has saved me so much time searching code files once I found that one out. **Ctrl+M, O|L** \- Expands/Collapses regions in C# or tags in XAML files. I love this feature in XAML files since I can't use Regions in them to make my code easier to read **Ctrl+R, E** \- Builds a property's Get/Set methods for me. That, combined with a few macros, makes building accessor methods a lot less painful **Ctrl+E, D** \- Fixes the whitespaces in code files I also created my own keyboard shortcut to CloseAllOpenFiles since VS2010 moved the Close button on open files and I can no longer keep my mouse in one place and spam-click to close all my open files. Why would they they think its a good idea to put the close button on each tabs and make the tabs various widths....


title: Name for WS pattern where a generic object is returned?

text: Two part question:   1. I am working on a project where the webservices all return a generic object. On success, that object then contains the data returned from the webservice along with additional information such as status messages or qualifiers. On failure, the object contains no data and error messages. What is the name for this pattern?   2. When I think that something I am working on is a common pattern and has a name, what strategies can I use to learn what that name is? I frequently see things that look familiar or common and suspect they have a name and are a common pattern. How can I find those on my own without asking StackExchange?


title: Offline data that will need imported later

text: My existing application is a .NET 3.0 winform app that talks to a WCF service which in turn updates a MS SQL Server database; I can make changes at all spots (Windows client, WCF, server). I've had an inquiry into the possibility of allowing users to work offline and later sync their data back up. I have concerns about stale data mostly as the data is not "owned" by them and another user could have updated the same record while they were offline. I also use NHibernate for my ORM. What are your thoughts as to the best implementation to add a sync feature?


title: How important are design patterns in programming?

text: I'm a university student and I've just started learning about design patterns and im struggling to understand the purpose of them. I have tried researching them but all the resources I have found seem to talk about them in an academic, not professional, way. What is their purpose and are they important to learn?


title: How to handle storing the login data for various projects and web servers?

text: Hello and I'm apologizing in advance if this question doesn't fit programmers section of stackexchange. I'll try to clarify what the problem is by telling a story where the problem originates from. I'm working in a small company (8 people) where we have developers, sys admins and staff that handles day to day calls. The problem is the logins. There are various logins, for example web server root login. Then there's MySQL login, login for apps that we develop and to make the thing even more complex - logins differ from local development and testing versions to the ones that are actually deployed which makes the whole thing even more messier. What's happening is that no one knows all of the logins, and they're either written down somewhere deep on cryptically named files or certain people know them by heart. If someone who knows the login for the thing we need to work with is away (say holiday), the process of retrieving the login becomes a huge mess. Now, we are aware how terrible that is and we're looking into improving our login / project management. The other problem is that not everyone should know all the logins. My question is: how do you (or how would you) handle storing logins such as web server root information, web app admin login etc. in such a way that it's available to everyone within the company, but with restricted access (say, a secretary cannot obtain root details, no offence to secretaries)? P.S. I just spent 3 hours obtaining the login details to change a simple spelling mistake on a project which took exactly 1 second after I had the info. Seeing I can't afford losing any more nerves or time over such seemingly trivial things, I'm begging experienced and smart guys for help. Thanks in advance :)


title: Given C++ '11 Was Approved, Does This Change How A C++ Beginner Learns The Language?

text: I've wanted to learn C++ for awhile and took AP Computer Programming in High School (back when it was C++ and not Java). I enjoy C and just haven't found the time to learn C++ or I'll just fall back on C# where I'm much more productive. My question is this: given that C++ '11 has been approved (although I know not fully implemented) does this change the way I should approach learning C++? I own C++: The Complete Reference By Herb Schildt which is from 1998. Does the newly approved standard make learning from such books less important than some of the newer tutorials/books that include things from the standard? Is there any benefit from learning from the older books?


title: Languages on embedded systems in aeronautic and spatial sector

text: I know that my question is very broad but a general answer would be nice. **I would like to know which are the main languages used in aeronautic and spatial sector.** I know that the OS which run on embedded systems are **RTOS** (Real time OS) and I think that, this languages must be checked correctly by different methods (formal methods, unit tests) and must permit a **sure verification of whole process of a program**.


title: What exactly is bootstrap admin-template and how it is supposed to be used

text: So this is my second ASP.NET MVC 4 project. It's decided that for this one we will use this template and it was said in a way that I felt really stupid for not knowing how exactly this template will help us and what exactly we gain by using it. I'm used to using HTML/CSS for the UI combined with jQuery. Now it seems that instead of jQuery we will be using bootstrap which as far as I understand is just another JS library created from twitter, so if that's it then this part is clear. What I really need to clarify for myself is what exactly this theme is used for, what is offering, why one would want to use such a theme? From what I see in the live demo maybe it's just a stack of premade controls that you can use in the front end along with bootstrap.js and maybe I'm just confused because on the page is shown as much as possible just for presentational purposes. If that's right, still I wonder where I can find info for the current theme, the controls that it offers and the functionality that I get and not least - how to use it. But still those are just my assumptions. What I really need is a clarification on what exactly is this theme for, what is the advantage using it, is there a good tutorials about how to use such themes in the context of ASP.NET MVC 3+. Also any additional info about this theme and generally on using themes in ASP.NET MVC will be much appreciated.


title: How accurate is "Business logic should be in a service, not in a model"?

text: **Situation** Earlier this evening I gave an answer to a question on StackOverflow. _The question:_ > Editing of an existing object should be done in repository layer or in > service? > > For example if I have a User that has debt. I want to change his debt. > Should I do it in UserRepository or in service for example BuyingService by > getting an object, editing it and saving it ? _My answer:_ > You should leave the responsibility of mutating an object to that same > object and use the repository to retrieve this object. > > Example situation:               class User {      private int debt; // debt in cents      private string name;           // getters           public void makePayment(int cents){       debt -= cents;      }     }          class UserRepository {      public User GetUserByName(string name){       // Get appropriate user from database      }     }      _A comment I received:_ > Business logic should really be in a service. Not in a model. **What does the internet say?** So, this got me searching since I've never really (consciously) used a service layer. I started reading up on the Service Layer pattern and the Unit Of Work pattern but so far I can't say I'm convinced a service layer has to be used. Take for example this article by Martin Fowler on the anti-pattern of an Anemic Domain Model: > There are objects, many named after the nouns in the domain space, and these > objects are connected with the rich relationships and structure that true > domain models have. The catch comes when you look at the behavior, and you > realize that there is hardly any behavior on these objects, making them > little more than bags of getters and setters. Indeed often these models come > with design rules that say that you are not to put any domain logic in the > the domain objects. Instead there are a set of service objects which capture > all the domain logic. These services live on top of the domain model and use > the domain model for data. > > (...) The logic that should be in a domain object is domain logic - > validations, calculations, business rules - whatever you like to call it. To me, this seemed exactly what the situation was about: I advocated the manipulation of an object's data by introducing methods inside that class that do just that. However I realize that this should be a given either way, and it probably has more to do with how these methods are invoked (using a repository). I also had the feeling that in that article (see below), a Service Layer is more considered as a façade that delegates work to the underlying model, than an actual work-intensive layer. > Application Layer [his name for Service Layer]: Defines the jobs the > software is supposed to do and directs the expressive domain objects to work > out problems. The tasks this layer is responsible for are meaningful to the > business or necessary for interaction with the application layers of other > systems. This layer is kept thin. It does not contain business rules or > knowledge, but only coordinates tasks and delegates work to collaborations > of domain objects in the next layer down. It does not have state reflecting > the business situation, but it can have state that reflects the progress of > a task for the user or the program. Which is reinforced here: > Service interfaces. Services expose a service interface to which all inbound > messages are sent. You can think of a service interface as a façade that > exposes the business logic implemented in the application (typically, logic > in the business layer) to potential consumers. And here: > The service layer should be devoid of any application or business logic and > should focus primarily on a few concerns. It should wrap Business Layer > calls, translate your Domain in a common language that your clients can > understand, and handle the communication medium between server and > requesting client. This is a serious contrast to other resources that talk about the Service Layer: > The service layer should consist of classes with methods that are units of > work with actions that belong in the same transaction. Or the second answer to a question I've already linked: > At some point, your application will want some business logic. Also, you > might want to validate the input to make sure that there isn't something > evil or nonperforming being requested. This logic belongs in your service > layer. **"Solution"?** Following the guidelines in this answer, I came up with the following approach that uses a Service Layer:               class UserController : Controller {      private UserService _userService;           public UserController(UserService userService){       _userService = userService;      }            public ActionResult MakeHimPay(string username, int amount) {       _userService.MakeHimPay(username, amount);       return RedirectToAction("ShowUserOverview");      }           public ActionResult ShowUserOverview() {       return View();      }     }          class UserService {      private IUserRepository _userRepository;           public UserService(IUserRepository userRepository) {       _userRepository = userRepository;      }           public void MakeHimPay(username, amount) {       _userRepository.GetUserByName(username).makePayment(amount);      }     }          class UserRepository {      public User GetUserByName(string name){       // Get appropriate user from database      }     }          class User {      private int debt; // debt in cents      private string name;           // getters           public void makePayment(int cents){       debt -= cents;      }     }      **Conclusion** All together not much has changed here: code from the controller has moved to the service layer (which is a good thing, so there is an upside to this approach). However this doesn't look like it had anything to do with my original answer. I realize design patterns are guidelines, not rules set in stone to be implemented whenever possible. Yet I have not found a definitive explanation of the service layer and how it should be regarded.   * Is it a means to simply extract logic from the controller and put it inside a service instead?    * Is it supposed to form a contract between the controller and the domain?    * Should there be a layer between the domain and the service layer? And, last but not least: following the original comment > Business logic should really be in a service. Not in a model.   * Is this correct?     * How would I introduce my business logic in a service instead of the model?


title: Does C++ support subtyping?

text: I know it might be a silly question to ask, but I didn't quite get an a absolute clear answer on this matter, so I thought I'd put it here. Does c++ support the subtyping in the sense that it fulfills Liskov's principle fully? I understand how parametric polymorphism, inclusion polymorphism(subclassing and overriding) work in c++ but I'm not entirely sure or understand if subtyping exists in the context of C++. Could you please explain?


title: What is the pattern for a safe interface in C++

text: _Note: the following is C++03 code, but we expect a move to C++11 in the next two years, so we must keep that in mind._ I'm writing a guideline (for newbies, among others) about how to write an abstract interface in C++. I've read both articles of Sutter on the subject, searched the internet for examples and answers, and made some tests. ## This code must NOT compile!               void foo(SomeInterface & a, SomeInterface & b)     {        SomeInterface c ;               // must not be default-constructible        SomeInterface d(a);             // must not be copy-constructible        a = b ;                         // must not be assignable     }      All the behaviors above find the source of their problem in _slicing_ : The abstract interface (or non-leaf class in the hierarchy) should not be constructible nor copiable/assignable, EVEN if the derived class can be. ## 0th Solution: the basic interface               class VirtuallyDestructible     {        public :           virtual ~VirtuallyDestructible() {}     } ;      This solution is plain, and somewhat naive: It fails all our constraints: It can be default-constructed, copy-constructed and copy-assigned (I'm not even sure about move constructors and assignment, but I have still 2 years to figure it out).   1. We can't declare the destructor pure virtual because we need to keep it inline, and some of our compilers won't digest pure virtual methods with inline empty body.   2. Yes, the only point of this class is to make the implementers virtually destructible, which is a rare case.   3. Even if we had an additional virtual pure method (which is the majority of the cases), this class would be still copy-assignable. So, no... ## 1st Solution: boost::noncopyable               class VirtuallyDestructible : boost::noncopyable     {        public :           virtual ~VirtuallyDestructible() {}     } ;      This solution is the best, because it is plain, clear, and C++ (no macros) The problem is that it still doesn't work for that specific interface **because VirtuallyConstructible can still be default-constructed**.   1. We can't declare the destructor pure virtual because we need to keep it inline, and some of our compilers won't digest it.   2. Yes, the only point of this class is to make the implementers virtually destructible, which is a rare case. Another problem is **that classes implementing the non-copyable interface must then explicitly declare/define the copy constructor and the assignment operator if they need to have those methods** (and in our code, we have value classes that can still be accessed by our client through interfaces). This goes against the Rule of Zero, which is where we want to go: If the default implementation is ok, then we should be able to use it. ## 2nd Solution: make them protected!               class MyInterface     {        public :           virtual ~MyInterface() {}             protected :           // With C++11, these methods would be "= default"           MyInterface() {}           MyInterface(const MyInterface & ) {}           MyInterface & operator = (const MyInterface & ) { return *this ; }     } ;      **This pattern follows the technical constraints we had** (at least in user code): MyInterface cannot be default-constructed, cannot be copy-constructed and cannot be copy-assigned. Also, it imposes **no artificial constraints to implementing classes** , which are then free to follow the Rule of Zero, or even declare a few constructors/operators as "= default" in C++11/14 without problem. Now, this is quite verbose, and an alternative would be using a macro, something like:               class MyInterface     {        public :           virtual ~MyInterface() {}             protected :           DECLARE_AS_NON_SLICEABLE(MyInterface) ;     } ;      The protected must remain outside the macro (because it has no scope). Correctly "namespaced" (that is, prefixed with the name of your company or product), the macro should be harmless. And the advantage is that the code is factored in one source, instead of being copy pasted in all interfaces. Should the move-constructor and move-assignment be explicitly disabled the same way in the future, this would be a very light change in the code. ## Conclusion   * Am I paranoid to want the code to be protected against slicing in interfaces? (I believe I'm not, but one never knows...)   * What is the best solution among the ones above?   * Is there another, better solution? _Please remember that this is a pattern that will serve as a guideline for newbies (among others), so a solution like: "Each case should have its implementation" is not a viable solution._ ## Bounty and results I awarded the bounty to coredump because of the time spent to answer the questions, and the relevance of the answers. My solution to the problem will probably go to something like that:               class MyInterface     {        DECLARE_CLASS_AS_INTERFACE(MyInterface) ;             public :           // the virtual methods     } ;      ... with the following macro:               #define DECLARE_CLASS_AS_INTERFACE(ClassName)                                \        public :                                                                  \           virtual ~ClassName() {}                                                \        protected :                                                               \           ClassName() {}                                                         \           ClassName(const ClassName & ) {}                                       \           ClassName & operator = (const ClassName & ) { return *this ; }         \        private :      This is a viable solution for my problem for the following reasons:   * This class cannot be instantiated (the constructors are protected)   * This class can be virtually destroyed   * This class can be inherited without imposing undue constraints on inheriting classes (e.g. the inheriting class could be by default copiable)   * The use of the macro means the interface "declaration" is easily recognizable (and searchable), and its code is factored in one place making it easier to modify (a suitably prefixed name will remove undesirable name clashes) Note that the other answers gave valuable insight. Thank you to all you who gave it a shot. Note that I guess I can still put another bounty on this question, and I value enlightning answers enough that should I see one, I would open a bounty just to assign it to that answer.


title: Handling extremely large numbers in a language which can't?

text: I'm trying to think about how I would go about doing calculations on extremely large numbers (to infinitum - intergers no floats) if the language construct is incapable of handling numbers larger than a certain value. I am sure I am not the first nor the last to ask this question but the search terms I am using aren't giving me an algorithm to handle those situations. Rather most suggestions offer a language change or variable change, or talk about things that seem irrelevant to my search. So I need a little guideance. I would sketch out an algorithm like this:   1. Determine the max length of the integer variable for the language.   2. If a number is more than half the length of the max length of the variable split it in an array. (give a little play room)   3. Array order [0] = the numbers most to the right [n-max] = numbers most to the left  Ex. Num: 29392023 Array[0]:23, Array[1]: 20, array[2]: 39, array[3]:29 Since I established half the length of the variable as the mark off point I can then calculate the ones, tenths, hundredths, etc. Place via the halfway mark so that if a variable max length was 10 digits from 0 to 9999999999 then I know that by halfing that to five digits give me some play room. So if I add or multiply I can have a variable checker function that see that the sixth digit (from the right) of array[0] is the same place as the first digit (from the right) of array[1]. Dividing and subtracting have their own issues which I haven't thought about yet. I would like to know about the best implementations of supporting larger numbers than the program can.


title: Can I use dynamic packages in Delphi if I plan to build my application for cross platform usage?

text: Now I am thinking about architecture of my program. I plan to provide one not only for Desktop usage, but for mobile platforms as well. I want to create a bpl package as separate file. That is I want to have in Windows version next files: program.exe + logic.bpl. It can be usefull because logic.bpl may be often modified, as it is a very important part of my program. Besides other programmers (my friends) will be able to develop their own logic and replace the logic.bpl file to their own. So, there are next questions:   1. Will I have any problems with compiling the program for Android, iOS?    2. How can I build the program with packages for Windows and without packages for mobile platforms with minimal changes in the code?   3. In the case of dll use instead of bpl, are there any advantages/disadvantages for cross platform programming? P.S. English is not my native language, sorry for possible mistakes.


title: Using a column to store the company or a separate database?

text: I am writing an system for the company to put their promotion material on the site, which is like some kinds of CMS. So, I need a database that store their data, but I am considering how to store their data.... First approach is use a single table to store their data, but use a column, like 'company_code' to distinguish the company, another approach is create a separate database for a company.... (Of course, will check the company_code or company table name is existed or not, if yes, will assign a new company_code or company table name by programme.) So, which approach is better? Thanks.....


title: How to prove a Dynamic programming strategy will work for an algorithm?

text: How can I prove that a dynamic programming (dp) strategy for a problem will work or not? For greedy algorithms, we can prove by showing the sub problems exhibits matroid property. Is there any such methods for dp algorithms?


title: How are RDF and RDFS related?

text: I've been reading about Semantic Web technologies such as RDF/RDFS and "ontology", but was wondering how each of these are related? At the moment the terms all seem interchangeable, or I'm not understanding a fundamental concept here.


title: Does this have a name? DRY overloading?

text: public int foo(int x)     {         int defaultValue = 0;         return foo(x, defaultValue);     }          public int foo(int x, int y)     {         return x + y;     }


title: Need to test .properties one by one in every possibility?

text: For example, there are some key-value configuration in .properties file. Such like `someFeatureEnable=true`. It must be bool type value which will be parsed by framework, in my case it's typical Java Spring configuration. Spring will handle the configuration and throw Exception when users set `someFeatureEnable=123`. My question is: if there many properties in .properties file, Is it worth testing them one by one? It's quite troublesome and low priority. The .properties file is always configured by tech administrator stuff. Limited chances that they will mess up the configuration. Thanks!


title: What open source license is best when releasing a framework or library?

text: I am thinking of releasing libraries and frameworks which I have written in Java to other developers. I've spent a lot of time researching what open source licenses are available, and the differences between them, however some advice from real people specifically on this matter would be nice. Basically, I want something that is.. .. easy to understand for other developers .. it's ok for developers to use and modify the code as they wish .. keep my copyright notice in the source code, even though the code gets modified and/or redistributed .. No need to put my copyright notice on the final product in any way, only in the source code as mentioned above .. it's ok to use the framework in a commercial solution, without forcing the commercial solution to be open source as well (for example if Microsoft Windows would use my library, it wouldn't force Microsoft to release Windows as open source) .. You are not allowed to sell the libraries or framework alone (however it is ok to bundle it in your own commercial solution, as mentioned above) .. includes basic "as in" warranty Three questions: 1) Are there any other important license topics that could be good for a library/framework? 2) Which open source license should I pick and why? (I assume the candidates are MIT, GPL and LGLP) 3) With the license, is it ok to distribute the binaries alone (without the source code, to minimize size) or does that go against the "open source" idea?


title: What should I do to get started with Windows 8 app development?

text: I'm looking to get into Windows 8 app development, and from what I understand I should be mastering XAML and C#. Now, there aren't any good tutorials on the internet about Windows 8 yet, but there are a lot of tutorials about WPF, which uses XAML. So what's the best starting point: learning WPF? Or is there something else I should be looking at?


title: Are there any Web Frameworks for beginners?

text: I was wandering if there are any frameworks like Google Web Toolkit to create Web Apps? (Apps like Evernote, Spring Pad, Google Docs, etc.). I am fluent in Java but could learn a new language without much problem. So is there any kind of framework that would allow me to write Web Apps without worrying much about UI element design and client-server communication? I have heard of one-- Vaadin. Is it something like what I am looking for? If yes, are there any alternatives? I'm hoping to make a Web App similar to this: Gantter. Mostly the UI and smooth usability.


title: DDD with ORM where should the business logic go?

text: I have used an MDA (model driven architecture) tool in the past where we modeled via UML and this generated the business entities (our domain model) and the ORM (mapping etc) amongst other things. A lot of the business code and services working on the domain were part of the model and our repositories were returning the business entities (so it would have been impossible to switch out to another ORM (not that we wanted to)). However, now I am starting a project and I want to think in terms of DDD. So far it feels as though I put my business logic in my domain model and via repositories I would work with the ORM (which ever I chose). However, if I wanted to continue to use the MDA tool for the ORM part of the application, the model created here would be very anemic (i.e not contain any business logic). Similarly if I used Entity framework (.net) or NHibernate for my ORM it too would be an anemic model.? I am not sure where you would put the business logic if I just used NHibernate. Am I correct in thinking this way, in other words with DDD all the business logic in the domain and just use the ORM for persistence via repositories?


title: Is there a source for user opinions on commercial enterprise software?

text: It seems like a lot of my clients get roped into buying less-than-adequate enterprise software then dumping it on us (as consultants) to implement. I've seen some of these slick vendor demos where they show off a heavily customized demo app and pass it off as an off-the-shelf solution that does exactly what you need while cleverly hiding the fact that it took thousands of developer hours to build and conveniently ignoring the operational gotchas that will cost you a fortune in maintenance even after you pay them for licenses. I know of sites like Gartner and Real Story Group that will sell you an expert analysis, but I'm looking for a site more like Stack Exchange or Yelp where developers, users, admins, etc give honest feedback on the quality of commercial software and maybe give some insight into pricing and value. Does such a thing exist?


title: Dangers of two Jobs? Violating Company Policy?

text: I'm working for a company full-time and myself part-time. I started learning the Mac OS/Cocoa/Objective-C at work, and then I got the "Brilliant Idea" that I'd like to program for the iPhone. The iPhone stuff is going well, but I'm earning money there because I'm applying skills I learned on the job. What is commonly considered violating company policy on things like this? Is there any danger of the company claiming 'ownership' of my side-job? If I leave the company, could they ask me to stop working at my side business? The company and my iphone stuff are in completely different "areas" but I'm still concerned. What can I do to make sure? What else should I be wary of? Has anyone run into bad stuff like this before? Thanks,


title: How can I reuse generic code for consulting between companies?

text: I am employed full time for company X and approached by company Y to do consulting services to write embedded C for them. While I know the basics of conflicts of interests and the big no-no's of sharing proprietary information, company knowledge and proprietary algorithms, I do have some questions regarding basic generic items that I need to reuse:   * Software architecture: I have a personal preference of layering application, abstraction layer and hardware drivers. I don't want to have to do something different and it is not proprietary to the company. Would this be a problem if shared?   * Generic functions: table look ups, sine/cosine functions, parsers, etc. I wrote all this code myself. Can I copy-paste this or do I have to rewrite, insert random spaces, change indentation, var names, table sizes, etc?   * Function naming: I use a specific naming convention, e.g. MATH_Sin(). However, compiled to a DLL, company X can find a MATH_Sin() function available in company Y's DLL and assume that I copied their code. Do I need to rename all functions to hide any similarities?   * Public knowledge turned into source code: say you find an algorithm on an paper that describes how to search for a pattern in a string and you turned the paper content into source code. Again, would a copy-paste be a no-no here too? Rewrite changing a few things or completely dismiss and find for another way to do it? In the end it is an implementation of public knowledge. I asked around my peers and I cannot get a straight answer on what to do. Software is digital and very traceable and can always be traced back to the developer. Thanks. **Update** : I have approached my manager and HR and they strongly discouraged me to pursue this. They claimed that by using the same skill set (embedded programming or programming in general) for another company, there will be always the opportunity for company X to challenge myself or company Y. I asked then what would NOT be considered a conflict of interest and they answered "You could invest in a restaurant...". Seriously? Company X is a very large corporation. There is no negotiation between employer and company, there is no acceptance of open source/licensed code and it seems they believe they own me and my skill set. While I do agree with some of their reasoning, I do not agree that they own my education and, while employed for them, I can't make use of my basic skills for other endeavors. Therefore I have decided to follow the advice below and open source all my personal code that does not belong to the company nor was written using company equipment or company time. I won't be making money or signing contracts, but at least I can keep my personal code and continue developing my career outside this restrictive environment. Thanks for all answers. Hope this serves as a reference for others pursuing the same goal.


title: Can I perform a code review although I am very inexperienced?

text: I have been teaching myself Python as a first language for 2 years now. So far I have done some online courses (NLP, Design of a Computer Program etc.) and solved some puzzles but never worked with big applications. Yet right now I have the opportunity to do some real work with Python on a project at my university. It's a web app using the Pyramid framework, currently at about 8000 lines. And they are using quite a few tricks that I have never encountered before - stuff like `__metaclass__`, lots of OO stuff that I have no prior experience with. Do you believe that I could still do useful work for the project? And what could I do to prove my worth? **Edit:** The developers on the project are at a different university. The job available at my university seems to be a classic code review job: Check the code for security flaws, style, coherence, efficiency etc.


title: What is the responsibility or benefit of a Tokenizer?

text: Suppose I had a grammar like:               object          { members }      members          pair     pair         string : value      value          number         string     string          " chars "      chars          char         char chars      number         digit         digit number      I could parse the following example: `{ "one" : 1234 }` As far as I understand, I should have the tokens `object`, `members`, `pair`, `value`, `string` and `chars`. Tokenizing the example should produce               object         ->members             ->pair                 ->"one"                 ->"1234"      Parsing the tokens should produce               object         ->pair             ->"one"             ->1234      It seems to me like the tokenizer is either useless or I don't fully understand what a it should do. What is the responsibility of a tokenizer? What is the benefit of a tokenizer over parsing the original string?


title: Omitting "destructors" in C is taking YAGNI too far?

text: I'm working on a medium embedded application in C using OO-like techniques. My "classes" are .h/.c modules using data structs and function pointers structs to emulate encapsulation, polymorphism, and dependency injection. Now, one would expect a `myModule_create(void)` function to come with a `myModule_destroy(pointer)` counterpart. But the project being embedded, the resources that are instantiated realistically should never be released. I mean, if I have 4 UART serial ports and I create 4 UART instances with their required pins and settings, there's absolutely no reason to ever want to destroy UART #2 at some point during runtime. So following the YAGNI (You ain't gonna need it) principle, should I omit the destructors? This seem extremely strange to me but I can't think of a use for them; resources are freed when the device powers-off.


title: Would I benefit changing from PHP to Node.js (in context)

text: The situation: We are about to roll out what is essentially a logging service. As we are rather PHP heavy, the current implementation use it. We will have about 200 computers (most on the same network) that will each send, via HTTP POST, around 5000 requests/day. With each request containing about 300 bytes of data. The receiving end is hosted at Amazon and is a very simple PHP form with some simple validation that puts everything in a database. Now, I've recently been introduced to Node.js and I'm curious as to if it would be a good fit for the backend here. Granted I could easily build something to test this. But since I haven't fully grasped the async-methology I would really like someone with experience to explain it to me.


title: Programmer-to-Programmer, what would you ask?

text: I can't discuss specifics but let me begin by inserting you into a fictitious scenario that closely mimics the one I'm in. You have just been brought in as a engineering consultant to help finish an application fairly large in scope and addressing a problem domain you are unfamiliar with. For fun, lets just say its a flight control system for an alien spacecraft that crash landed on earth a few years ago. The current developer and his team have been working on this alien FCS for some time now, but have not meet the contractual obligations, or the timelines set forth, and the company that has brought you on has decided to not renew the contract with the current developer. You have only a few days (maybe one or two phone calls worth of time actually) to pick his (the developer) brain on everything and anything he and his team has done up to this point on the project before the contract expires. The problem is you don't know enough about implementing flight control systems in alien spacecraft to really know what to ask. You know the following things about the project and the developer:   * It is fairly well documented, both in code and wiki-documentation, eliminating the need for many technical questions   * The developer isn't always truthful and/or goes on tangents about unrelated things when asked simple questions SO - what kinds of questions do you spend the precious little time you have on to get the most out of this developer when you don't really understand all the ins and outs of the system you have been hired to assist with? Seriously, any feedback would be great on this. **EDIT:** I really appreciate the feedback so far, some good suggestions have been made and I have already begun the process of formulating some good questions based on the advice given. One thing I forgot to mention is that there are team members from both sides on any given phone call so it's not really possible to ask questions where fingers would get pointed. Unfortunately, this implied requirement of delicacy will surely cause some issues to remain hidden.


title: Is it ethical to teach teens about software viruses?

text: I volunteered to instruct an after school computer club at my son's middle school. There has been a lot of interest in computer viruses. I was thinking about showing them how to create a simple batch file virus that will infect other batch files in the same directory. Also show how creating a batch file with the same name, but that is closer in the path, can replace another program. It could also allow for discussion of anti-virus techniques - recognizing viruses and virus like behavior. I mentioned the idea to my wife and she thought it was a terrible idea. Compared it to giving them loaded weapons. I don't see it as dangerous since this technique wouldn't be immediately applicable for any real mischief on any modern operating systems. Am I being too cavalier or is she being too concerned? This isn't a settle this argument for me question, I am just trying to get another opinion. **Update** : I don't plan to cover moving between systems (or even directories) or any malicious behavior. And lest anyone think I am revealing any deep dark secrets, here is a book from 1996 I found at the library that goes into a lot more detail than I planned to cover. If some is motivated to be malicious they will find a way.


title: Good game that has scripting support

text: I've volunteered to lead a programming club at my son's middle-school. We've covered a lot of fun topics, including showing them how to use a game engine to build 3D interactive environments. One thing they said they would like to see is how to use scripting languages to enhance and extend games. I know I have heard that a lot of games use Lua as an embedded scripting language, and we have talked about Lua previously. I've found that the kids like to see something fun and flashy and are less interested in practical things. Of course I try to sneak in some learning too. What game can be recommended that would be fun to extend via scripting? It doesn't have to be Lua scriptable, but that would be nice. Bonus points if the game is free or open source so the kids can download it at home. I prefer Windows, but Mac is fine too. Game needs to be teen friendly.


title: How do I make code bound to an ORM testable?

text: In Test Driven Development, how do I make code bound to an ORM testable? I am using a Micro-ORM (PetaPoco) and I have several methods that interact with the database like: AddCustomer UpdateRecord etc. I want to know how to write a test for these methods. I searched YouTube for videos on writing a test for DAL, but I didn't find any. I want to know which method or class is testable and how to write a test before writing the code itself.


title: Maximize the visibility of an ad to a maximum of people in an automatic advertising system

text: I have N different ads that I want to display at the same time to M people in an automatic advertising system. Some people will never see some ads because they only check some specific criteria on the GUI, which are used like filters. Some ads will never be displayed at all, if nobody looks for them. The goal is to maximize the visibility of an ad to a maximum of people looking for specific criteria (filters) at the same time. The system refresh the ad every minute. Once the system choose the moment and the users who will see the ad, he stores the values in a queue (a database). I am looking for a solution to avoid starvation and deadlock. I mean, all ads corresponding to the criterias must be displayed, even if the waiting time is long. It can also be a typical scheduling algorithm corresponding to my problem.


title: How do I test this?

text: I've attempted test first in Ruby on Rails using Test Unit and RSpec. I'm wondering how to do test first in situations that are more closely tied to the OS/filesystem. **Problem:** Building a USB stick of MP4 files. **Inputs:**   1. List of mp4 file name, destination directory pairs.   2. List of source directories   3. List of destination directories **Output:**   1. USB stick with a directory structure of mp4 files. Here is some code that does what I want. Written using puts debugging:               #!/bin/env ruby     # encoding: utf-8          require 'fileutils'          files = [         [ 'Keynote_ Architecture the Lost Years by Robert Martin.mp4', 'dev' ],         [ 'The Oak Beams of New College, Oxford.mp4', 'arch' ],         [ '1. How Buildings Learn - Stewart Brand - 1 of 6 - “Flow”.mp4', 'arch/how_buildings_learn' ],         [ 'Hexagonal Rails by Matt Wynne.mp4', 'dev' ]     ]          dirs = [         'arch',         'arch/how_buildings_learn',         'dev'     ]          sources = [         '/home/gnoll110/dwhelper',         '/home/gnoll110/Downloads',         '/home/gnoll110/GNUstep/Downloads',         '/home/gnoll110'     ]          dest = '/media/Lexar'          dirs.each do | dir |         if !File.exist?( dest+'/'+dir )             system( 'mkdir '+dest+'/'+dir )         end     end          files.each do | file |         actual_source = false         sources.each do | source |             res = File.exist? source+'/'+file[0]             actual_source = source if res         end              if actual_source             FileUtils.cp(actual_source+'/'+file[0], dest+'/'+file[1] )         end     end.      What the best approach?   * Junk the existing code. After all, I'm trying to do test first.   * Write a test(s) that invokes a Command Pattern object. Dependence inject the data arrays in the constructor.   * Then inject the 'file exist' and 'fileutils copy' as stub/mocks, to get separation from the OS/filesystem.   * Build, assert and refactor the run method within an inch of its life. All suggestions and ideas welcome.


title: What are some good practices when trying to teach declarative programming to imperative programmers?

text: I offered to do a little bit training in F# at my company and they seemed to show some interest. They are generally VB6 and C# programmers who don't follow programming with too much passion. That being said I feel like it is easier to write correct code when you think in a functional matter so they should definitely get some benefit out of it. Can anyone offer up some advice on how I should approach this? **Ideas**   * Don't focus on the syntax, instead focus on how this language and the idioms it promotes can be used.   * Try and think of examples that are a pain to write in an imperative fashion but translates to elegant code when written in a declarative fashion.


title: Am I covered with GPL If I want to share open source code of project developed in my company?

text: I'm working in a company and in my job contract there are confidential clauses concerning code, documents, etc... In the company we are working on an open source project (GPL V3). The project is not shared yet to the public. Do I have the right to share the code of the project with people (out from the company)?


title: Can fixed scope + fixed deadline + fixed price contract ever be made to work with "agile"?

text: Some projects we run internally using scrum, whilst still being "fixed everything" to the customer. Mixed success on our part (the customer likes the visibility of the burndown chart). Any experiences on doing fixed price with agile?


title: How to deal with frequent requirements changes?

text: I'm dealing with pretty stressful (in my opinion) situation in my current work place. We've started developing new project, get some requirements, implemented it and then show to someone you can call a 'business advisor' (person who knows business requirements but will not use the program). That person is supposed to evaluate application from customers point of view, test it etc. Here how the 'process' looks:   1. business advisor talks in the evening with my boss for hour or two on windows messenger   2. the next day I receive email with copy of that conversation. I am supposed to choose tasks from that, check reported bugs (which often aren't bugs, just poor testing and forgetting about past establishments)   3. I implement changes, implementation gets accepted and then in a week or two it turns out that isn't want they want (they talked with some potential client that have seen software for 5 minutes and he suggested changes) - I have to do new changes Don't get me wrong, I understand that sometimes requirements change. What upsets me is how often the change occur in my workplace and how easy for 'management' is two give new requirements or sometimes fundamental changes to existing features. At the same we working on tight deadlines and I have impression that instead of going forward with our software we're running circles. I seek advise from you how to deal with this situation? Is this normal situation and I'm just hypersensitive about it?


title: Why is the Flyweight Pattern practical?

text: I was reading up on design patterns, to better my understandings of ones I know and reveal ones I didn't. One of the last ones I looks at was the Flyweight Pattern. It preaches about shared common function, and I understand this. Keeping with the game example (in the link), sharing functions for units in an RTS I'm sure would save on memory. But would this not sacrifice a great deal of [speed] performance? Keeping with the RTS theme, suppose you have 300 units on the field, all sharing the same run function, would this not be an asynchronous nightmare? And if one was do perform this in-line (via maybe a step/render style engine), would this not bog the the CPU?


title: Is a book that teaches how to build compilers good for learning to implement interpreters?

text: I'm looking for a book to learn how to implement interpreters for programming languages. Thing is there are much more 'compiler books' than 'interpreter books'. So my question is: can I read a book that teaches how to build compilers, to learn how to build interpreters (at a very beginner level)? Is this a good idea? If so, what do I need to keep in mind while reading?


title: ROA on top of SOA

text: I already have a stable Service Oriented Architecture for my application which exposes services as API calls. (the verbs) Now, I need to build a Resource Oriented Architecture to expose a RESTful API to interact with the application objects. (the nouns) What are the best practices to reuse the existing services:   \- without any persistence inside my new code.   \- without putting unnecessary logic into the REST layer i.e. it should ideally just leverage the services provided by SOA API. I want this layer to be as thin as possible.   \- without modifying the existing SOA API   \- allow easy extension of the REST API i.e. it should be easy to add more resources without changing the (yet to be written) core code. (I want to make resource names and their associated actions configurable so more contributors can easily add resources without a need to understand my module) Any advices/suggestions how to achieve this? **Edit: Adding more info**   **My Stack:**   * My existing stacks is in Java. But since I plan to just use the services, I don't think that should affect the design of new REST code.    * I am planning to implement the new REST code in PHP.  **How well the services map to resources?**   Some services are mapped well i.e. there are services for creating, updating application objects.   But for other application objects, there are no direct services available. _More importantly_ , there are actions beyond just create, update etc. that apply to application objects. And I would like to provide some way for these actions to be exposed through REST. Since these are verbs, how do I deal with them? **Where exactly I need help?**   I would appreciate any help towards high level design to accomplish the task along-with making the framework extendible. For instance, tomorrow there are some new services added to my SOA layer, I want to make sure it is easy for a fresh developer to write a REST call by simply registering a new resource (in a config file/db) and write code for connecting it with SOA calls. Just like plugin.


title: Configuring DI in a decoupled app

text: I'm reading through Mark Seeman's _Dependency Injection in .NET_ (excellent read so far) and something is escaping me. If the application's architecture is like `[DAL] => [BLL] <= [UI]`, with the Business Logic Layer free of dependencies upon Data Access and UI layers (and both dependent upon the BLL), and if the _composition root_ is located in the UI layer, then how on Earth are we supposed to be able to bind the interface of a type in the BLL with an implementation that's in the DAL? Mark Seeman gives a nice, typical example: abstract class `ProductRepository` lives in the BLL and class `SqlProductRepository` in the DAL. This may sound like a silly question but how is the UI layer supposed to be able to bind `ProductRepository` to `SqlProductRepository` without a reference to the DAL? > I move all the Controllers and ViewModels from the User Interface Layer to > the Presentation Model layer, leaving only the Views (the .aspx and .ascx > files) and the COMPOSITION ROOT in the User Interface layer. Thing is, I'm pretty sure this guy knows what he's talking about, so what part have I missed? Also where would I have to put the composition root in the case of a class library project? At first I thought the BLL would be perfect (given `[DAL] <= [BLL] => [UI]`), but now that I've refactored my project to literally reverse the dependencies, I don't know anymore - I used to have a BLL that knew about both the DAL and the UI layer so binding the types of these layers was easy, now nobody knows about everyone anymore, it's like I don't have anywhere I could possibly put a composition root. Help me out here, I feel like I'm missing a fundamental cornerstone...


title: How should I compress a file with multiple bytes that are the same with Huffman coding?

text: On my great quest for compressing/decompressing files with a Java implementation of Huffman coding (http://en.wikipedia.org/wiki/Huffman_coding) for a school assignment, I am now at the point of building a list of **prefix codes**. Such codes are used when decompressing a file. Basically, the code is made of zeroes and ones, that are used to follow a path in a Huffman tree (left or right) for, ultimately, finding a byte. In this Wikipedia image, to reach the character `m` the prefix code would be `0111` ![enter image description here](http://i.stack.imgur.com/ah9kI.png) The idea is that when you compress the file, you will basically convert all the bytes of the file into prefix codes instead (they tend to be smaller than 8 bits, so there's some gain). So every time the character `m` appears in a file (which in binary is actually `1101101`), it will be replaced by `0111` (if we used the tree above). Therefore, `1101101110110111011011101101` becomes `0111011101110111` in the compressed file. I'm okay with that. But what if the following happens:   * In the file to be compressed there exists only one unique byte, say `1101101`.   * There are 1000 of such byte. Technically, the prefix code of such byte would be... **none** , because there is no path to follow, right? I mean, there is only one **_unique_** byte anyway, so the tree has just one node. Therefore, if the prefix code is **none** , I would not be able to write the prefix code in the compressed file, because, well, there is nothing to write. Which brings this problem: **how would I compress/decompress such file if it is impossible to write a prefix code when compressing?** (using Huffman coding, due to the school assignment's rules) This tutorial seems to explain a bit better about prefix codes: http://www.cprogramming.com/tutorial/computersciencetheory/huffman.html but doesn't seem to address this issue either.


I am working on something that should be fairly simple. I have 95% of my program working, but one piece is still not fulfilling the requirement. (FYI, this is for a homework assignment, but I will prove that I have put good effort into it before coming here.) The piece of the assignment: * The ProductionWorker class should throw an exception named InvalidPayRate when it receives a negative number for the hourly pay rate or if the data entered is not numeric. I have my InvalidPayRate logic for catching negative numbers, but I am not too sure how to ensure that the input is numeric. Here is the relevant code: InvalidPayRate.java               public class InvalidPayRate extends Exception {         public InvalidPayRate(){             super("Error: Invalid Pay Rate.");         }     }      ProductionWorker.java               void setHourlyPayRate(double rate) throws InvalidPayRate         {             if (rate < 0.0){                 throw new InvalidPayRate();             }                  this.hourlyPayRate = rate;         }      test.java (this is within a main function)               //Set Rate details     try{         worker.setHourlyPayRate(-15.00);         System.out.println(worker.getHourlyPayRate() + ": Valid HourlyRate");       } catch (InvalidPayRate e) {         System.out.println(e.getMessage());     }          try{         worker.setHourlyPayRate(20.00);         System.out.println(worker.getHourlyPayRate() + ": Valid HourlyRate");       } catch (InvalidPayRate e) {         System.out.println(e.getMessage());     }          String testRate = "1v2.65";     try{         double rate = Double.parseDouble(testRate);         worker.setHourlyPayRate(rate);         System.out.println(worker.getHourlyPayRate() + ": Valid HourlyRate");       } catch (InvalidPayRate e) {         System.out.println(e.getMessage());     }      Right now, 2 of the 3 tests are working... the Valid entry, the negative number entry (returns my custom error) but my non-numeric entry is not working... it gives the standard NumberFormatException error. How can I perform a logical test to ensure that MY CUSTOM ERROR gets thrown instead of the NumberFormatException?


title: Is there any software development methodologies for small teams?

text: I'm working in a big software company and I'm developing a big enterprise- level web-solution with a team of about 25 people (2 architects, ~15 developers, 5 QA engineers, couple BAs, project manager). We are following agile methodology and scrum and it seems to be pretty convenient for such big team in circumstances of frequent requirement changes. I also have one pet project - I have basic idea and I've started development. Currently I'm working alone, but I plan to propose to couple of my friends participate in my project. Some time ago I've faced with a problem of proper task-tracking and formalizing requirements. My first thought was to use agile methodology as we used it with my team at work. While it is very convenient for my job, I have found it too much time-consuming for team with 1-3 people. Is there any software development methodologies for really small teams? Or I should overcome myself and formalize all my thoughts into user stories and tasks and use iterations? I don't want my project become just another folder on my disk, but I'm also don't want to waste time on unnecessary formalizations.


title: Track performance numbers

text: I have a (large) software project in a git repository. There is a benchmark suite that spits out lots of numbers (time per benchmark, allocations done per benchmark) I’d like to track. What is the best way to get a grip on intended and unintended performance changes in such a setup? (Ideally, I think, there is a piece of free software that takes a git repository, a script to obtain the numbers, schedules jobs for new commit, also checks old commits when idle and presents a slick web interface with lots of graphs and analysis tools.)


title: Is doing Parent.call from the child object a right way to implement Inheritance in JavaScript?

text: I came across this piece of code it didnt look that right to me. Is it the right way to implement SUPER in javascript. if not what is the right way?               function Person(name){      this.name = name;       }          function Student(name){     Person.call(this, name);     }          Student.prototype = new Person();      var a = new Student('test');     var b = new Student('test2');


title: Is using Git Stash as a workflow an antipattern?

text: I've recently been looking at how me and my team uses Git and how our workflows work. We currently use a feature-branch workflow which seems to work well. I've also seen some individuals on our team use workflow based on git stash. The workflow goes something like this:   * Work on a main branch (like `master`)   * Make commits as you go   * If you need to get changes or switch branches, push your uncommitted changes onto the stash   * Once your updating is done, pop the changes off the stash. I should mention that this workflow is used _instead of_ a feature branch workflow. Instead of taking a branch and working on it, developers here only ever work on a single branch and push/pop off the stack as they see fit. I actually don't think this is a great workflow, and branching would be more appropriate than using git stash in this way. I can see the value of git stash as an emergency operation, but not for using it in a daily, regular workflow. Would using git stash regularly be considered an anti-pattern? If so, what are some specific problems that could arise? If not, what are the benefits?


title: Should putting html tags into localization files be avoided?

text:
We are localizing all parts of our website to many languages. We use XML localization files. I think this scenario is so common, and even there should be a standard solution to this, but still I couldn't find any good advice, and every developer here has different opinion about it, so I'm asking you. **Suggest the following example:** _If you have question, please ask our`<a href="blabla" target="_blank" title="Our nice Customer Support + boilerplate SEO bullshit">`Customer support`</a>` or write an email to `<a href="mailto:XXX">`Jane Doe `</a>` our specialist._ **Or a long, formatted text:**
A very long, marketing blah-blah. A very long, marketing blah-blah. A very long, marketing blah-blah concluding in a list:

1

2

3

      **1) Would you put html tags into the localization XML file?** My concern is the View is **separated into 2 files** : your page and your localization file. People will forget to check the localization file. Also, **there's logic and style embedded in html** as well (see `target="_blank"`, or the fact that the above mentioned list is unordered...) **2) Or splitting it to smaller parts?** `<msg id="IfYouHaveQuestion">`If you have question, please ask our`</msg>` `<msg id="CustomerSupport">`Customer support`</msg>` `<msg id="OrWrite">`or write an email to`</msg>` ... Now, View can contain all the markup and style. It's easy to change it, flexible. But. There's absolutely **no guarantee** that the **word order will be the same** in all languages. Also, this would make the **translator's work a nightmare** , making it a puzzle. **3) Or introduce BB-style markdown?** `<msg id="HaveQuestion">`If you have question, please ask our `[link url="{customersupportlink}" title="{{CustomerSupportTitle}}">`Customer support`[/link]` or write an email ...`</msg>` But probably this is over-complicating the issue, and also we have to write our own parser for this (though, I think it wouldn't be so hard). And probably does not solve the long, formatted text problem. **4) ??? (Your golden solution here) :)**


title: In MVC design, do I use a base class over an interface?

text: In _web_ MVC most designs I've seen, (just choosing model layer as an example) the domain problem class, say students, always inherits the superclass "Model." The name is irrelevant, but why do they always inherit classes instead of interfaces? I've seen others that have interface -> abstract class -> concrete class. But, I don't know why I'd choose a class over an inteface.   * Will I need to execute something in the constructor of the superclass in MVC? Some other method?    * I know of no mutual functionality that needs an implementation beforehand, but that is probably inexperience? I don't now.    * Why not just an interface to enforce my API? I have seen other answers. I have not seen it in the _specific context of MVC **design_** , however. Using PHP if it matters.


title: In Node.js, are non-blocking constructs usually preferable to blocking ones?

text: Is the following a statement of best practices in Node.js with regard to web applications? If not, how could it be improved? **The statement** The lifecycle of any web app has at least two phases: a setup phase, and a ready phase (when the application is ready to respond to requests.) In the ready phase,   1. IO operations (disk access, database calls, etc.) should always be asynchronous/non-blocking.   2. Even operations that occur purely in memory should be asynchronous, when possible. This is especially true when the operations involve iteration, and especially^2 true when the upper limit on the number of iterations is unknown.   3. Synchronous/blocking operations should never be performed in response to a request. In my opinion, the question of whether or not something is part of the best practices for developing in a certain programming language can be answered decisively based on experience and objective criteria.


title: Essential Technologies for Senior (.NET) Developer

text: I was recently laid off, and now I'm looking to take this opportunity to add new technologies to my resume. I don't mean just padding with keywords; I mean developing _real_ (albeit possibly small), _useful_ applications that require me to, in the process, learn a new technology. My choice of platform is a little confused, because I have about 1-2 years of experience with 10 or so languages/platforms (C++, Ruby, C#, Java, JEE, ASP.NET, Ruby, Rails, PHP, ...). I'm hoping this question will be generic to at least C#/Java, or maybe wider. **What are some absolutely essential technologies I should learn about, for Java and for .NET?** As an example, I would say based on my experience, a JEE example would be: Hibernate, Spring, Struts, EMMA, Ant, BEA WebLogic, and Hudson. (Note that they span the entire gamut from writing and compiling code to building and deploying applications.) **Edit:** I will probably end up in a .NET web development job (ASP.NET, MVC2 if I'm lucky). That's what I'm looking for.


title: In C++, were SFINAE and metaprogramming intentional or just a byproduct of templates?

text: SFINAE and `template` metaprogramming can do wonderful things and many libraries also use them considerably. Historically both of these "magic concepts" were intentionally introduced/supported in C++ ? Or they were just later discovered as useful byproducts (side products) of original `template` programming ?


title: Workflow of sharing code for small teams

text: Problem is, we have developed a small CMS, that is different per implementation (currently). Of course development of this is never complete. Sometimes, we are working on more than one project that implements it (by copying-pasting the code files of the CMS to each project), and we add a new feature that we want to share on other projects as well (these can be small ones too, ie a custom ajax JSON controller - we use MVC) What we want to do is quickly and uniformly share the code with all other projects, via a version control system (or something similar), and generally organize the workflow as we know this isn't a very good workflow that we have. What would you suggest? Also, at the momment, the software we use is Visual Studio 2010, so we are strongly considering TFS, but even if we get it we still don't know the ideal workflow, or even if TFS supports what we want to do. **Edit:** Also note, we have specific implementations that have modifications over the CMS base that we want to KEEP only in the project area. (ie: a specific feature that we DONT want to share with the base CMS code)


title: Can I use metro style interface in my own web application?

text: I am wondering if I would need to license the Metro style or if I can just freely use it in my own applications. I mean, is it patented or protected in any way that would prevent me from building my own implementation? I effectively would like to copy the visible part of it. I like to idea of being able to:   * Provide an interface which is used somewhere else (as in 1 less to learn)   * Use the interface that has been tested for usability (I personally like it)   * Have the possibility of getting free publicity because of implementing full Metro style web application while not associated with Microsoft, etc.


title: How to setup TDD environment

text: In TDD, is it good practice to keep the tests in the same directory as the code its testing or is it better separate the tests in either a different directory or a separate project. Would it be the same for a web site where you have the aspx/c# pages in one directory?


title: Programming language for simple program?

text: I am wondering about which programming languages people see fit to create a program idea that I had. I am looking to create a fairly simple program whose main functions are adding to, managing, and searching through a database of people, all through a polished GUI. It will be for use in the business world, so I think Windows would be the priority, but Mac and Linux support wouldn't be bad. Also, eventually I would like to add the ability for an instance of one program on a computer to interact with other instances on the same network, mainly through the sharing of a database. Most of my experience is in Java, but I don't particularly like the appearance of Java GUIs, so I'm looking for an alternative. I noticed that a lot of people have suggested C++ or C# in similar posts, so what are some of the advantages/disadvantages of one or both if that is your suggestion. Thanks for any help in advance.


title: Declaring interface in the same file as the base class, is it a good practice?

text: To be interchangable and testable, normally services with logic needs to have interface, e.g.               public class FooService: IFooService      { ... }      Design-wise, I agree with this, but one of the things that bothers me with this approach is that for one service you will need to declare two things (the class and the interface), and in our team, normally two files (one for the class and one for the interface). Another discomfort is the difficulty in navigation because using "Go to definition" in IDE (VS2010) will point to the interface (since other classes refer to the interface), not the actual class. I was thinking that writing IFooService in the same file as FooService will reduce the above weirdness. After all, IFooService and FooService are very related. Is this a good practice? Is there a good reason that IFooService must be located in its own file?


title: Is security a real argument for centralized version control?

text: I'm trying to understand if security is a real concern, or if distribution actually does a better job with security. See, the access to the main source repository could be layered and inherently managed by a network of trust, and could still have centralized user management integrating users from an LDAP/Active Directory, while the centralized version control system just relies on the later. With distribution, access could even be given to less users per repository in different countries and maintained easier. I can see why it is easy to think that having tight & centralized access management to a code repository translates to security, however, that doesn't mean that code cannot be accessed or redistributed other ways. But, is there a real argument/use case/scenario for security where the centralized model is just better than the distributed one?. **Some context** : I'm trying to make the case (with a whitepaper) to my company to switch to a DVCS (I already have other problems identified that are successfully addressed by most DVCSs) and security is one of the arguments I'm expecting to have to justify. My company is open minded though; they currently use perforce and are distributed geographically.