web Service - what happens when client doesn't get the response?

We have developed a WCF service which acts as an API to our system. some of the methods expose functionality which eventually writes and updates data to DB. Lets say that the client sent one of those requests, the service performed the needed operations while the client disconnects for some reason and did not get the response. the response holds information about success/failure of all sub-operations An example of "problematic" data being updated - "Add X amount to Balance of Member M". So if the client did not get the response - the client doesn't know that the data was updated. **How should we deal with this scenario while keeping the client side implementation as clean as possible?**


How do your busiest people transfer their knowledge?

We have recently polled our company wide wiki users and found out that there are two large groups of users:   * people with **lots of knowledge** but (who claim they have) no time to document   * people with **time** but (who claim they have) not enough knowledge worth documenting Each group covered almost 50% of the users! How do your companies handle this? That is, **how do you encourage your busiest / most knowledgeable people to share their knowledge?**


When should a class or module be in a separate Assembly/DLL?

Are there any guidelines for deciding when a class should be in its own assembly/DLL? I often see two schools of thought: 1) Every "grouping" of classes belongs in its own DLL e.g. Repositories, Services, DTOs, Infrastructure, etc. 2) Everything should be in a single DLL but separated out via namespaces/folders e.g. have a "Core" DLL with additional namespaces e.g. Core.Repositories, Core.Services, Core.DTO, etc. At work we just lump everything in a single Assembly called "Business". There are some folders but there's no real separation - business objects (with logic, some of which shouldn't even be classes) are lumped in a "BusinessObjects" folder without care. Things used in more than one class are in a "Core" folder. Utilities are in a "Utilities" folder, the data access infrastructure is a "Data" folder - you get the idea. For a new module I'm working on I want/need to have a separate data access layer (think a rudimentary Repository implementation) but I don't want to just throw it under the "BusinessObjects" folder with the other 160 (!) classes there. At the same time I'm concerned about creating a new Class Library since everyone is used to stuffing a class in the single Library; a folder/namespace could work however.


How to handle management pushing legacy systems?

I am currently on a paid internship, and have been tasked with maintaining an obsolete system that has been developed by multiple developers (at different times) over the course of the past 5 years. Management agrees the "system is on life support", and I receive a fairly regular supply of bug reports from end users currently using the system. Management now wants to extend the project for another year, and in the process nearly triple the user base. As an intern (or any entry level position) how do I "push back"? I've already written a report stating my concerns, albeit in an open-ended document. Is there protocol or document type for suggesting changes? Am I in a position to make suggestions, or should I simply continue to support the old system?   * To clarify, software development is not my company's primary business. As such no internal protocols exist. Additionally, the project has no formal documentation at all, and no requirements documents either. The development is very ad hoc.


Making money from a custom built interpreter?

I have been making considerable progress lately on building an interpreter. I am building it from NASM assembly code (for the core engine) and C (cl.exe the Microsoft compiler for the parser). I really don't have a lot of time but I have a lot of good ideas on how to build this so it appeals to a certain niche market. I'd love to finish this but I need to face reality here ... unless I can make some good monetary return on my investment, there is not a lot of time for me to invest. So I ask the following questions to anyone out there, especially those who have experience in monetizing their programs: 1) How easy is it for a programmer to make good money from one design? (I know this is vague but it will be interesting to hear from those who have experience or know of others' experiences). 2) What are the biggest obstacles to making money from a programming design? 3) For the parser, I am using the Microsoft compiler (no IDE) I got from visual express, so will this be an issue? Will I have to pay royalties or a license fee? 4) As far as I know NASM is a 2-clause BSD licensed application. So this should allow me to use NASM for commericial development unless I am missing something? It's good to know these things before launching into the meat and potatoes of the project.


How do you format arrays within parameters?

I'm talking about something like this:               echo $form->input('general_addresss', array(                 'label' => 'Where will you go today?'                 'format' => array('before', 'input', 'after', 'label', 'after', 'error')                 ));      Do you start with one array parameter, then break a line? If it can't fit on a line, do you immediately break a line? After of which, do you do a set number of tabs over? What happens if an array within an array has lots of properties? Is there any particular guide you follow?


Limiting certain functionality to development environment only

I intuitively think that an application should be exactly the same in DEV, QA, and PROD environments. However, I have been asked to add a feature to an application that will only be available in DEV environment. The tool modifies DEV database values and produces an output script that will be tested in QA and afterwards will be used to modify production data. The authentication that allows access to the feature will not be available in QA and PROD environments. I understand that this will work, but is this correct for Java EE standards? **Additional details:** -I removed "best practice" because of the comments below.  -I have a development server and development database, a testing server and testing database, and a production server and production database. I want to know if there would be any possible issues that could arise (and "best practice" for avoiding them) from having a feature of a large application only available on development server. The feature would modify values in the development database then export a SQL script that has the current state of the development database. The SQL script would then be run on testing database and if every function worked properly afterwards it would also be run on production database. The code that would modify the testing and production databases is not available in either of those environments. I apologize, I know that says basically the same thing as above. If it is still unclear, I will remove the question. Thanks.


Multiple inheritance use cases

Java omits multiple inheritance on the grounds that it obviates the design goal of keeping the language simple. I wonder if Java (with its eco-system) is really "simple". Python is not complex and has multiple inheritance. So without being too subjective, my question is... **_What are the typical problem patterns that benefit from a code designed to make heavy use of multiple inheritance_**


Subset counting algorithm

I have a following problem i want to solve efficiently : Input: Set s of {Pass,Fail}^k vectors, m - minimum percent of vectors Output : Set of Sets of indexes: Where each set Contains indexes of Pass word in given vectors, and number of vectors that contains Pass in those indexes is over m percent from total vectors. Example: {(Pass,Fail,Pass,Fail),(Pass,Fail,Pass,Pass)} where k is 4 and number of set elements is 2 and m 60% , output will be {{0,2},{0},{2}} The output is group of sets where every set contains vector indexes that for at least 60% of vectors value was Pass


What are the trademark guidelines for Java technologies?

The former page "Trademark and Logo Usage Requirements" at http://www.sun.com/policies/trademarks/ is no longer available, is there a new version which helps with the proper naming of products (beans, libraries) for Java? I have found Third Party Usage Guidelines for Oracle Trademarks at http://www.oracle.com/us/legal/third-party-trademarks/index.html however there is no occurence of "Java" related product names. Former guidelines said that "(productname...) for the Java platform" was a correct name, and now it seems to me that it must be renamed to " **(productname...) for Oracle Java** " to comply with the Third Party Usage Guidelines for Oracle Trademarks


Should more than one function be used when they do similar, but not identical things?

For example, if I wanted to generate some HTML based on some input. Which is the preferred way out of:               <?php          function generate_html($type, $input){         switch($type){             case 'paragraph':                 //Generate and return the HTML code for a paragraph                 break;             case 'ul':                 //Generate and return the HTML code for an unordered list                 break;             default:                 error('Invalid type specified');                 break;         }     }          generate_html('paragraph', 'This is a paragraph');     generate_html('ul', [         'This is the first item in a list',         'This is the second item in a list'     ]);      or:               <?php          function generate_paragraph($input){         //Generate and return HTML for a paragraph     }          function generate_ul($input){         //Generate and return HTML for a list     }          generate_paragraph('This is a paragraph');     generate_ul([         'This is the first item in a list',         'This is the second item in a list'     ]);      I know about the idea of a function doing only one "thing", but I'm not sure how specific that "thing" should be. The first type could only be doing one thing (generating HTML), or it could be doing two things (generating lists, paragraphs). It depends how you look at it. What would be the preferred way of doing something like this?


Are there any concerns with using a static read-only unit of work so that it behaves like a cache?

Related question: How do I cache data that rarely changes? I'm making an ASP.NET MVC4 application. On every request the security details about the user will need to be checked with the area/controller/action that they are accessing to see if they are allowed to view it. The security information is stored in the database. For example:               User     Permission     UserPermission     Action     ActionPermission      A "Permission" is a token that is applied to an MVC action to indicate that the token is required in order to access the action. Once a user is given the permission (via the UserPermission table) then they have the token and can therefore access the action. I've been looking in to how to cache this data (since it rarely changes) so that I'm only querying in-memory data and not hitting a database (which is a considerable performance hit at the moment). I've tried storing things in lists, using a caching provider but I either run in to problems or performance doesn't improve. One problem that I constantly run in to is that I'm using lazy loading and dynamic proxies with EntityFramework. This means that even if I `ToList()` everything and store them somewhere static, the relationships are never populated. For example, `User.Permissions` is an ICollection but it's always null. I don't want to `Include()` everything because I'm trying to keep things simple and generic (and easy to modify). One thing I know is that an EntityFramework DbContext is a unit of work that acts with 1st-level caching. That is, for the duration of the unit of work, everything that is accessed is cached in memory. I want to create a read-only DbContext that will exist indefinitely and will only be used to read about permission data. Upon testing this it worked perfectly; my page load times went from 200ms+ to 20ms. I can easily force the data to refresh at certain intervals or simply leave it to refresh when the application pool is recycled. Basically it will behave like a cache. _Note that the rest of the application will interact with other contexts that exist per request as normal._ **Is there any disadvantage to this approach? Could I be doing something different?**


Overview of the agile process that I can apply to a startup

I need to provide a quote to an external client for some software. I'm looking to use agile just for initial requirements building (which I'm experienced in from a developer perspective) but I need to do everything this is just a one man job. The client are having a hard time working out what there requirements are and the value I can add will be to sit down with them and work out what they want using user stories etc, I basically need to be a BA for a little bit. I am looking for good overview of the procedures to go through in the agile process for building requirements, and the continuing process a bit for further down the line. For example the initial inception through to elaboration of epics and building user stories (or not) just need to read a bit about it before the meeting so I know the best way to proceed if I spend a day with them. Having additional resources to provide to the client so that we are all on the same page would be useful too.


Serializing an object in different ways

It is usual for me, when doing web development, to copy attributes from my model classes to the other class that will be sent to the client. Usually, with a class that accepts a model and extracts the necessary information this is sufficient (something like a adapter I suppose), but sometimes it is not that easy. In some systems, for different reasons I need to send a different sets of attributes, and this is where simplicity seems to disappears. With my usual approach I end up with lot's of classes very similar one from each other, just because one is for being used in one channel that requires some information and the others for channels that require very similar information. But cannot be the same sum of the two because performance or security. (When I say channels it is because it could be a serialized using json or xml, or used in other protocols, or just displayed as html by the server.) **The question is:** Is there a pattern that allows for different transformations of a object (that might aggregate others objects) depending the context being used? (without too much code duplication) **Case of study:** in a distributed cards game (like poker), I need to send to every user the score, the name of the players, the cards that were played, and the cards he has in his hand. But when the game ends I need to send the cards in the hands of the others players too. And in other view of the game I need to send only the score and the name of the players. Sorry about my English, it is not my first language (and the idea I am trying to communicate seems a little complex for me).


Handling leaves in tree-based menus

**Tl;Dr** Given a language with no polymorphism how to you elegantly modify the behavior of a leaf in a tree data structure. **Context** I'm programming an application in C for a microcontroller and I'm wondering what would be the best way to design flexible GUI-less menus. Basically inputs may come from 2 different sources: The built-in buttons on the board used by the user and a Uart port used by the production team to calibrate the device before shipping. I already have a mechanism using a thread to listen to inputs (from both the buttons and the serial port) who post them to a crude parser. The parser then takes action depending on the currently registered callback for the received input. It also knows if the menu must be printed on the LCD screen or through the serial port. I'm also using a k-ary tree to represent the hierarchy between sub-menus and different options. Since the menus are not defined yet it'll allow me to simply add / remove nodes when my supervisor makes his mind on the supported features. Now when the currently displayed menu is not a leaf, the behavior is quite simply. Left and Right moves between siblings, Back selects the parent and Enter selects the first child. If its a leaf, Enter activates / deactivates modifications, Left and Right increment / decrement the value and Back cancels the moficiation. **Other concerns**   * Am I over-engeenering stuff that could be done with a bunch of switch-cases?   * Are there ressources giving example of clean GUI-less menus when you don't know where the inputs come from, the actions you will have to take, the menus you must offer and where to display those menus?   * Since there is basically 2 options (leaf or not) should I just do everything with if/elses and move on?


Implementing IEnumerator without using 'yield return' in c#

I'm new to C# programming, I was experimenting with iterators concept in C#. Here, I'm trying to display all the terms in a list, for that I'm trying different ways to obtain the results. In the below code, I'm using two classes ListIterator and ImplementList. In the `ListIterator class` : I defined a `HashSet` and it uses `IEnumerator` to store the values. Here `GetEnumerator()` method returns the values in the list. GetEnumerator is implemented in the `ImplementList class` (other class). Finally, the list is displayed in the console.               public class ListIterator     {         public void DisplayList()        {         HashSet<int> myhashSet = new HashSet<int> { 30, 4, 27, 35, 96, 34};         IEnumerator<int> IE = myhashSet.GetEnumerator();         while (IE.MoveNext())           {             int x = IE.Current;             Console.Write("{0} ", x);           }           Console.WriteLine();         Console.ReadKey();        }     }      In the ImplementList class : `GetEnumerator()` is defined and it returns the list using `yield return x.`               public class ImplementList : IList<int>       {         private List<int> Mylist = new List<int>();         public ImplementList() { }              public void Add(int item)          {              Mylist.Add(item);          }              public IEnumerator<int> GetEnumerator()         {           foreach (int x in Mylist)             yield return x;         }       }      Now, I want to rewrite the `GetEnumerator()` without using `yield return`. And it should return all the values in a list. I tried using for loop as `for(int x=0; x<Mylist.Count; x++)`, but it doesn't return all the values in the list. Is it possible to get all the values in the list without using `yield return` in IEnumerator


Is the Observer pattern adequate for this kind of scenario?

I'm creating a simple game development framework with Ruby. There is a node system. A node is a game entity, and it has position. It can have children nodes (and one parent node). Children are always drawn relatively to their parent. Nodes have a `@position` field. Anyone can modify it. When such position is modified, the node must update its children accordingly to properly draw them relatively to it. `@position` contains a `Point` instance (a class with x and y properties, plus some other useful methods). I need to know when a node's `@position`'s state changes, so I can tell the node to update its children. This is easy if the programmer does something like this:               @node.position = Point.new(300,300)      Because it is equivalent to calling this:               # Code in the Node class     def position=(newValue)       @position = newValue       update_my_children    # <--- I know that the position changed     end      But, I'm lost when this happens:               @node.position.x = 300      The only one that _knows_ that the position changed is the `Point` instance stored in the `@position` property of the node. But I need the node to be notified! It was at this point that I considered the Observer pattern. Basically, `Point` is now observable. When a node's `position` property is given a new `Point` instance (through the assignment operator), it will stop observing the previous `Point` it had (if any), and start observing the new one. When a `Point` instance gets a state change, all observers (the node owning it) will be notified, so now my node can update its children when the position changes. A problem is when this happens:               @someNode.position = @anotherNode.position      This means that two nodes are observing the same point. If I change one of the node's position, the other would change as well. To fix this, when a position is assigned, I plan to create a new Point instance, copy the passed argument's `x` and `y`, and store my newly created point instead of storing the passed one. Another problem I fear is this:               somePoint = @node.position     somePoint.x = 500      This would, technically, modify `@node`'s position. I'm not sure if anyone would be expecting _that_ behavior. I'm under the impression that people see `Point` as some kind of primitive rather than an actual object. Is this approach even reasonable? Reasons I'm feeling skeptical:   * I've heard that the Observer pattern should be used with, well, _many_ observers. Technically, in this scenario there is only one observer at a time.   * When assigning a node's position as another's (`@someNode.position = @anotherNode.position`), where I create a whole new instance rather than storing the passed point, it feels hackish, or even inefficient.


What is the simplest human readable configuration file format?

Current configuration file is as follows:               mainwindow.title = 'test'     mainwindow.position.x = 100     mainwindow.position.y = 200          mainwindow.button.label = 'apply'     mainwindow.button.size.x = 100     mainwindow.button.size.y = 30          logger.datarate = 100     logger.enable = True     logger.filename = './test.log'      This is read with python to a nested dictionary:               {       'mainwindow':{         'button':{           'label': {'value':'apply'},            ...       },       'logger':{          datarate: {'value': 100},          enable: {'value': True},          filename: {'value': './test.log'}       },        ...         }      Is there a better way of doing this? The idea is to get XML type of behavior and avoid XML as long as possible. The end user is assumed almost totally computer illiterate and basically uses notepad and copy-paste. Thus the python standard "header + variables" type is considered too difficult. The dummy user edits the config file, able programmers handle the dictionaries. Nested dictionary is chosen for easy splitting (logger does not need or even cannot have/edit mainwindow parameters).


Should I still use a web application framework?

I'm about to make a simple web application with just image uploading and user management. I'm browsing through several web app frameworks I could use yet I'm still thinking if I should still make use of them or just make one from scratch for this specific application. Any suggestions from experienced web app developers? Thanks!


Non-Profit Technololgy for Non-Profits?

I've been looking around for a way to give back to the community, but I haven't found my right fit yet, so an idea came to mind: A non-profit technology "company" that targets non-profits. Do these exist? I've been doing some google searches and can only find software that is targeted for non-profits that is created by for-profit companies or that charges what I believe to be an outrages amount, conferences directed towards non-profits and technology they may use -- or articles complaining about the digital divide and how non-profits view technology as key but dont have the funds or the knowledge to employ it. **Pseudo "Business Model"** An open source 501(3)(c) organization that targets directly targets non- profits to fill the "digital divide." Most services would be free and consulting fees would be charged for customization. Donations would be accepted and government grants would be sought after. This would enable non- profits to keep pace with the for-profits in the technology sector, but at little to no cost. Perhaps the first "industry" to be targeted would be those that fill key social needs like unemployment, or food banks.


What are the consequences of still sticking with Windows XP despite there are Windows Vista, 7 and very soon 8?

From a .Net programmer perspective, what are the consequences of still sticking with Windows XP despite there are Windows Vista, 7 and very soon 8? How does having windows XP limit programmers development in .Net platform?


Publishing: Hows and Whos of Peer Reviews

So, I'm sitting here, chewing on a couple of novel data structures. I'm thinking of coding them up, but I'ven't got any professional use for them at the moment. Nonetheless, they solve interesting problems, and deserve reference implementations. So, I'd like to publish them, ideally in a peer- reviewed journal, so there's at least an off-chance someone will run into them and get some use out of it. But I can't for the life of me figure out how I'd even start to go about such a process, and none of my old professors seem to be in a position to help. Can I get a primer on how to go about getting something published in a moderately reputable journal?


Is there a term for reusing code by retyping it?

I built a prototype ("one to throw away") a while ago, and I'm rebuilding it now as an alpha. My goodness, it's been worth it. I reused some of the prototype code by copy-pasting then modifying it, but I've fallen into a pattern of looking at the prototype for guidance, but writing the new code from scratch. This doesn't take too long for me because I'm a pretty fast touch-typist. Right now I'm rebuilding a complex function, and I'm actually reading it line- by-line and typing equivalent code into my alpha version. I find it's better than copy-paste-refactor because I get reacquainted with the logic, and I don't miss parts of the code when I'm reading it. Is there a name for this kind of reuse? Any authoritative commentary on its benefits/drawbacks?


Why do people hesitate to use Python 3?

Python 3 was released in December 2008. A lot of time has passed since then but still today many developers hesitate to use Python 3. Even popular frameworks like Django are not compatible with Python 3 yet but still rely on Python 2. Sure, Python 3 has some incompatibilities with Python 2 and some people need to rely on backwards-compatibility. But hasn't Python 3 been around long enough now for most projects to switch or start with Python 3? Having two competing versions has so many drawbacks; two branches need to be maintained, confusion for learners and so on. So why is there so much hesitation throughout the Python community about switching to Python 3?


Are code reviews necessary for junior developers?

I've worked at two companies, who each had a different methodology when it came to code reviews: In the first company, a code review was conducted by the team leaders and was required after the completion of every module. However, in the second company, team leaders weren't required to conduct any code reviews, and just checked for functionality and design issues. So I am confused. Is the code review process really needed? If it is, why? And if it isn't, why not?


Apple subscription for customer

When developing an iOS application (freelance) for a customer, how do you handle the iOS Developer Subscription? On the one hand, I have no problem submitting the app using my own subscription.   On the other hand, the subscription is per year which means the customer would be dependent on me actually renewing my subscription every year.


What is the relationship between a framework like RoR and a database?

I'm a front end developer...I've never done ANY backend, although I did take a course in databases once. (I have a comp sci degree; I'm a competent programmer, I just haven't done any backend web stuff before.) So I'm trying to figure out how the framework relates to the database. Presumably they're set up separately, and the framework receives requests from the website and sends them to the database, then receives the response and handles it appropriately to deliver the content correctly? It's basically a complex intermediary for all the web-app logic? Am I far off? Need a good explanation of this.


Parsing Text Tokens in Script Files

My team is wanting to migrate away from compiled code to dynamic code. We have a wide variety of customers and each has different business rules. Instead of having a single compiled code base, we are considering having different templated script files for each customer. However we have a lot of compiled code, so for now we are wanting to keep most of our current code and shell the script files like `ruby my.rb` or `node my.js`. In addition, we need to get data into the scripts. So, we are thinking we will have variable declarations in the script, and those variables will be set to some character sequence that we will treat as a token. Then with another app, we'll process the document looking for the tokens replacing them with the actual data. I have some concerns and am not sure what to think of all this, but I'm wondering if someone with more experience can shed some light on the quality of this solution and what some other alternatives might be. EDIT: I hope this helps explain my scenario. Some of the motivation of this is our clients are not always accessible. In addition, we have services running on the client that would need to be stopped to install new versions of .dlls or .jars. Also, our clients get fragmented on versions of software despite attempts to keep them together. The thought is the script files will ship on demand with the other files and data to which that script is valid, and the compiled software will change less often.


What's the difference between using RDFS/OWL versus XML?

I was wondering what advantages the ontology languages of RDFS/OWL has over using a tagging/markup system (such as http://www.schema.org/) for managing and creating metadata?


WCF service - best way to accept requests from a client and do background work?

For a project at work, I was tasked to create a WCF service that will receive email messages from client and queue them on a database, while at the same time the service will check the DB every 30 minutes or so to check if there are any new email messages queued, and send them automatically with the appropriate credentials. To accomplish this, my boss told me to do it with threads: while the main thread is in charge of taking requests from clients, a background thread will be in charge of checking the DB for as long as the service is alive, and send the queued emails. After asking on StackOverflow, however, I was told that for this kind of scenario _two_ services is a better option, a WCF service that takes requests and a different Windows Service that does the background work. So my question is, what is the best option for implementing this kind of scenario? And is doing this with just threads possible, but ill-advised? I would like to hear more opinions before checking with my boss about the best way to accomplish this.


Auxiliary space complexity of map vs map!

I'm curious about the difference in space complexity between `map` and `map!` in ruby. If I have the methods:               def mult_by_two(arr)       arr.map {|i| i * 2 }     end          def mult_by_two!(arr)       arr.map! {|i| i * 2 }     end      While there's no explicit assignment in the first method, it's implicitly collecting the result of the `map` somewhere and is not operating in-place like the second method. Would it be correct to say that the first has O(n) auxiliary space complexity while the second is O(1)? How should I represent them when looking at the auxiliary space complexity of a method?


Do good code readers write bad code?

I've been observing programmers that are great at reading foreign, messy and undocumented code. At the same time they tend to also write messy code without documenting it. Is this common or just a coincidence? My theory is that since they can understand almost anything, they don't see the need for quality code. While I'm not that good at interpreting foreign code, when I write new I try to show the intent in the code and use plenty of comments, so that I myself could understand it later. Does this make sense?


How to describe the complexity of a project, without revealing information?

I will be looking for a job after a long break, so I need all the help I can get. Problem is, my best point in a portofolio is an unusual application, using quite unusual algorithms, that may seem simple at a glance for anyone who didn't have to design and implement them. The natural thing to do would be to describe the design and implementation details, so that any developer would be able to assess how much skill and determination it took to finish the project. But, I intent to polish the application some more and sell it. I don't want clones to appear anytime soon. The barrier to entry currently is high, but if I were to be giving hints about my implementation, then it's no longer the case. I don't believe in the honesty of recruiting developers. I have experience going to interviews and in some cases it seems like the main point of an interview was to gain information about our pipeline, used technologies and custom solutions, as opposed to hiring me :) EDIT: Not telling what the application does, or not providing a link to it won't even get me a call back for an interview. I won't be applying to companies which could be selling solution similar to mine. I'm rather worried about giving advice to individual developers on how to make a clone, without going through some dead corners and lengthy research.


MVP Implementation at the UserControl Level

I'm trying to figure out how MVP should be implemented at the `UserControl` level. I thought I had it, but I ended up reading a blog post that pretty much shut me down. Now I'm back at the start and with no idea how to proceed. Let's say my `UserControl` is something simple like two `TextBox`es and a `ComboBox`. This gets invoked from a main form (which has its own View and Presenter). Now, the way I understand MVP is that the Main Form Presenter is supposed to invoke a second presenter to handle all communication with the UserControl that gets dropped there. And this is where I get completely lost. My past implementations of `UserControl`s (before I learned MVP) always incorporated the logic behind the control (e.g. `ComboBox` selection will change text label related to `TextBox1`). As such, implementation of the `UserControl` is done by dragging it onto the designer, and then calling commands like `UserControl1.Update()` or `UserControl1.DisplayData(data)`. In any third-party `UserControl`, all commands to the `UserControl` are performed by commands to the control. There is no "presenter" that needs to be invoked, for instance, when I drop a `ComboBox`, or a `ListView`, or any other WinForms control onto my form. Yet they have internal logic that dictates how they display, and in the essence of testing, it should have a "presenter" separation to it **somewhere**. I _thought_ that a good solution would be that the **constructor** of my `UserControl` would create a Presenter. Any commands to the `UserControl` would delegate straight to the Presenter. This would allow my `UserControl` to have its own presentation logic separated from its "view", such that I can test it, and such that the implementer (the Main Form) need only drop in the `UserControl` and perform data sends and receives as part of its local presentation logic. The `UserControl` has its own presentation logic left invisible to the implementer. And just when I thought I understood it all, I find out that it's bad practice (The Self-Aware View). So I plead with people who understand this better than I: How do I construct a `UserControl` that keeps its presentation logic invisible to the end-user, such that I don't have to construct the wrapping presenter in my Main Form, **without** violating the principles that Matt Wynne discusses in the linked post above? Or am I completely misunderstanding the concept of MVP here?


what's the proper way to organize code that straddles multiple objects?

Let's say I have the following classes: person, widget, foo_bars. A person can have multiple widgets and foo_bars. When an admin deletes a person, I want my code to do a cascading delete... and remove all related records in the database for this person In my widget class, I have a delete method... and the same is true for my foo_bars class But in order to accomodate something like the person delete function, I feel like I should be creating "Person Manager" class, that will actually repeat a version all the logic inside both the delete methods in the widgets / foo_bars classes. (instead of just calling the existing methods on the classes. Here's what I'm thinking: **Example 1**                public class PersonManager{               delete_person(personID as int)          {              // assume that I've queried for list of all widget and foobars IDs.             //1.  delete all widgets for personID             success = true             dim obj_widget = new widget;             loop through all widgets                   result = obj_widget.delete(widgetID)                    if not result then                    success = false                     exit with error                 end if               end loop                   //2.  delete all foo bars for personID             if success then                  dim objfoobar= new foo_bars;                 loop through all foobars                     result = objfoobar.delete(foobarid)                          if not result then                         success = false                         exit loop                       end                   end loop               end                   //3. delete person record.              if success then                   result = databaseobj.deleteperson(personID)                  if not result then                       return false, "Delete person failed because...."                  else                      return true                  end                             end           }      }      In the above example, I'm trying to demo the reuse of existing the existing delete methods on each class... and then if it successfully deletes all widgets and foobars for the person, then i delete the person record itself. The problem with this is that if the widgets delete properly, but the foo_bars don't, how do I rollback? Each delete method has it's own transaction defined within, because deleting a widget or foo bar involves, let's say 2 - 3 steps. So, in other words, the delete method on the widget class currently looks like this:                   public class widget{              delete_widget{                      database.execute("BEGIN TRANSACTION")                      database.execute("DELETE FROM XYX ...")                      if successful then                              database.execute("DELETE FROM yyy...")                      else                              database.execute("ROLL BACK")                             return false                      end if                      database.execute("COMMIT")                      return true                   }           }      For each widget, I'll be calling this method... So what if all the widgets delete, but it dies deleting the first foobar? I think I have to rewrite the code to delete everything right inside the Person manager class and wrap it in a transaction, instead of calling the existing delete methods on the classes. At least, that's what I'm thinking. If there's another way to look at this problem, please let me know. I could just write a cascading delete SQL statement in the PersonManager class, and not call the methods on the two classes. But I don't know if using SQL cascading deletes is a good thing... Thanks!


Should methods returning a hashmap of string to object be avoided?

In my current code I have felt the desire multuple times to have helper methods that generate a collection of objects and return them as a map of string to object, with the string being some unique id like the objects label. Many of my objects have gaurenteed unique labels since these labels are used via restful interface when querying the object. The reason I want to do this is efficency. I may have a decent sized collection and I know that the method calling whatever private helper method I wrote will definately want to search for specific objects within my collection, so returning them as a map allows the calling method to run in O(n) instead of O(n^2). However, I feel that the return is not self documenting. The key is just a string, there is nothing that makes it obvious that the string is specifically the objects label. Obviously I will have comments to that effect, but ideally self documenting code is writen so well one doesn't have to go to method delarations to figure something out. So I have a few questions: 1) Is the fact that i find myself needing to return maps a code-smell in itself? (other then possibly premature-optimization, which I know I may be a little guilty of, but I don't feel too bad about worrying about the big O of a method) 2) Is this generally acceptable, or should I be looking into a cleaner approch? For instance should I have be making some map object that auto-maps any object by label? What about places that I want to return a map where the key is a different key, should I make a wrapping object for all of them? or is my map good enough? EDIT: More detail was asked, so to clarify my specific situation. I am working within java. While I may have unique strings they aren't known until compile time and enums are not a good fit, or I would have used them! I'm not using reflection or any other systems to dynamically generate data, the methods and their meaning is pretty much standard each time. Usually using the equivalent of a UUID of the objects (which in this case is a string which is used throughout the domain), or the label, which is a guaranteed unique string used to reference the object in question for a restful call.


Best practice for combining a Java Applet/ Android interface?

I'm working on an online game, which I am seriously considering writing a Java Applet for it. The game is not overly complex on the features. I'm considering at some point having at least 3 versions of the game, which include a Java stand alone, applet, and Android game. I know from Design Patterns that the best way to use differing things like buttons and the like is to use a Bridge interface, where I have a common template for the common buttons. However, I'm having a bit of difficulty understanding what to do about the following. I know that Android programs use an Activity structure, which I am well familiar with, and that Applets extend the Applet interface, which I am not as familiar with. I also know that a stand alone java program uses basically a main() function, which doesn't have much structure. I'm convinced that there should be a way to design a common design pattern between the two, but somehow I'm missing what that is exactly. What can I do to make the different frameworks work with as much common code as possible?


Are service locators really that bad?

People say Service Locators are bad because they expose the dependencies in some random method from the class (and not in the constructor's arguments like it should):               class A{          function F(){        DB::query(...)     }     }      instead of               class A{     protected $db;           function __construct(DB $db){       $this->db = $db;     }           function F(){       $this->db->query(...);      }     }      But consider a function, like `imagejpeg()` from GD. Obviously you can't "inject" that, so you have to call it somewhere in your class, just like your service. So isn't this the same thing? That function is a dependency too. Or what about instantiating an object somehwere in your class methods, like PDO. Aren't these things exactly like services after all? So why all the fuss about service locators being evil?


Sourcecode license: free for personal use and modification but no public distibution

For one of my apps, I want to make the source code “open source” so that others might adapt the code to their personal needs or even contribute improvements, but I don’t want anybody else to publish “my app”. Furthermore, I still want to be able to sell the app at some time in the future. Is there a usual license for this, like the GPL or similar? I found similar questions from 2010 which say something about dual licensing, but maybe there is a license fitting my needs?   * A commercial software but open and free for personal/edu. How to license?   * Free for personal use license?   * Open Source but not Free Software (or vice versa)   * Software licensing: open source, no commerical, no derivatives


How do you search your codebase?

I am using egrep to search our codebase, but at around 300MB of source code that starts to get a little slow. How do you search your codebase?


Where can I find examples of functional specifications?

I am writing a functional specification for a software program (Mac OS X application to be exact). I want to improve this by looking at other (good) functional specifications, but I cannot find any. Are there any (open-source) projects that have their specs publicly available so I can learn from them and improve my spec writing skills?


Unit testing a text index

Consider a text index such as a suffix tree or a suffix array supporting _Count_ queries (number of occurrences of a pattern) and _Locate_ queries (the positions of all the occurrences of a pattern) over a given text. How would you go about unit testing such a class ? What I have in mind is to generate a big random string then extract a random substring from this big string and compare the results of both queries with naive implementations (such as string::find). Another idea I have is to find the most frequent substring of length `l` appearing in the original string (using perhaps a naive method) and use these substrings for testing the index. This isn't the best way, so what would be a good design of the unit tests for a text index ? In case it matters, this is in C++ using google test.


UI (Specifically FLEX) automation testing

I was wondering whether the community utilizes automation tests to the extent of UI? Is there some common best practices for testing UI? Also - the product I'm working on is flex-based. I would love to get ideas how to test it. Mainly I want to test:   1. Data appears on the screen as expected   2. Field validations (for example: field is not a number) are working as expected   3. Alignment of fields And so on


What are all things that do/can happen when a user enters in a web page's URL?

Sorry if this is a naive title. I am trying to break into web development. I have taken a basic intro to OS, intro to Networking as part of my bachelors degree several years ago. I cannot say that we went into things deeply, beyond academic assignments. I would like to understand things much better regarding to this specific task (e.g what goes on in at the OS level, at networking level, what are other computers involved, where do proxy servers and hackers come in). Again, at the very basic level this has been covered, but I would like to review this specific thing better. Are there chapter(s) os a specific book, or specific SHORT reading that you recommend? I have nothing against your list of 20 favorite books, but I want to understand this one thing better in 2-3 weeks of reading after work / on the weekends (realistically 5-10 hrs per week, so I am looking for about 15-20 hrs of reading material, NO MORE). I am not a fast reader :) Thanks.


What can I do if my boss is asking about my program every hour?

Here is the situation: You are working on your complex, hi-tech code, and your boss keeps on asking if it's finished. But the project started just yesterday and you have two weeks to go. What can I do? Shall I keep on answering "I'm on it!"? :)


Why python library APIs are more intutive than C++ STL library APIs?

I am not sure whether it is a personal perspective or just a common feeling. I think in most cases, python's API is much more intuitive than C++ STL library APIs. If it is not a subjective judgement, could anyone explain why?


Is individual code ownership important?

I'm in the midst of an argument with some coworkers over whether team ownership of the entire codebase is better than individual ownership of components of it. I'm a huge proponent of assigning every member of the team a roughly equal share of the codebase. It lets people take pride in their creation, gives the bug screeners an obvious first place to assign incoming tickets, and helps to alleviate "broken window syndrome". It also concentrates knowledge of specific functionality with one (or two) team members making bug fixes much easier. Most of all, it puts the final say on major decisions with one person who has a lot of input instead of with a committee. I'm not advocating for requiring permission if somebody else wants to change your code; maybe have the code review always be to the owner, sure. Nor am I suggesting building knowledge silos: there should be nothing exclusive about this ownership. But when suggesting this to my coworkers, I got a ton of pushback, certainly much more than I expected. So I ask the community: what are your opinions on working with a team on a large codebase? Is there something I'm missing about vigilantly maintaining collective ownership?


Should I judge an IT company by the look of the interior office space?

I recently attended an interview for an IT company. Though the interview process itself was decent, I was shocked by the rather poor working conditions and interior of the office. A few things stood out:   1. The building is located in a shady area of an otherwise bustling mega-city.   2. The interiors are not well furnished. No false roofing with AC ducts, wires and pipelines randomly scattered overhead, no cubicles/desks/partitions, no proper meeting rooms.   3. The workplace had an unpleasant odour.   4. The interview itself was conducted in a makeshift room - almost looked like the safe locker of a bank to me. When I asked if they were in the process of renovating the premises, I was told, "No, that's how it's always been". In fact if I believe my ears, he mentioned that the building used to be a barn before the IT company occupied it. Should I really be worrying about all these aspects of my next employer? Doesn't it clearly hint that they don't have enough funds and interest for the betterment of their own workplace?


Extracting main article from webpage/feed. Is it legal/ethical?

There are some applications like Readability and Pocket, which are letting users to read the main content of web pages, in a clean interface or such. But the articles should be bookmarked from another application, or the web browser. However, I'm creating a news reader app (Zite and Flipboard are popular news reader apps), and I want to create a clean experience for users, so I want to show full content of articles inside my application. Some websites have fulltext feeds, and I'm using it. But about some other websites, which don't have full text feeds: I want to know, is it legal/ethical to use for example Readability API (Or maybe writing my own code for this) to show full text of articles inside my application?


Is it OK to use email as an identifier in a RESTful URI?

I'm working with a team building a RESTful web service, and our current implementation utilizes the user's email as a unique identifier for the user resource, yielding URIs like the following: `https://www.domain.com/users/example@gmail.com/resource` Emails are guaranteed to be unique in our system, and we've handled when the user changes his/her email, so it seems OK. But is it _correct_? The debate is whether we should use an immutable user ID instead, which in our case would look more like: `https://www.domain.com/users/a36571b87be464728c8d/resource` Or perhaps something else altogether. For instance, several Google APIs simply use `/users/me/resource` and identify the user via auth data. In a nutshell, is it acceptable to use a unique but mutable identifier in our URIs, or should we use an immutable one? Thanks!


Slower Ajax Response

Does putting the view logic inside the controller increase page load speed? Because I have a controller action calling a view which I am loading through ajax and I am getting a very slow response. Why is that happening? Does putting the view logic inside controller like...               echo "
View echoed
"      a good way to code? does this increase efficiency? I have writted a controller action like               class Ajax extends CI_Controller{        foo ($id){        $data = $this->model->get_data();//has joins in query        $this->load->view($data);      }     }      In view, I have used two foreach loops nested to get the table having about 100 rows and I load the view through a jquery ajax request to the url ajax/foo/1 My question clearly is whether it is a good practice to put view-logic into the controller for ajax calls? will it increase the speed my page will load. I am new to coding things very professionally. Is this a good and a professional method or any other alternative available.


Epsilon Transitions in an NFA

I'm attempting to teach myself the basics of finite automata and have been exploring the differences between Deterministic Finite Automata and Non Deterministic Finite Automita. One thing that pops up quite often in the on-line examples, lectures slides and videos of various CS instructors is the epsilon transition. The problem is none of them do very good job of explaining epsilon transitions. They just kind of pop them out of nowhere as this mysterious property that allows a you to jump from one state to another without reading an input character. O.K. I get that, but how are these arbitrary jumps facilitated semanticly if we were to create this automata? Take the image below for example. Lets say we are in S0, there are two epsilon transitions to s1 and s4. How is it decided which one to go down. If you go to S1 and do not have an a, can you backtrack and try b? I say this because the arrows do not seem to infer this. Or have I conceived this wrong, could the automata actually be in both states S1 and S2 concurrently? Also s3 and s6, have epsilon transitions to s7, so why don't we have two accepting states S3 and s4 instead? Finally the S2, has two paths that react to a, s5 has two paths that react to b. How does that work in practice. How is the path to follow determined? When answering please try to limit the use of esoteric mathematics, and if you do use operators and symbols explain each one clearly. I'm not a maths wizz. ![NFA with Epsilon Transitions](http://i.stack.imgur.com/qUDyA.png)


When is 'cloning', rather than reusing, a module acceptable design solution?

For this question, I'll give an example module to facilitate the discussion, Let's say the module is a calculation engine, It currently servers its purpose for its current audience. The requirement is to **clone** the same engine but with some **tweaking** for an entirely new audience. Given that, these are Considerations/Factors that will affect the design solution:   1. User expects that the current engine will remain **unchanged** , because its not part of the requirement (note the new engine is for some new audience, and does not affect the users of the current engine).   2. In addition to #1, the expectation is **no regression testing** for the code base of the current engine since no changes are introduced.   3. Just to drive the point, refactoring the current engine to make it flexible to address both current and new engines, will not be an option given that will not satisfy the 2 points above.   4. We can expect in the future that there will be **exclusive changes** for each engine, ie. change is applicable only to the new engine hence should not affect the current.   5. Tight deadline. However, I am still conflicted, since:   1. It will inherently be a copy-paste solution.   2. Duplicate code.   3. Maintenance issue for code changes that should be common to both.   4. Does not address extension issue, ie. a third engine, and so forth could all be possible. Is the **compromise** acceptable in this situation, given the user expectations highlighted above? And followup question, is there something I can add to the solution that will address the conflicting issues but at the same time satisfy the user requirements?


How do I avoid feature creep on a solo project?

So I have a program I'm worked on back in 2011 and all through 2012, but the last release was in December of _2011_. I've been actively working on it, but feature creep lured its ugly head and now it is filled with tons on unfinished features. The bad part is that as I implement a feature, a new one creeps in. What can I do to avoid feature creep in the future so I can **actually get a release out** in over a _year_? The project is based around iOS and used to have releases around each iOS version update, but the last one was back with 5.1 (2011). I would like to be able to get that steady release cycle back, but it has proven too difficult.


Determining if an Algorithm is O (log n)

I'm refreshing my CS Theory, and I want to know how to identify that an algorithm O (log n) complexity. Specifically, is there an easy way to identify it? I know with O(n), you usually have a single loop; O(n^2) is a double loop; O(n^3) is a triple loop, etc. How about O (log n)?


What personal milestones can you use to measure growth in your programming abilities?

How can you determine objectively, over time, that you are getting any better at producing code? For example, I may sit here and feel that "I know `<language>` now, and I use `<technique>` now, so I must be better." But this does not account for my own bias, or the fact that I may be getting better at a slower rate than intended, or I may actually suck at `<technique>` and not realize it. What methods are available for one to **objectively** rate one's own abilities? What about to objectively compare them to their peer groups?


Why is software still released with known bugs?

It seems that frequently in large projects the software is still released with the bug tracker full of bugs. Now I can understand feature requests, but several times I've seen large numbers of bugs still unresolved, not reviewed, or not finished but a release is still pushed out. Why? Why would an open source project or a project in general be released with **known** bugs? Why wouldn't they wait until the bug tracker had 0 opened bugs?


How does Go improve productivity with "implicit" interfaces, and how does that compare with C#'s notion of Extension Methods?

In the Go Language Tutorial, they explain how interfaces work: > Go does not have classes. However, you can define methods on struct types. > The _method receiver_ appears in its own argument list between the func > keyword and the method name.               type Vertex struct {         X, Y float64     }          func (v *Vertex) Abs() float64 {         return math.Sqrt(v.X*v.X + v.Y*v.Y)     }      > An interface type is defined by a set of methods. A value of interface type > can hold any value that implements those methods. This is the only way to create an interface in Go. Google further explains that: > A type implements an interface by implementing the methods. There is no > explicit declaration of intent [i.e. `interface` declarations]. > > Implicit interfaces decouple implementation packages from the packages that > define the interfaces: neither depends on the other. > > It also encourages the definition of precise interfaces, because you don't > have to find every implementation and tag it with the new interface name. This all sounds suspiciously like Extension Methods in C#, except that methods in Go are ruthlessly polymorphic; they will operate on _any type_ that implements them. Google claims that this encourages rapid development, but why? Do you give up something by moving away from explicit interfaces in C#? Could Extension Methods in C# allow one to derive some of the benefits that Go interfaces have in C#?


Releasing poorly written software

I've made a poorly written, yet fully functioning website, in _(shock, horror, shock)_ PHP. Everything works as expected, I've implemented the necessary security measures: http://php.net/manual/en/security.php and phpsec.org/projects/guide/ It's poorly written in the sense that it's a bunch of functions thrown together that do something...oddly enough I was consistent with the naming conventions. Would you release something you were not happy with, but worked? I would also like to point out that I don't collect much user information (username, email and password) is about it -- but it's not really the security part I'm worried about, it's the spaghetti code I've written.


What language is most similar to JavaScript?

I am looking for a language that   1. has First class functions   2. is dynamic   3. has prototypical inheritance   4. does not have too many features (i.e is easy to get into and write first program). I have been programming in JavaScript for quite some time and have gotten quite fond of it. Are there any other languages that have similar design? Edit (just some clarification) I know a bit of c#.After doing some programming in node js I really started to appreciate javascript and ease of its use.However outside of web development javascript falls short.Sure there are libraries like app.js that allows desktop programming but that's about it.Which is why I was looking for a more general purpose sripting language that has the above mentioned features.I listed those features to make the question more in tune with stack exchange policies other wise it would probably have been closed.


Exercise for implementing design patterns

I have started to study design patterns using some course in pluralsight and the gang of four book. While I feel I understand what I have studied so far, I think it would be very helpful if I would have some way of practicing them. I know that I will get the chance in time but I feel I would get a better understanding of each design pattern if I would do some exercises for each of them. What I would like is if someone knows any websites or documents that provide exercises for implementing design patterns. I am particularly interested in ones where the author provides some source code and the problem that has to be solved and I have to implement a design pattern to solve it. I am not interested in examples and theory; I already got that covered from what I am reading.


In Unit Testing, why would I create a Repository twice?

The other day I was reading a little about Unit Testing and I saw some examples where people create a repository interface (i.e. `IExampleRepository`) and then create the real repository (`public class ExampleRepository : IExampleRepository`) and a repository to be used for unit testing (`FakeExampleRepository : IExampleRepository`). In the `IExampleRepository` they were implementing the same methods as in the `ExampleRepository`, however with different Linq queries. What is exactly the objective here? I thought one part of unit testing your code is make sure that a method works correctly? But when I use two totally different queries, one for 'real' and one in the test, how much sense does the test make?


Code Reviews, what are the advantages?

In my team, we don't do formal code reviews. We tend to think that it's enough with pair programming and rotating pairs often. Should we consider doing formal code reviews? What would be the advantages?


Design of interface for finding one of something or a list

I am developing a telephony call model and thinking about how best to design the interface. One basic idea is that a call has a unique call identifier. I have a list of calls and finding a specific call is easy by callid. Each call has zero or more parties. A party has a device identifier (eg extension 201) and a state. Eg my extension 201 can be alerting or established or whatever. I have a class to represent a call which has functions to find a party on the call, I have the following findxxx functions:               party* find_party_by_dn(const std::string& dn) const;     int find_parties_by_dn(const std::string& dn, std::list<party*> pties) const;      find_party_by_dn seems ok, but it has a problem in that a call may have 2 parties with the same device identifier. Eg a user may put a call on hold and make a new consult call to another device. In which case the call has a party with dn 201 in state hold and another party with dn 201 and state dialling for example. So if I use function find_party_by_dn only the first party in the list with this dn will be returned. So I thought ah, why not return (well via reference) a list of parties with a given dn. Hence the second function. Does that seem like a useful interface? Could it be improved? I also have these functions:               party* find_party_by_state(const std::string& dn, pstate state) const;     party* find_party_by_states(const std::string& dn, int states) const;      In which case the caller needs to specify either a specific state or a number of states - eg state1 | state2 I am looking for feedback on this interface. Does it seem logical? Could it be improved to make it more user friendly or robust?


Implementation of automated updates

What is the best way to implement automated updates? I've gotten as far as libcurl, I imagine I need to ping the server every now and again with the current version of the software. But then what should I do? What server tech needs to respond, and how?


Writing data driven reflection based tests to ensure design completeness

When writing software I'm often forced to at some point to make a decision that involves a design pattern of "by convention" naming and behavioral patterns. This normally makes me feel kind of slimy as a .NET developer because nearly everything is statically typed (arguably even the dynamic type is statically typed, but others have covered this well, go read their blogs, they will thank you for it.) Naturally I encountered others with opposing views who felt that in many cases, convention based naming and behavioral patterns are actually helpful in that they allow for cleaner, more readable, and more consistent code. It was even stated that depending on how far that convention is taken, for instance into a type reflection name determined behavior scenario, that it might even enforce good naming by breaking functionality if naming in inconsistent with the established conventions. All of this brought me around to the place where the love and passion for development goes to die, "Testing." I came up with the following hypothesis: > Using naming conventions and associated behavioral or structural rules > associated with those conventions, it should be possible to write tests for > the product that enforce that behaviors and structures associated with names > are implemented correctly by reflecting the available target binaries. > Furthermore it should also be possible to enforce a by convention design > that doesn't allow for the misuse of naming conventions by means of having > names that fall under the naming conventions that don't follow those same > behavioral or structural rules to be used inappropriately (i.e something > with the word Locator in the type name that doesn't implement the service > locator pattern.) Has anyone ever investigated this kind of architectural and design testing and provability? What have your experiences been with writing architecture and convention tests? What challenges have you faced and what solutions have you devised? Are there frameworks or tools for doing this? Is there research on the subject done that has been peer reviewed?


How can I write HTML, CSS, and JavaScript to make back-end developers work easier?

When I get a design from a designer, I get it as a PSD (Photoshop) file. I always expect proper layer and folder names, basically a clean and managed PSD. From this desigbn I develop HTML, CSS and JavaScript and deliver it to the back-end developers. To make it easy for them to understand, I   * write semantic code,   * keep JavaScript and CSS in external files,   * add useful comments in HTML, CSS and JS files,   * use CSS sprites (though developers don't like it),   * use HTML5 boiler plate,   * use jQuery for JavaScript,   * try to use new HTML5 tags and CSS3 whenever possible and   * sent a Zip file containing the HTML, CSS, JS and images. I expect that if small changes will need to be made to the layout, the developers can handle that. I would like to hear from back-end developers and other CSS ninjas what more one could do in terms of organization of files and mark-up to make the integration with back-end systems easier (i.e. back-end technologies, PHP, .NET, Ruby etc.) Different client uses different systems.


Are there general rules or best practices for building a new framework?

I need to start the design and development of a new framework to interact with an open source ECM. This inludes a customized data model to help web site developers interacting with this ECM, so they don't need to care about the details of nodes manipulation and other low level details. That's just a bunch of classes and methods to develop. I have some doubts about how to handle the organization and managment of that project: Are there some general rules to follow, tips, best practices or something to keep in mind for developing this kind of project? I'm sure there are some difference between the development of a framework or library and an application.


"Extends is evil" vs. OCP?

As far as I have understood(?), the "Extends is evil" idea is in direct opposition to the Open Closed Principle? In here, the concept of OCP is presented as inherently using Extends:   http://www.oodesign.com/open-close-principle.html While in for example this article, the act of extending is considered a capital offense?   http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html?page=1 What is the correct way to satisfy both OCP and not using Extends? Consider a simple BulletinBoard class that has Posts, which can be either NewsPosts or GuestbookPosts with different properties, but same methods/behaviour.


How to apply one of the OOP concepts (Closed for Modification and Open for extension)?

Days before, I created Question, Quiz, and Main classes. One Quiz has one or more Questions. From the main class I first create Question objects (the constructor accepts an array of numbers). The Quiz is like when I display the questions I omit the last number of the array and the user will try to figure out that number. Then from Main I created a Quiz Object. From Main I only call methods of the Quiz class and from Quiz Class I only call methods in Question class. Then I also created a web application (with JSP and Servlets) which uses the same Question and Quiz classes but not Main. Instead of Main I used JSP and Servlets to display the data. So without modifying the model classes(Quiz and Question) I am able to use them from other applications. But now, I need to add a HINT, which will give the user hints for every questions. If I go and modify those 2 model classes, I am going to violate the Open-Close principle. If I am going to create a class called Hint(one hint per question) and extend from question class, it doesn't make a sense because Hint is not a Question. But Question has a hint. Can you please guide how to have a HINT in my application so that I will use the previous classes without modification and violating any OOP concepts?


What are the disconnected scenarios in Entity Framework?

I'm not sure I understand what all fall under the disconnected context scenarios in EF (See this and this). This link says use Web API or WCF services to avoid the complexities of disconnected tier EF solutions. Here's my understanding. If I create a new DbContext, get some entities, pass it to another process/machine (anything outside the scope of the current context), and there I make some changes to these entities and try to save them, then this is a disconnected scenario. EF will not know whether it is an Add or Update or what fields have changed, unless I explicitly tell it. Suppose I have an MVC app, with a UserController. The UserController takes in a IUsserService through dependency injection. UserService, the concrete implementation of IUserService takes in a UnitOfWork. My DbContext is instantiated for the UnitOfWork, and SaveChanges() is called only on Commit() of the UnitOfWork. I also set the lifetime of the DbContext in Unity as PerRequestLifetime -> which means one instance is created for each HttpRequest. My UserService works with different entities required to do its job. I believe this is not a disconnected scenario, **since my context is the same throughout**? If my MVC controller were in one machine (web), and the UserService in another machine(app - http endpoints exposed using webapi), does anything change? In this case, I need the DbContext only starting with ApiController, and everything will stay within the app layer. So I still avoid disconnected contexts. Am I right? If I'm not clear, I can put some code, but nothing different in there.


Is it a bad idea to return different data types from a single function in a dynamically typed language?

I come from a statically typed language background (Java). In Java, you have to return a single type from every method. For example, you can't have a method that conditionally returns a `String` or conditionally returns an `Integer`. But in JavaScript, for example, this is very possible. In a statically typed language I get why this is a bad idea. If every method returned `Object` (the common parent all classes inherit from) then you and the compiler have no idea what you're dealing with. You'll have to discover all your mistakes at run time. But in a dynamically typed language, there may not even be a compiler. In a dynamically typed language, it's not obvious to me why a function that returns multiple types is a bad idea. My background in static languages makes me avoid writing such functions, but I fear I'm being close minded about a feature that could make my code cleaner in ways I can't see. * * * **Edit** : I'm going to remove my example (until I can think of a better one). I think it's steering people to reply to a point I am not trying to make.


Why is it suggested stories be sized to 2-3 days?

If sprints are on average 10 days, why is it often suggested stories be sized to 2-3 days? **Related Question:** How to handle backlog-items that are longer than one sprint?


Is it a bad practice to use GUI designer tools with code generation for application programming in Java/C++?

In a stackOverflow question I have read that using a GUI designer program can generate lots of messy code and is considered to be a bad practice unless you're making smaller programs. My question is why and how. Is it bad to use a GUI designer program? Why? Additional details:   * Programming on a Windows platform;   * Only programming in C++/Java for windows programs.   * For IDE I've been using visual studio 2010 (Not the express edition) since it comes with the GUI designer.


Is there any work into the application of the Halstead complexity measures to determine software quality?

In 1977, Maurice Howard Halstead introduced his complexity measures for software systems, which included measurements of the program vocabulary, program length, volume, difficulty, effort, and an estimated number of bugs in a module. According to Wikipedia, difficulty relates to the difficulty of understanding the program when reading or writing it and effort can be translated into the time it takes to code an application where Time = (Effort / 18) seconds. A measurement is useless unless the data and calculations relate to some aspect of software development. However, I haven't found any work which states that a difficulty of a certain value or higher tends to a statistically significant increase in defects or a relationship between difficulty and time to read code (a difficulty of N yields an average of M hours spent understanding the code base) or any analysis of being able to compute Time after the fact being useful in determining quality (especially since time to write should have been recorded as a measurement already). I'm especially interested in Halstead's bug estimation (which is not mentioned on Wikipedia) - the number of bugs in an application can be estimated by Volume/3000 or Effort^(2/3)/3000. I'm looking for two things:   * Has anyone used Halstead's software complexity measures in a real-world application to assess software quality? If so, how did you apply them and did they turn out to be a useful, valid, and/or reliable measurement?   * Is there any academic research in the form of surveys, analyses, or case studies that discuss the validity (or invalidity) of Halstead complexity measures when applied to software quality?   * Is there any academic research in the form of surveys, analyses, or case studies that demonstrate the use of Source Lines of Code (SLOC) to compute something similar to the Halstead metrics of Volume, Difficulty, Effort, Time, and Bugs? I would suspect that Volume might just correspond to a SLOC count and Difficulty might correspond to cyclomatic complexity (and possibly other measures). I'm also well aware that measuring effort, productivity, or time in SLOC is potentially misleading.


Fixing a security exploit - but then everyone knows about it

Earlier, I was messaged about a potential security risk in one of my projects. I checked it and found that it allows for "arbitrary code execution". (Quotes because it is running in a VM, but the damage that can be done is huge nonetheless) Since it is an open source project, I imagine other people have found it and exploited it already. However, I am reluctant to fix it, because everybody will be able to see the commit and know about the exploit. Since I have no way of contacting the users and no way of forcing an update (updates are manual), I am at a loss at what to do here. If I let it stay, people are going to exploit it. If I fix it, people are going to exploit it even more. How can I proceed?


Subset sum problem is NP-complete?

If I know correctly, subset sum problem is NP-complete. Here you have an array of n integers and you are given a target sum t, you have to return the numbers from the array which can sum up to the target (if possible). But can't this problem be solved in polynomial time by dynamic programming method where we construct a table n X t and take cases like say last number is **surely** included in output and then the target becomes t- a[n]. In other case, the last number is **not** included, then the target remains same t but array becomes of size n-1. Hence this way we keep reducing size of problem. If this approach is correct, isn't the complexity of this n * t, which is polynomial? and so if this belongs to P and also NP-complete (from what I hear) then P=NP. Surely, I am missing something here. Where is the loophole in this reasoning? Thanks,


Should all foreign table references use foreign key constraints

Closely related to: Foreign key restrictions -> yes or no? I asked a question on SO and it led me to ask this here. If I'm faced with a choice of having a circular reference or just not enforcing the restraint, which is the better choice? In my particular case I have customers and addresses. I want an address to have a reference to a customer and I want each customer to have a default billing address id and a default shipping address id. I might query for all addresses that have a certain customer ID or I might query for the address with the ID that matches the default shipping or billing address ids. I'm not sure yet how the constraints (or lack of) will effect the system as my application and it's data age.


As a .NET WPF developer what are key differences I should be aware of when working with ASP.NET MVC?

I'm a fairly experienced desktop .NET developer with a solid feel for MVVM and WPF, and I've worked with JavaScript, jQuery and HTML/CSS in the past - though I'm pretty dated and haven't had a ton of experience with the new frameworks (Angular, et al). My question is, for anyone who has had to do it, what are the key pain points and differences I should be aware of when working on an ASP.NET MVC project? I have a general sense of the MVC pattern and where it differs from MVVM, but ASP.NET tricks me by looking familiar, but with subtle and not-so-subtle differences in implementation and execution. I'm helping out with an ASP.NET project at work, and while my C# knowledge helps, my desktop habits seem to be a liability. Links to material I can review would be appreciated, or a succinct summary of what I need to change about my mindset.


Separation of presentation and logic

I'm now writing a program, which will allow processing data expressed in the form of graphs. These graphs will determine workflow of the processing and they are actually an essence of this program (in terms of being the main object being edited by the user). It is very, _very_ tempting to put all the processing, data containment and presentation in a single control, which will also display these graphs and handle user interaction. From one side it seems to be violation of the presentation/logic rule, but from the other I'm certain I will write surely at least 2x or 3x less code, because I won't have to take care of constant synchronization between data model and the control, which will present this model (+encapsulation, interfaces, proxy classes etc.) I'm wondering how it is done in editors like Word. Is the data displayed by the control really physically separated from the presenter or are they combined? If you use the Word document control in your program, you ask the control to perform operations on text, what would suggest, that there is no separation (but we don't know how does it work under the hood). So the question: is separation between data presentation and logic worth it _even_ if it requires like 2x or 3x more code to keep everything consistent and synchronized? (yes, I mean 2x or 3x). * * * I've described the situation in more detail in the next question: How to separate logic from presentation?


How to ensure method finishes running before being run again

I'm new and I am trying to figure something out. I have a simple program which executes a method either when an event happens or when my timer ticks. Lets just say the method takes 5 seconds to complete. During that 5 seconds an event could happen. **What would I use/do to make sure my method isn't called while its already running.** Or is this something I would not have to worry about in a simple program, as it wouldn't run until the method is done anyway ? A little background and example. I am using System.Windows.Forms.Timer, I am not using any threads or anything, and I just have a simple windows form application with a timer, a method to do stuff, and two event handlers.               Program{       public Program(){         DoSomething();         Event.EventHappened += HandleEvent;       }       void DoSomething(){         MyTimerVariable.Stop();         InitMyTimer();         //Just do something check network, access db write line, something         //that in this example takes 5 secs for example purposes         MyTimerVariable.Start();       }       void HandleEvent(){         DoSomething();       }       void InitMyTimer(){         // Create Timer, and add Timer tick event       }       void TimerTickedEvent(){         DoSomething();       }     }      I left a few things out of that program, but just was trying to show how simple it is. I was just thinking about making it more efficient so that say in the middle of doing "DoSomething()" an event is triggered, I wouldn't want two "DoSomething()"s method running.


Utility Functions Best Practices

**Update:** Most answers are about how to write a wrapping interface or what is a good wrapper around ADO. but my question is more about when to do so and when not. I never found a good rule for deciding when to write a wrapper and when not. As nobody came up with a suggestion I think the reviewers are right in that this question has no general answer and is to broad. Even in the specific case of ADONET the answer may depend on the use case and for most use cases a wrapper has been written already. Dapper and Orseis for e.g. as MainMa points out. I would like to remove the question but I do not want to steel any ones points 8-) **Original Question** Let's take code executing a query using ADONET as an example.               var cmd = connection.CreateCommand();     cmd.CommandText = "SELECT 1 FROM DUAL";     cmd.CommandTimeout = 1000;     var dataReader = cmd.ExecuteReader();      Many will want to write this as a one-liner and create a bunch of utility functions in this example called as follows (or extension classes):               var cmd = connection.CreateCommand();     Utility.SelectToReader (connection, "SELECT 1 FROM DUAL", 1000);      So what are good rules to introduce or deprecate utility functions? Apart from ADONET this question arises using almost any framework.


Building complex algorithms with TDD

I'm trying to adopt TDD in my daily programming practice. I use it at work very effectively, but I'm having trouble with my personal projects where I'm using some complex algorithms. The particular algorithm that makes me ask this question is the Extended Kalman Filter. It's complex enough that I'm not confident in the code I've written, but it's simple enough that it's hard to break up. I could write a test for the algorithm with an input and the expected output, but I'll do a lot of thrashing and shotgun coding in the middle because I don't have confidence in those intermediate steps. If you've worked with reasonable complex algorithms and use TDD, what is your approach?


Design pattern for bidirectional signals/events

This problem feels rather basic, yet I've never known a great solution. I'm looking for a way for components in an application to notify each other while being as decoupled as possible (both at build/compile and run time), but also **avoiding circular notifications** in a way that components do not need to self-mitigate against. I happen to be hitting this issue (for the hundredth time) in JavaScript right now, but that is incidental. Some means of decoupling include:   * **Dependency injection (DI)**. In this case I use `require.js` which allows, for instance, substituting mock implementations in unit tests by creating alternate `require.config()` setups.    * **Event dispatching**. E.g. `fooInstance.listen('action string', barInstance.actionHandler)`   * **Publish/subscribe** (aka pub/sub). The last two are basically variants of the Observer pattern with different pros and cons. The problem I want to solve is not specifically addressed by these patterns, and I'm not sure if its an implementation detail or if there is a pattern to apply:   * `fooObj` sends a message (fires an event, whatever) that the `"baz"` property has changed   * `barObj.bazChanged()` handles this event by calling its own `setBaz()` method   * `barObj.setBaz()` fires an event that "baz" has changed   * `fooObj.bazChanged()` handles this event ... As a real case, imagine `fooObj` is a GUI component, with a slider for `"tempo"`, and `barObj` is a music sequencing component that plays back a score. The slider should affect the tempo of the sequencer, but the score can contain tempo changes so when playing the sequencer should affect the slider position. A solution should be modeless. One approach is to add guards, for example:               function handleTempoChanged(tempo) {         if (this.tempo == tempo) return;         ...     }      This works but feels like a poor solution because it means every event handler needs to either assume it needs a guard, which is ugly boilerplate and often not required, OR needs to be aware of the other components in the system that would make a cycle possible. Arguably, this point is wrong, guards should always be used _if_ the handler is going to fire a changed event directly or indirectly, but this still feels like boilerplate logic. This may be the only answer to my question... Is there general case pattern to deal with potential cycles as described? Note that this is _not_ about synchronous vs. asynchronous; either way the cycles can occur. EDITED to reflect insight from commenters: I realize it is possible to eliminate the boilerplate, using some sort of mixin. In pseudo-code:               class ObservablePropsMixin:              // generic setter with gaurd         function set(propName, value):             if this[propName] = value: return             this[propName] = value             _fire(propName, value)               // generic method to add listeners         function observe(propName, handler):             _observers[propName].add(handler)                  // private event dispatching method         function _fire(propName, value):             foreach observer in _observers[propName]:                     observer.call(propName, value)              ...      This is simplified to focus on my question, but a real mixin would implement other pubsub or event or signal semantics, analogous to any event dispatcher implementation. Components needing to be observers or observables would inherit/extend from the mixin (the above assumes some form of multiple or aggregate inheritance is possible in the language. This could be modified to work with composition instead, e.g. ObservableMixin.constructor(observedObject) rather than using "this".


Including front end designers in enterprise web development

We are developing a web application using Java EE. The stack is heavy, the deployment is complex and now we want to include a purely CSS designer in the team. We want to include this designer without having him have to understand the build and deployment of our application. We want him to be included in the projects version control. What is an effective way of allowing a designer to work without being exposed to to the rest of the project? Simply working from browser inspectors is insufficient, as it does not give him the ability to upload images.


How do random number generators work?

I am a Programmer out of Oregon, I currently work as a web developer for a local company, and am starting college this winter for Computer Science. I was just pondering about php `rand()` function, and thinking about how I could remake it, and I came up completely stupified. How the heck do random number generators work?


What is the difference between SOAP and Web Services?

Keep getting confused about these two. Anyone care to explain the difference(s)?


Developing JSON API for a Carpool Engine

I am developing a new set of API methods for carpooling/cab booking, so if a developer needs to develop an app or webportal for carpooling, he can call my JSON API. Basically making it easy for developers. My API current has:   * `AddVehicle`   * `AddJourney`   * `SearchJourney`   * `SubscribeToThisJourney(journey)`   * `SubscriberList(journey)` to get list of people who have subscribed for this journey   * `AcceptSubscription(subscriber)`   * `AcceptedSubcriberList`   * `SubscriberList` to get list of providers I have subscribed to I need help with replacing subscriber with something else. It's difficult to remember, and confusing when you see 3 methods that mean very different things: `SubscriberList`, `SubscribedToThisJourneyList` and `AcceptedSubscriberList`. Confusing to remember.   * One is a list of who I have subscribed to   * Who has subscribed to me   * Whose subscription I have accepted How can I name these methods to make them easier to understand and remember?


Game programming : C# or C++?

I've decided what I really want is to do game programming. So the question is, as a 18 years old who wants to learn self taught programming, what is the most suited programming language between C# and C++? (I should state that I don't care about Unix because I believe windows will be still the most used OS) I know the basics of C++, but none about C#. I know that C++ has more tutorials guides, dlls and stuff like that, while C# doesn't, but it's far easier to learn and to use for a single person to develop a program, but I've read even if the program is obfuscated it's easy to get the source of it. Well, I kinda want to focus on basic a lot first, I must say that I have a preference for C++ just because it feels more suitable to me, but I must consider that I work alone. So even if I like it, it may not be the best thing to do. I am really not sure of which one to go for, I've read a lot of threads on various websites and it looks like C# is becoming more popular than C++. But yeah, that said, I also specified I want to do game programming. So I need to know some better points than just "C# is easier because of .net memory handling while C++ isn't" because I couldn't just find it.


DB Schema for packaging products / services together under a single pric / Offer

I'm trying to 'conceive' the business logic of this website that have many activities, that the users can build their "combo" and get discounts depending on their choices and how long they are willing to pay for their plan (1, 3, 6 and 12 month plans). I'm having a hard time trying to come up with a solution, while keeping the database normalized and with proper relations, without having to resort to JSON encoded data in the database fields. The system must stay generic enough to fit many businesses types that relies on plans / activities. **I need to know how to do the structure of my tables**. Scenario: For example, in case of a gym, will have bodybuilding, yoga, boxing, body pump. If the person choose bodybuilding and boxing, they will have a discount, if they add yoga, boxing and bodybuilding will keep the discount but will add the yoga without any discount to the price, but if the person decides to pay 12 months upfront, they will get a bigger discount. Bodybuilding + Body Pump   * `Bodybuilding..$70 | 28% discount`   * `Body Pump.....$70 |`   * `Total.........$100`   * `1 month - $100 / month`   * `3 months - $91 / month`   * `6 months - $75 / month` Bodybuilding + Body Pump + Yoga   * `Bodybuilding..$70.00 | 28% discount`   * `Body pump.....$70.00 |`   * `Yoga..........$90.00 | No discount`   * `Total.........$190`   * `1 month - $190 / month`   * `3 months - $171 / month`   * `6 months - $158 / month` I'll be using PHP and MYSQL, but that doesn't matter much, only the RDBMS part. * * * **Edit for clarification:** What I really looking for is a DB Schema for Packaging products (or in this case services) together under a single price\Offer. Each product must also exist in the systems as a stand alone product. I Still need the ability to report on sales (& Profit) by product even if that product was sold as part of a package. I would Need the ability to report on Package performance.


Having error codes option in C++ library for performance

I have written an open source and cross-platform C++ File Library which have exception and error codes. Exceptions can be disabled when the program is running. In that case, the user have to check the error codes. Of course, when exception throwing is enabled, error code won't be returned because exception is thrown before the called function returns. Currently, exceptions still could be thrown when disabled (bug). I'll fix that soon. Someone comment to me that it is considered bad design to have both exception and error codes. I agree with him and I am about to remove the error codes and have library throw custom derived exceptions with more error information. But I hesitate. I like to have this hybrid approach for performance reasons. This is what I am thinking of doing: keeping exception throwing and error codes but exception throwing is disabled through macro at compile time instead of runtime. If user define the following in a common config file               #define ELMAX_EXCEPTION 1      The follow code               int Write(std::wstring str) ELMAX_THROW_OR_NOT;      would expand to either of the 2.               // under C++11 compiler     int Write(std::wstring str) noexcept;          // under C++98 compiler     int Write(std::wstring str) throw();      If `ELMAX_EXCEPTION` is not defined or is zero, the macro would expand to nothing.               int Write(std::wstring) ;      The reason I want to do this, is for library user who wants the performance gain of not having the compiler generating the stack unwinding code (for exception) and compiler can better optimize such functions. My C++ file library is using C file API and the only thing which could throw exception is `new` keyword, which I intend to add `nothrow`. The UTF-8 code can also throw exceptions (need to be changed too)               char *parr = new (nothrow) char[num];          if(parr==NULL)         // handle it either through error code or throw exception (if enabled)      Please kindly advise if I should have a pure exception approach or a hybrid approach (as mentioned), for my library errors?