title: I'm struggling with abstracting my animation code in my game using a functional style. How can I do this?

text: My game is a top down 2D shmup programmed in a functional style. I'm struggling with abstracting the code that is responsible for animating the projectiles. There are many types of guns with many types of projectiles. Here are a few that are very different:   1. A **standard gun** that shoots a bullet that travels a distance over time.    2. A **laser** that shoots a line that goes from start to end in an instant.      * This is different from the **standard gun** projectile because its projectile doesn't travel over time. It's drawn as a line. Unlike the standard gun, the laser beam animation should last after the projectile hits something.    3. A **psychic shockwave** that forms a circular blast wave around your body and damages anything in range. The size of the circle is variable.       * This is different from the **standard gun** projectile because its size is variable and circular. Also, it doesn't move. I'm struggling on how I can use a sprite sheet for this. It seems like the best way might be to draw a circle on the screen. All the other projectiles are sprites.      * This is different from the **laser** because it's a circular shape rather than a line.  If this were object oriented, the path I'd take is straight-forward: I'd create an `Animation` class that is responsible for animating itself. The client code would have no idea _how_ the animation occurs, it would just pass in the necessary objects in order to get it done. But I'm not sure how to do something like this in a functional style. Right now I represent everything as data. A `projectile` contains `animation` data like so:               projectile: {       type: "laser"       animation: ...     }      But what feels very wrong is I have to have one switch to create this projectile, and then in my rendering code, I have to have _another_ switch to decide how to use the data to animate it. EG:               if projectile.type is "standard gun"       rotateBulletTowardsVelocityAndAnimateAtPosition(projectile)     if projectile.type is "laser"       rotateLaserTowardsTargetAndAnimateFromStartToTarget(projectile)     if projectile.type is "psychic shockwave"       drawCircleAroundProjectilePosition(projectile)      This doesn't seem very abstract to me. What's a better way to code this while still being functional about it?


title: Difference between Yesod and Ocsigen web frameworks

text: I have been looking at web-frameworks in functional languages and eventually found Yesod and Ocsigen interesting. As far as I understand, they leverage the type system to statically prevent basic errors such as invalid HTML or internal dead links. My question is are there practical differences such as feature focus or maturity between these two frameworks? What does one have that the other miss? For example, with Yesod, can I write the entire web-application in Haskell and have the appropriate component compiled to Javascript? Thanks.


title: Unit testing statically loaded data

text: Scenario: I have a configuration file containing some structured data that is loaded in at runtime and is **not** modified by the application, but is referenced in many places. There are functions that retrieve specific data from the configuration file (after it's been loaded into memory). I'd like to write unit tests that ensure that data has not been changed inadvertently by a developer, is this good practice or overkill? E.g. `Assert(GetDataForKey("SomeKey") == "MyValue")`


title: How to prove that following practices and industrial standards are profitable, and investment in refactoring are good

text: I started working in a company not much time ago, and what I see a lot inside a project is a high amount of low quality code and some custom ideas instead of industry standards and selected best practices. But when I trying to talk with manager about that, I often see the answers, that guys who doing that make things quick and they are good etc, etc, etc


title: How can I study C# from Stack Overflow

text: How can I study C# from Stack Overflow?   I have only the basics of the C# language with some simple exercises; now I want to go to the highest level C# through Stack Overflow, reading any questions tagged "c#". The questions are not ordered from easiest to hardest. Do you have any idea on how to learn C# from Stack Overflow?


title: C++ Multithreading on Unix

text: I have two related questions:   1. Are there any good books for multithreading in C++, especially now that C++11 contains multithreading in the standard library?    2. I have the Wrox Programming on Unix book (1000 pages fat red one) and within it, it uses the Unix Thread class.      * How does this code relate to boost and the C++11 multithreading libraries?      * Is it better/worse/just specific to Unix etc?      * Is the performance the same?


title: What is the actual purpose of MVC?

text: I've seen a lot of stuff that describes how it's done, but not a lot that tells WHY it's done. Is it just a way to keep the code readable, or is there a better reason?


title: Best patterns for variable-scope disposables

text: I have `Client` which uses a disposable `Connection` for talking to a remote service. A `Connection` is somewhat expensive to set up and needs to be Dispose()d properly. I want to allow multiple methods in `Client` to share a connection, like this:               using (client._connection = client.Connect())     {       client.SyncTime();       client.UpdateUsers();       client.SomeOtherOperation();     }      But I don't want to _insist_ on `Client`'s consumers managing connections. They should be allowed to call individual single `Client` methods without being aware or concerned with `Connection`s. Here is the pattern I'm using at the moment. It makes SRP cry. Any suggestions on how I can do this better, or should I be doing this at all?               public class Client     {       Connection _connection;            public void SyncTime()       {         bool wasConnected = _connection == null;         try         {           if (!wasConnected)             _connection = Connect();                _connection.ActuallyDoSomeWork();           ...              }         finally         {           if (!wasConnected)             _connection.Dispose()         }       }     }


title: Why isn't Lisp more widespread?

text: I am starting to learn Scheme by the SICP videos, and I would like to move to Common Lisp next. The language seems very interesting, and most of the people writings books on it advocate that it has unequaled expressive power. CL seems to have a decent standard library. **Why is not Lisp more widespread?** If it is really that powerful, people should be using it all over, but instead it is nearly impossible to find, say, Lisp job advertisements. I hope it is not just the parenthesis, as they are not a great problem after a little while.


title: C# open-source framework for multithreaded task management

text: I have an API library for C# that provides flexible multithreaded task management of objects on task bases. The library was developed extensively for a project that was later cancelled by the client. I received the legal rights to the library, and the client doesn't care what I do with it now. I don't know what to do with this source code. Can you please explain to me, what the steps are in taking source code and making it a successful open source project? How do you attract developers? How will people know the library exists? EDIT: The reason I ask this question, is to bring the source code to an open source state. I'll be adding a full set of unit tests, documentation, examples, etc.. etc.. That represents more investment of my time, and if there is no pay off "i.e. no one uses it". Then what's the point?


title: Will object reuse optimize this often-called function?

text: Suppose I have a function that I need to call a lot, maybe a few thousand times on every mouse down or mouse move. It uses an instance of a function (class), called `Transform`:               function func1(a, b, c) {       var t = new Transform();       t.rotate(a);       t.scale(b, c);       return t.m[0];     }      So I'm creating thousands of new transforms as I call this `func1` lots. What if, instead of creating `new Transform()`s every time, I created a small system to allocate extra transforms only as they are needed, and re-use them:               window.Util = {       _CachedTransforms: [],       tempTransform: function() {         var arr = Util._CachedTransforms;         var temp = arr.pop();         if (temp === undefined) return new Transform();         return temp;       },       freeTransform: function(temp) {         Util._CachedTransforms.push(temp);       }     }      Then instead I could call `func2`:               function func2(a, b, c) {       var t = Util.tempTransform();       t.reset();       t.rotate(a);       t.scale(b, c);       var result = t.m[0];       Util.freeTransform(t);       return result;     }      Using `func2` several thousand times, `new Transform` is only ever called once. This might suggest a benefit, but the numbers from jsperf don't seem to suggest any. If you want to see these two functions in action as well as the Transform class, take a look at jsperf: http://jsperf.com/transforms And especially: http://jsperf.com/transforms/2 To simulate it occuring lots during an event, my jsperf test does:               var a;     for (var i = 0; i < 4000; i++) {       a += func1(1, i, 3); // vs func2     }      There may be better ways to test if this is advantageous or not. Am I missing something? More broadly, is object reuse like this still a good idea in this scenario, or ever?


I was under the impression that the concepts of time and memory complexity are a must for graduates of compsci courses, but having studied engineering I have no knowledge if that is the case. I have recently been surprised to interview some graduates of a local college that do not even know the concept. I guess my question is: Is the concept of computational complexity important for software developers? And should it be taught in undergraduate courses?


title: How to fulfill EASTL license

text: I'm integrating EASTL into my game programming framework. I did some changes to it since I have my own memory management sub-system and now I'm wondering what I need to do to not break the license under which EASTL was released. The source code files include the following notice:               Copyright (C) 2005,2009-2010 Electronic Arts, Inc.  All rights reserved.          Redistribution and use in source and binary forms, with or without     modification, are permitted provided that the following conditions     are met:          1.  Redistributions of source code must retain the above copyright         notice, this list of conditions and the following disclaimer.     2.  Redistributions in binary form must reproduce the above copyright         notice, this list of conditions and the following disclaimer in the         documentation and/or other materials provided with the distribution.     3.  Neither the name of Electronic Arts, Inc. ("EA") nor the names of         its contributors may be used to endorse or promote products derived         from this software without specific prior written permission.          THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY     EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE     DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY     DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      Since I will probably be releasing the source code on GitHub at some point, but do not plan on releasing any binaries without source code, can I just add something similar to my own source files and be okay with this? Will something like the following do?               /*      * Copyright (c) 2012 Bartlomiej Siwek All rights reserved.      * Based on EASTL (https://github.com/paulhodge/EASTL) - copyright information follows.      */          /*      * Copyright (C) 2005,2009-2010 Electronic Arts, Inc.  All rights reserved.      *       * Redistribution and use in source and binary forms, with or without      * modification, are permitted provided that the following conditions      * are met:      *       * 1.  Redistributions of source code must retain the above copyright      *     notice, this list of conditions and the following disclaimer.      * 2.  Redistributions in binary form must reproduce the above copyright      *     notice, this list of conditions and the following disclaimer in the      *     documentation and/or other materials provided with the distribution.      * 3.  Neither the name of Electronic Arts, Inc. ("EA") nor the names of      *     its contributors may be used to endorse or promote products derived      *     from this software without specific prior written permission.      *       * THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY      * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED      * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE      * DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY      * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES      * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND      * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT      * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF      * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      */      P.S. This is a repost of a legal-like question from StackOverflow where it was found off-topic. If this is off-topic here as well, please tell me where I can ask such question?


title: LINQ to SQL - Business logic in another assembly?

text: So I am trying my hand at this whole tiered application thing with ASP.NET 4. The software I've developed is a maintenance nightmare and it isn't very well organized. I've done some looking around the web and can't seem to find an example of what I'm looking for here. Someone please pick this design apart. My Data Access Layer will be an assembly with LINQ to SQL. I will have a Business Logic Layer that references the DAL assembly and does what BLLs do. Very general and basic stuff. Then I will have a business objects class that does some that is data-related but is more "work" type stuff - like generating documents, etc. The web site will interact with the BLL and the business objects. So:                   DAL          |          |          |         BLL----------BO          |           |          |           |          |           |         Web----------|      Am I making this way too complicated? Should I just put my business logic right in there with the LINQ classes in the DAL? I'm not sure how a DataContext would work in a separate assembly with classes that inherit from LINQ classes. Thoughts?


title: Can my GitHub and SourceForge account share the same repository?

text: I like that SourceForge can also let people browse your code using Git. But, before I even set up the project on SourceForge, I had a GitHub repository for it. Now that I have created my SourceForge project, I had the option to use the Git tool. The problem is when I did that it made a new repository from scratch. I would like to use my existing GitHub repository with my SourceForge project, is this possible? As of now the SourceForge project has no files, so the button on the summary page, instead of a 'Download' button, is a 'Browse Code' button, but the button leads to an empty repository. So I am wondering, is it possible to link my SourceForge project with my existing GitHub repository, or do I need to remove the 'Code' tool from my SourceForge project and just leave a link to my repository in the description?


title: Are there languages that expand on the STL's iterator types?

text: Many languages use the concept of an iterator. The c++ STL expands on this with input iterators, output iterators, forward, bidirectional, random access and others. As far as I know, these distinctions don't exist in other languages. In this talk the author of the STL, Alexander Stepanov, talks about iterators (among other things), and mentions the idea and of 2-dimensional iterators. I haven't seen these anywhere. Question 1: Are there other languages/ libraries that expand on iterators and/or use 2-dimensional iterators? Question 2: Could anyone point me to some good resources on iterator theory (if that is what it's called)?


title: Efficiently compute distance of location to POIs?

text: I want to write an android application that holds information where (climbing) rocks are located in a wider area. I want to display all rocks nearby my current location (say below 500m) and may be update the displayed distance to them (straight-line distance) in real time. To naively compute the distance between two points will not be efficient regarding a rock database with thousands of entries. For this special case the use of online services is discouraged as they are not available at all. I've heared about some location-aware databases. Does anyone have experiences with them (under android)? Is it efficient enough to divide the map of rocks into quadrants and enrich the rock database with these information? (Then compute the quadrant of the current location and only compute the distances of the rocks in the nearby quadrants?) I tried searching for an answer to this question (I'm sure others had these question too) but could not find anything appropriate. **tl;dr** How do I **efficiently** find points of interest near my current gps location?


title: Server distribution for high performance

text: I've developed a Socket Application on top of TCP in .NET C#, which allows many clients to send files from one another via a VPS I'm using. Most file transfers will occur between people in the same region, say, even in the same neighborhood. So, If 300 clients are connected, some of them will be connected from say Europe, others from, say the USA etc... Those who are connected from Europe will never try to send files to those in the USA. What matters to me the most is scalability (hopefully, I will have thousands of users connecting simultaneously), and low latency (responsiveness) when it comes to upload/download transfer rates. Something tells me, that if I want the files (up to 2MB) to be transferred quickly between my clients, I should get a VPS in Europe, USA, Asia etc. In this way, users will get higher transfer rates, and in case one of the server fails, they will be able to use the the other one(s). Besides, I should have a separate database for user info/statistics to which all of the servers connect when needed. My question is, what is the common practice for such usage and requirements? Any kind of clue/terminology I should start to get familiar with will be highly appreciated. Thanks


title: How to justify migration from Java 6 to Java 7?

text: We were migrating from Java 6 to Java 7. The project is behind schedule and risks being dropped, in which case it will continue to use Java 6. What are the specific improvements in Java 7 that we could go back to our manager with and convince him it is important to use JDK 7? Looking for bug fixes that I could highlight in Oracle Java 7 (with respect to Java 6). Fixes in security, performance, Java 2D/printing, etc. will be more sellable in my case. Compiler fixes for example, will not of much use. [I am going through many sites like Oracle adoption guide, bug database, questions on Stack Overflow]. Update: Thanks for the answers. We rescheduled the update to next release. Closest we got was security. Accepting the highest voted answer.


title: Is it generally a good idea to work with JDK 6 instead of JDK 7?

text: As far as I know, there aren't a lot of differences between JDK 6 and JDK 7. At least, I haven't yet come across a difference (I coded with JDK 7 and with JDK 6). A lot of computers run JRE 6 or JRE 7. Compiling my program using JDK 7 will narrow the number of potential computers that can run my application. Is it generally a good idea to always program using JDK 6 and compile my program for JRE 6? Is this something common? Or is it generally a bad idea?


title: Organisation of $(document).ready

text: I have some code that looks something like this, except rather than 2 sections, there are about 20, and they have real code in them:               /*------------      * Contents:      *  1. Load slider      *  2. Check form     /*------------              /*------------          * 1. Load slider     /*------------          var slider_id = 101;     var num_slides = 10;          $(document).ready(function(){         // Initiate document ready slider     });          /*------------          * 2. Check form     /*------------          var fields = {"text","number","textarea"};          $(document).ready(function(){         // Do some document ready form stuff     });      I'm trying to keep everything neat as there is going to be a handover at some stage. My question is should I do it like I have done, or something like so:               /*------------      * 1. Load slider      * 2. Check form     /*------------              /*------------          * 1. Load slider     /*------------          var slider_id = 101;     var num_slides = 10;          /*------------          * 2. Check form     /*------------          var fields = {"text","number","textarea"};          $(document).ready(function(){         /*------------              * 1. Load slider         /*------------              // Initiate document ready slider              /*------------              * 2. Check form         /*------------              // Do some document ready form stuff          });      So, do I minimise document ready calls, or group associated content together? Just self taught so no idea about these kinds of best practises. Thanks


title: Storing escaped mysqli characters in database but outputting them correctly with htmlspecialchars()

text: I have a database sanitizing function that I use when the user enters some data into my website. I escaping the mysqli characters with mysqli_real_escape_string(), but I wish to also output the content with htmlspecialchars(). The problem is, let's just say the user enters something with a single quote; that will be escaped by the sanitize function and will be output as \'. Is there any way to store it like that, and then output it as '?


title: Generic service control interface

text: I need an interface to a back-end service, mostly for control commands (stop, status, cancel, reload config). The service might be in Python, Perl, Java, or whatever, and runs continuously. The interface will let me send infrequent commands to the running process. A signal handler can tell a process to stop, and USR1 and USR2 signals let it do two more things. Tomcat sets up a special listener on a fixed port number to get it to shutdown, perhaps due to limitations of Java signal handling. But I'd like it to respond, not just react. And I'd like to use this for a service written in any language on any platform. I'm hoping to avoid middleware or databases to communicate, since it's a simply request/response (Q: "how are you?" / A: "I have been running for 3 hours at peak efficiency"). I glanced at these but they seem like overkill for a simple control interface:   * dBus \- general interprocess message bus   * UPnP \- device communciation   * Avahi \- DNS queries to find services   * Hadoop YARN \- Distributes work across a network, parallel processing Each seem compelling, but they feel heavy weight or else require special software to be installed ahead of time, or aren't for every language or every platform. If I wrote my own, I could write a single-threaded TCP listener with JSON requests/responses. That seems about as lightweight and universal as you can get, and is small enough for a "hello world" service, and big enough for speaking to any service. JSON over TCP would be very command-line friendly (curl or netcat), and therefore easily scriptable. Lots of languages already have a JSON library (C++, Java, etc), in any platform. A harder approach is adding HTTP semantics to the JSON request/response so you could browse to your application or use curl to control it. But embedding HTTP seems like a lot of space and complexity when it will only support a few resources (PUT text/plain "true" to /stop to shutdown your app, GET application/json from /status to see how it is running). Frankly, I'm surprised nobody invented a standard service control interface for simple things like basic control commands. At work we used CORBA and registered in a naming service and then had to deal with Java/C++ ORB connection issues and it seemed like tons of code for something that should be simple.


title: Is there a name for this anti-pattern? (Variable has context-dependent meaning)

text: I'm working on a legacy system with troubling behavior - it uses the same identifiers to signify different things in different places. The system in question is a CRM system. It uses special codes for each subscriber's account to signify a bundle of features they've purchased access to. These codes are transmitted to licensing servers, which activate the appropriate features. However, the same code means different things depending on which licensing server happens to serve the subscriber. For example:   * Code 241 means the subscriber has access to features 1-10, 12, and 20-50 if they are served by licensing server A.   * Code 241 means the subscriber has access to features 1-20, 33, 34, and 50 if they are served by licensing server B. Clearly (to me, at least), it would be better if each code meant one things. That is, 241 should mean (1-10, 12, 20-50) everywhere and new code 242 should mean (1-20, 33, 34, and 50) everywhere. Is there a name for a problem of out-of-band data being required to uniquely specify something?


title: JavaScript Combination Inheritance Pattern

text: In the chapter of Professional JavaScript for Web Developers on OOP, Nicholas Zachas describes a JavaScript inheritance pattern which he refers to as _combination inheritance_. The basic idea is that methods are inherited via prototype chaining; whereas parent properties are passed on to descendants by calling the parent constructor within the child constructor. A small example:               function Parent() {         this.parentProperty;     }          Parent.prototype.parentMethod = function() {         console.info(parentProperty);     }          function Child() {         Parent();     }          Child.prototype = new Parent();      He concludes his discussion by saying that "combination inheritance is the most frequently used inheritance pattern in JavaScript." However, in his following discussion on the prototypal inheritance pattern, he mentions a shortcoming of combination inheritance, namely that the child type invokes the parent constructor twice: once when creating the prototype and then again in the constructor. My question is why does the combination inheritance pattern suggest extending the prototype by having the child's prototype be an **instance** of the parent type, why shouldn't it just reference the parent's prototype directly? Using the previous example, why not just do the following:               Child.prototype = Parent.prototype;


title: How can I maintain my technical skills after becoming a project manager?

text: As I advance in my career, I have found that I do less technical work and more project management work. I joke that I am getting dumber every day. Each time I go back to doing technical work it seems to be a little harder to get things going. What suggestions do people have for maintaining technical expertise throughout your career?


title: Where does Windows Workflow Foundation fit into the messaging oriented middleware architecture?

text: I've been trying to find information online about where WWF 4.5 fits with in an architecture based around an enterprise message queue using central broker(s) (RabbitMQ in particular). It seems like responsibilities overlap a bit since WWF offers the ability to pause-and-resume (persist/restore) workflow instances. I'm wondering if I'm erroneously equating this pause-and-resume WWF functionality to the general message queuing concept. Having looked at MassTransit, in particular a code listing of a sample Saga showing parallel code "activities" that then "combine" when completed... it seems like WWF excluding the pause-resume functionality in this context, is better compared against MassTransit.. is this an accurate assessment?


title: How would you introduce an agile methodology like scrum?

text: If you've found agile and walk into a workplace that doesn't particularly follow any methodology and they are resistant to change (as most people usually are), how would you introduce an agile methodology like scrum? **NOTE:**   * Well, I've phrased it as a hypothetical question, but it isn't.   * I'm not very confident about Agile myself


title: Can I share ~1k of dynamically updated data between HTML5/JS pages using only apache2?

text: I have an HTML5/Javascript web site. There is a form which updates JSON data. There are other pages which I would like to load that JSON data dynamically. I know how to do this via Tomcat/JSP but I'd like to keep this site solely apache2. Is there a way to persist and read the JSON data? It is ok if the data is temporal and is lost upon an apache2 bounce.


title: As a self-taught programmer, how do I get the academic foundation without attending school again?

text: I've made a pretty good living as a self-taught programmer, but when I find that I discuss some low-level fundamental topics with my peers who have a CS degree, holes appear in my knowledge. I'm a big picture (architecture) guy, so for a long time this hasn't bothered me, but lately I've wondered if there is an approach I can take that will help me learn these fundamentals without going back to school? Are there books, websites or videos that you can recommend that would give me a ground-up perspective as opposed to a learn it as you need it mentality?


title: How to trace logical errors in algorithms

text: I am beginner in algorithms. Last year I participated in Google Code Jam. One of the major issues I faced during the competition was my code was working fine on my test cases, but when I submitted on a large number of test cases, I failed to pass them causing some logical error. So, my question is basically how can I trace logical errors in my code in such situation where it fails to match some test cases?


title: How can I deal with a slow API in PHP?

text: I'm writing a public web app to get stock data from a magento store. I've accessed the data, but it turns out that i have to query each product individually for stock data. With thousands of items this is a resource hog and takes lots of time. This cannot be avoided. It's just how their API works and I have to do it this way. How can I code something in php that runs in the background, harvesting the api data by nibbling it in a calmer more friendly manner, and not hammer their shops with SOAP api calls? Am I right in thinking that I need to use a background process like this: $pid = shell_exec(sprintf('%s > /dev/null 2>&1 & echo $!', $command)); ...and then query that $pid? Store them in a database? Are there any examples of background process managers?


title: Legitimate reasons for circular references in C++

text: I have project written in C++ that I am working on which has a parent-child relationship where each child has only one parent. I had previously decided after looking at this post that I would make the children know nothing of their parents. A little background on my project before I go into my question: The parents in this situation are objects representing a collection of interlinked computational "blocks". The parent (The "Model" class) takes in one or more input values, runs them through its blocks, and the blocks return back one or more output values. The child objects are the Blocks and a Block is owned by exactly one Model. The issue is that a certain kind of Block can contain a Model so that I can nest them and re-use models. Although most blocks know nothing of the Model class, the ModelBlock (inheriting Block) knows about Models and is allowed to encapsulate a Model. **The Question:** The above seemed to be working pretty well, at least in the console version of my application. However, I need a GUI to be able to create any large Model without losing my mind and so I have started making one. The issue has reared its ugly head again when I realized that the Blocks in general need to know about their Model so that ModelBlocks can inform a Model when it is being used inside of another Model. This is so that I can easily find "orphaned" Models that are not the root model and not used in any other context (meaning they will never be run). I guess I could make it specific to ModelBlocks, but if I'm going to do something like that, why not make it apply to all the blocks? In C#, its seemingly not a bad practice to use a circular reference to accomplish this (Entity Framework does it up the wazoo...it wreaks havoc with serializers). However, it seems very taboo in C++ to use circular references. So, I am wondering if the above is a legitimate use. Were I to do this, Blocks would be informed of their parent Model's destruction so that they know if they are orphans. Even if the above isn't, are the legitimate uses for circular references in C++ since they seem to be relatively common other languages (of course, that's assuming that those programs in those other languages using circular references don't have serious design issues)? If I didn't explain my question well enough just let me know and I'll try to clarify. EDIT: I should mention that the actual implementations are separate from all this since I am using interfaces (classes with all pure virtual functions) to define how a block looks or how a model looks. Here is a partial class diagram with my proposed changes: http://oi50.tinypic.com/16c8cwn.jpg Here is the source: https://github.com/kcuzner/Simulate/tree/develop. If you feel like building it, it depends on Qt >= 4.7, boost >= 1.52. The projects are Qt-Creator projects. Console and GUI depend on Engine.


title: Is Convention Over Configuration "Knowledge in the World" or "Knowledge In Your Head"?

text: In Don Norman's seminal work "The Design of Everyday Things", the author coined the phrases and explains the difference between "Knowledge in the World" and "Knowledge In Your Head"; an example of this is a multi-switch light panel that can either incorporate "Knowledge in the World" by being a model/map of the room, with the switches in the corresponding location, or "Knowledge In Your Head" (which is how they are almost always designed/implemented) when you have to memorize which switch toggles which light. You could think of "Knowledge in the World" as something you can deduce by using observation and logic, and "Knowledge in your Head" as something that has to be memorized. In the world of DI, and "Auto-Registration," which relies on the "Convention Over Configuration" pattern, would using this process be a case of the programmer using "Knowledge in the World" (the functionality is expected, as the framework provides it) or is it "Knowledge In Your Head" (the programmer has to be aware of and learn the convention). I am taking the wishy-washy/middle-of-the-road view that Convention Over Configuration is a midway world twixt the two. Am I wrong?


title: Marked nodes in Fibonacci heaps

text: I don't understand why Fibonacci heaps have marked nodes (picture). A node is marked when its child is deleted. Quoting from Wikipedia: "[Keeping degree of each node low] is achieved by the rule that we can cut at most one child of each non-root node. When a second child is cut, the node itself needs to be cut from its parent and becomes the root of a new tree." Why do we need to do that? Why not just leave the node where it is after the second child is cut? The heap structure is not violated. I don't see the point of this optimization.


title: Why are wrapper classes not suited for use in callback frameworks?

text: I just read the question what are callback frameworks?, where the asker cites the following from Effective Java: > The disadvantages of wrapper classes are few. One caveat is that wrapper > classes are not suited for use in callback frameworks, wherein objects pass > selfreferences to other objects for subsequent invocations (“callbacks”). So I am curious, why are wrapper classes not suited for use in callback frameworks? And can you provide an example of what the problem is?


title: What is a "cross-functional team" actually?

text: The general meaning of "cross-functional team" is a team which combines specialists in different fields that are required to reach the goal. But it looks like in Agile cross-functionality means not only combining different specialists, but making them mix. Henrik Kniberg defines cross- functional team this way: "Cross-functional just means that the team as a whole has all skills needed to build the product, and that each team member is willing to do more than just their own thing." But where is the line drawn? Is it normal to ask developers to become testers for an iteration if it is required?


title: Unobtrusive JavaScript (regarding asp.net mvc3) not clear

text: Unobtrusive JavaScript avoids injecting inline JavaScript into HTML. This makes your HTML smaller and less cluttered, and makes it easier to swap out or customize JavaScript libraries http://www.asp.net/mvc/mvc3#BM_JavaScript_and_Ajax_Improvements what really is it ?( i am really trying to go deeper in the above article) can some one explain in simpler words


title: Are there real world applications where the use of prefix versus postfix operators matters?

text: In college it is taught how you can do math problems which use the ++ or -- operators on some variable referenced in the equation such that the result of the equation would yield different results if you switched the operator from postfix to prefix or vice versa. **Are there any real world applications of using postfix or prefix operator where it makes a difference as to which you use?** It doesn't seem to me (maybe I just don't have enough experience yet in programming) that there really is much use to having the different operators if it only applies in math equations. EDIT: Suggestions so far include:   1. function calls //f(++x) != f(x++)   2. loop comparison //while (++i < MAX) != while (i++ < MAX)    3. operations on objects where ++ and -- have been overloaded


title: Does the use of Comparator interface breaks encapsulation in Java?

text: According to the essay "The Object Calisthenics" by Jeff Bay in the book ThoughtWorks Anthology, Use of Getters and Setters should be avoided as they break encapsulation and we should instead ask the object to do something for us instead of digging in to the object and getting its fields. how about comparison of objects ? I have to find best object say a Resort for the customer on the basis of a rule that uses few properties of the Resort object. This rule can change in future. So I find use of comparator interface better as compared to comparable interface. But then I will have to use getters and setters for to access individual properties to compare to objects in a different class.


title: How large is ok for a Class?

text: I’m a long time developer (I’m 49) but rather new to object oriented development. I’ve been reading about OO since Bertrand Meyer’s Eiffel, but have done really little OO programming. The point is every book on OO design starts with an example of a boat, car or whatever common object we use very often, and they start adding attributes and methods, and explaining how they model the state of the object and what can be done with it. So they usually go something like "the better the model the better it represents the object in the application and the better it all comes out". So far so good, but, on the other hand, I’ve found several authors that give recipes such as “a class should fit in just a single page” (I would add “on what monitor size?" now that we try not to print code!). Take for example a `PurchaseOrder` class, that has a finite state machine controlling its behavior and a collection of `PurchaseOrderItem`, one of the arguments here at work is that we should use a `PurchaseOrder` simple class, with some methods (little more than a data class), and have a `PurchaseOrderFSM` “expert class” that handles the finite state machine for the `PurchaseOrder`. I would say that falls in the “Feature Envy” or “Inappropriate Intimacy” classification of Jeff Atwood's Code Smells post on Coding Horror. I’d just call it common sense. If I can issue, approve or cancel my real purchase order, then the `PurchaseOrder` class should have `issuePO`, `approvePO` and `cancelPO` methods. Doesn’t that goes with the “maximize cohesion” and “minimize coupling” age old principles that I understand as cornerstones of OO? Besides, doesn’t that helps toward the maintainability of the class?


title: Code sharing with a newbie coder in our group?

text: I'm working on a group project for school, and it's just me and a teammate. Well he is really behind with coding skills, and I was wondering if I should still give him access(email a copy) to the source I've been working on solely. So far he hasn't done anything except a basic TUI. Is it advisable to gently tell him to "catch up" to the coding level first?


title: Dependency injection and ease of use

text: I'm writing a handy library (we'll call it Thinger) that goes off and fetches an XML document, does some X-Path query on it and does something helpful with the result of that. (What I'm actually doing is far too boring to bother you all with, this is just a simplified example.) Because I'm a wise and lazy programmer I'm making use of two third-party components, one for fetching remote XML documents (we'll call it Fetcher) and one for running X-Path queries (we'll call it Querier). My library provides a Thinger class, into which one must inject a Fetcher and a Querier. I could do this via setters or a constructor. But then I think about the poor people using my library, who now have to think about injecting my dependencies when all they really want to do is call something like               new Fetcher()->fetch(someurl);      So far, I have written a static factory which instantiates a new Thinger, Fetcher and Querier, assembles them as appropriate and returns the Thinger. That left me feeling slightly unclean. Surely there's a better way? EDIT Most frameworks etc would probably get around this using a Dependency Injection Container or similar, but since I'm writing a fairly small third party library that seems like a bad approach.


title: What is difference between publisher-subscriber and reactor patterns?

text: Publish-subscribe and Reactor patterns looking very similar to me. How they are different? In both patterns a message is getting passed to subscribers indirectly (listeners in reactor pattern). I feel observer pattern is very similar to two other patterns too. What are key differences between those patterns?


title: Scratch - why do schools teach students a language that is not used anywhere else?

text: Why do schools teach Scratch instead of more commonly used programming languages (C, C++, Java, C#, Python etc)?


title: Defining a status between last check and now

text: I have sets of probing data from an internal monitoring tool which represent the availability of different services (databases, webservices and so on). Now my task is to visualize this data and I reached a point where I should make a decision concerning the data interpretation for the most recent data set. **Quick overall definition** , each data set reflects the given status at the time when it was verified and the probing intervals vary from service to service, so there is no constant time window. Hence if there is an interval of e.g. five minutes between set A and B, for these five minutes (assuming with B there is a change) the status of A is always assumed. So far no problem, my question now however is what should be assumed for the time between **now** and the **most recent** data. I see two solutions   * Only visualize data up until the most recent check, and ignore the passed time since then or   * Assume the status from the most recent check is still valid up until now (like between two given data entries) I could see arguments for both and hope someone can point me in the right direction as to which approach would be the most logical one.


title: Do I need to test everything?

text: I'm going to start my first real project in Ruby on Rails, and I'm forcing myself to write TDD tests. I don't see real advantages in writing tests, but since it seems very important, I'll try. Is it necessary to test **_every_** part of my application, including static pages?


title: How to design a task scheduler (like cron) with a Calendar Queue

text: I've been working on a dynamic task scheduler based on a Calendar Queue structure and I've hit a bit of a wall. The Calendar Queue lets me enqueue and dequeue events, however I think I might not be understanding the pseudo code correctly, but it can't seem to find any pseudo code referencing the application loop and how the application waits for the correct time before executing the task. Heres a naiive solution for what I'm talking about: Let calQueue be a CalendarQueue populated with events.               while(1){         time = DateTime.now         nextTask = calQueue.dequeue()         if(time!= nextTask.time){             sleep(nextTask.time-time);             executeTask(nextTask)         }     }      Obviously this has many problems:   1. many events may occur at the same exact time   2. the executeTask method may take a significant amount of time to execute, which means events might be missed.   3. I'm using a database backed CalendarQueue, and so the dequeue method may take a not insignificant time to complete.    4. This also ignores tasks that were added to the calQueue that must execute before the next task, ie the task was added while it was sleeping, for immediate execution.  Other considerations:   1. I would like to eventually make this a distributed (clustered) scheduler.   2. I've looked at cron and fcron but honestly they are both pretty large applications, and somewhat difficult to trace.  Basically what I'm looking for is how I could design a CalendarQueue scheduler.


title: Main method templating

text: Now that I've gotten into a dependency injection groove, I find main methods for different applications all look basically the same. This is similar to stuff you might find on the Guice documentation, but I'll put an example here:               public class MyApp {         public static void main(String... args) {             Injector inj = Guice.createInjector(new SomeModule(),                            new DatabaseModule()                            new ThirdModule());             DatabaseService ds = inj.getInstance(DatabaseService.class);             ds.start();                  SomeService ss = inj.getInstance(SomeService.class);             ss.start();                  // etc.         }     }      For multiple applications I have main methods that all look just like that. But now, lets say I want to make a brand new app, that, say, reuses my `DatabaseModule`. I pretty much have to copy and paste the `main` method and make appropriate changes... I view copy-paste as a code smell. Further, lets say I realize I should probably be putting shutdown hooks in, now I have to go through and change every main method in all my applications to attach shutdown hooks to each service. Is there some good way to template this process and minimize the boilerplate?


title: In DVCS with production and development branches, whats the master/default branch?

text: If your following the standard DVCS methodology of having a production branch and a development branch, I'm really interested in what do you do with the default (mercurial) or master (git) branch?   * Do you delete it (not recommended by several guides)?    * Do you use it as production?    * Do you use it as development?    * Or do you leave it empty and have separate dev and production branches? Note: I'm really interested in Mercurial specifically, but any other DVCS or just general rules would be ok


title: Why isn't `length` generic by default?

text: Haskell often provides two versions of a given function f, i.e:               f :: Int ...     genericF :: Integral i => i ...      There exist many standard library functions with those two versions: length, take, drop, etc. Quoting the description of `genericLength`: > The genericLength function is an overloaded version of length. In > particular, instead of returning an Int, it returns any type which is an > instance of Num. It is, however, less efficient than length. My question is: where does the efficiency loss comes from? Can't the compiler detect that we are using `genericLength` as an Int and therefore us `length` for better performance? Why isn't `length` generic by default?


title: a lot of small objects - OO pasta

text: In the code I am working on, there are a lot of really small objects like:                   class HasFieldLameSetter         {          public:             HasFieldLameSetter(field& p_):m(_p){}             void set(bool p2)             {                 m.hasLame = p2;             }               field& m;         };      Having lots of small classes creates a hard-to-read and complicated "code pasta". Sometimes, reading it is really really hard because I spend a lot of time jumping from file to file to find out that the class did something trivial like in the example setting bool to true. In addition, those objects are being passed around everywhere by "dependency injection" which makes reading it even more difficult. **How do I persuade the author of the code to write slightly bigger objects?** In my opinion too many small objects is just a nightmare for programmers. Am I missing something, or is there a mistake in my thinking? I would be happy to read any papers that might change my point of view.


title: When Rob Pike says "Go is about composition", what exactly does he mean?

text: From Less is Exponentially More > If C++ and Java are about type hierarchies and the taxonomy of types, Go is > about composition.


title: Understanding open and listening ports

text: I developed an app in Java (which is working perfectly; with this app you can scan TCP/UDP ports -for testing purposes only-), but meanwhile when I was writing the code I read several documentation (wiki) about sockets. I thought open port is mean, a protocol where the client/server can establish/bind a connection even if there are nothing on the server side which can handle/response data. I thought open port is mean (if there are no routers/firewalls) a protocol which is ready to be used. I was testing my application on my local server machine, but at first I thought my application is not working. It was working, but there was no any software which could response to my queries. After I opened my APACHE server and I wrote a simple UDP server (which can handle/response to any query on a specific port) the application was able to find those ports. I thought listening port is a port which is used and it's opened. What does listening port is meaning? If I send UDP packets to a remote host and there are no closed ports (router or firewall) what happens to the packet? Does the data is written in the buffer? Or it simply ignores/denies the packet.


title: Is it better to create a stored procedure or entities to get to the data I need?

text: I just jumped into a new project with a new company using Entity Framework and ASP.NET MVC 4. I am no expert on Entity Framework, but I think I have a decent grasp of how to use it. From what I can tell, my models should reflect a table in the database omitting the columns I don't need. Also, we can use stored procedures with Entity Framework, or an IoC to map the model. I need to connect the relationship with two objects, whose relationship is pretty nested. I could create a stored procedure to do this or create a bunch of models (based on the tables in the database) and use an IoC configuration to have a table from the database for each model, then query the models in the repository layer for the data I need using Linq to Entities. Seems like I would have a lot of ".Include(x=>x.SomeModel)" My question is: which option is better for maintenance and integration in the future of the project? A stored procedure or Linq to entities? Or am I not understanding Entity Framework properly?


title: How to connect several (mobile) devices

text: I want to start a little project, where I want to connect several of my devices. Some are Android mobile devices, others are desktop devices like a PC or laptop. Furthermore I want keep the project as generic as possible. Means I want to share it, so other people can use it. By connecting I mean send messages between them. My problem is, that I'am not sure what technology or architecture to use, and hope to get some advice from you. (I think this question is more about software architecture then gorilla vs. shark) I have considered several approaches already. I looked at Google's Cloud Messaging, but that seems not to fit my requirements, where several users can register to send independent messages. It looks more like, sending from one master to several devices. The next thing I thought about was something lile VLC did with its Android remote app, where the desktop application hosts something like a server to which the mobile app must connect. This seems to be limited to LAN and only fits to about 80% of my use cases. Is there another approach which does not require something like a server who is aware of all clients, which has to seperate the user's devices and route the messages?


title: What should I understand before I try to understand functional programming?

text: I've been Learning `Me A Haskell For Great Good` because I thought it looked interesting. Of course, I'm completely sold on the idea that functional programming will end world hunger, bring about world peace, send crows to peck out the eyes of my enemies, bring many young women with good birthing hips to my beck and call, double my order for free, and just generally improve my life in every way, shape, and form with zero drawbacks whatsoever. I am pretty well-versed in imperative paradigms. I learned Java and C++ before I dropped out of university, after which I taught myself Python. My problem is that even beginner tutorials get way far over my head pretty quickly and I'm not sure if there's something specific I'm missing or not understanding or if I just can't quite wrap my head around the whole paradigm just yet. I made it all the way to Section 4.7 of the Haskell Tutorial for C Programmers before I couldn't understand it anymore. Am I missing something foundational (like those last two years of university)? Or should I just keep going slowly and hopefully it will click? Put another way, what information would help me best bridge the gap between an imperative paradigm and a functional paradigm?


title: a better approach for reviewing performance of developers?

text: I am a web developer. My office sets a list of criteria such as   * Discipline   * Attendance   * Project Schedule   * Teamwork   * Problem Solving   * Idea Sharing   * Dedication for evaluating employees performance. Each criteria is allocated some points and the review is based on the total points scored in each criteria. My problem is I feel these criteria are quite vague and I don't think they can actually portray an employees performance. In software development, I think there are other other ways to measure an employees performance. Any suggestions? Thanks


title: Product backlog acceptance criteria

text: I read on a similar forum http://stackoverflow.com/questions/8117530/examples- for-acceptance-criteria-for-a-user-story about putting in the acceptance criteria for product backlog item. I am working on a Scrum based project and I need more info as my backlog item is as follows - UserProfiles ( I am using this in the title field in tfs 2013) and the description contains all the "As a user I want to be able to create new users and assign permissions' The acceptance criteria talks about how the user interacts with the UI (as discussed in one of the answers in the above link - which is very logical) For example   * As the user clicks on the home button, system will bring up 3 options   * And then the user can enter their user name  Is this the right approach I am using to use title for PBI and put the actual user story in description field in tfs Thanks in advance


title: Extensibility data model pattern

text: I was wondering how you'd be able to map the following criterias to common design patterns. I use PHP 5.3 and MySQL 5.5 and have my own mvc framework for my company but some parts could be better and here are the requirements: (Take the concept of a catalog since it's the first app that would be affected in our application pool) The controllers (products, clients and basket) all manage different information namely their own set of models. For example, the basket will create basket objects in memory, assign products to it, quantities, etc. Then it will save the basket to database and try the payment logic and save the payment associated to the basket. My issue is that most of the time, our clients want to customize the different objects such as the client (add more coordinate fields or descriptive fields) or the product (add custom properties to the product). If my controller always refers to the class product but i want to extend it to create:               MyCompany_Models_Product     MyClient_Models_Product extends MyCompany_Models_Product      How will i setup my system to support extension of classes and change the classes used by my different modules, controllers, views and other models. If i hardcode MyCompany_Models_Product as the class name in the controller and all other object, how would i go at creating an overridable system. Is there any pattern i can go for that will leverage this problem?


title: Execute a Managed bean from a JSF view in WEB-INF folder

text: We are initiating a Spring + Primefaces project and the first problem we have encountered concerns storing the XHTML pages into the WEB-INF folder. When we use a faces form in a view located inside the WEB-INF folder, then the `commandButton` does not execute the managed bean method.                <h:form id="loginForm">         <p:commandButton action="#{LoginMgr.doLogin()}" value="Login"/>      </h:form>      Our bean:               <bean id="LoginMgr" name="LoginMgr" class="com.tesipro.channelmanager.business.implemented.CMLoginManager">     </bean>      In fact we think the problem is that with JSF, the pages are rendered using a link to the same page as the action of the form, so if the page is located in WEB-INF it is not publicly accessible. We know that having all our XHTML views in the web folder instead of WEB-INF actually solves the issue, but we would like to store that pages into WEB-INF.


title: Does Exception Handling Violates "Program to Abstraction"?

text: I am talking based on experience with Java and C#. I do not know if other language have different exception handling implementation. In order to achieve loose coupling, we need our code being programmed to use abstraction rather than implementation. However the exception handling case is the opposite. The best practice is you need to handle specific exception type (`SqlException`, `StackOverflowException`, etc). This thing may be better (or not) in java thanks for it's `Checked Exception`, there is a kind of "contract" between the interface and the consumer. But in C# or for the `Unchecked Exception` there is no contract about what exception can be thrown by the interface. For example, say that we use `Repository Pattern` to decouple the DAL with BLL. The simple catch exception usually be used like:               public void Consume()     {         try{             productRepository.Get(k=>k.Id == "0001");         }         catch(Exception e){             // handle         }     }      In more specific case we usually use `SqlException`. However it means that we must know that the `ProductRepository` is a repository to database server. What if the implementation changed to use file repository instead? Now you need to catch `FileNotFoundException` or something like that. Why does it violates the "code to abstraction" principle? And what can we do to prevent it?


title: Try and catch error trapping, why is it so significant?

text: I try to understand why should I "try" a method to catch errors. It looks to me like the concept is: "letting a process run assuming its not properly developed". Should I always assume that a program based on classes and inheritance is bound for unexpected errors, which I should handle with tools like try catch and throw? Should all Java programs be included within try catch framework?


title: What is the advantage of wrapping exceptions

text: It's very common in .NET for an exception to be wrapped in several layers of "outer exceptions" which give marginally more contextual data. For example, in EF if your update fails, you get exceptions wrapped similar to this:   * `EntityException`   * `DbUpdateException`   * `SqlException` The data I need to understand what failed is almost always in the `SqlException`, so what's the advantage to the other two? What if I was using EF inside a custom library, should I wrap this exception with one of my own? Like `MyCustomLibraryException: Could not update the data. See inner exception for details.`


title: Are exceptions as control flow considered a serious antipattern? If so, Why?

text: Back in the late 90's I worked quite a bit with a code base that used exceptions as flow control. It implemented a finite state machine to drive telephony applications. Lately I am reminded of those days because I've been doing MVC web apps. They both have `Controller`s that decide where to go next and supply the data to that destination logic. User actions from the domain of an old-school telephone, like DTMF tones, became parameters to action methods, but instead of returning something like a `ViewResult`, they threw a `StateTransitionException`. I think the main difference was that action methods were `void` functions. I don't remember all the things I did with this fact but I've been hesitant to even go down the road of remembering because since that job, like 15 years ago, _I never saw this in production code at any other job_. I assumed this was a sign that it was a so-called anti-pattern. Is this the case, and if why? Update: when I asked the question, I already had @MasonWheeler's answer in mind so I went with the answer that added to my knowledge the most.. I think his is a sound answer as well.


title: Try/Catch or test parameters

text: > **Possible Duplicate:**   >  Arguments for or against using Try/Catch as logical operators   >  Efficient try / catch block usage? I was recently on a job interview and I was given a task to write simple method in C# to calculate when the trains meet. The code was simple mathematical equation. What I did was that I checked all the parameters on the beginning of the method to make sure, that the code will not fail. My question is: Is it better to check the parameters, or use try/catch? Here are my thoughts:   * Try/catch is shorter    * Try/catch will work always even if you forget about some condition   * Catch is slow in .NET    * Testing parameters is probably cleaner code (Exceptions should be exceptional)   * Testing parameters gives you more control over return values I would prefer testing parameters in methods longer than +/- 10 lines, but what do you think about using try/catch in simple methods just like this – i.e. `return (a*b)/(c+d);` There are many similar questions on stackexchnage, but I am interested in this particular scenario.


title: Efficient try / catch block usage?

text: Should catch blocks be used for writing logic i.e. handle flow control etc? Or just for throwing exceptions? Does it effect efficiency or maintainability of code? What are the side effects (if there are any) of writing logic in catch block? **EDIT:** I have seen a Java SDK class in which they have written logic inside the catch block. For example (snippet taken from `java.lang.Integer` class):                       try {                 result = Integer.valueOf(nm.substring(index), radix);                 result = negative ? new Integer(-result.intValue()) : result;             } catch (NumberFormatException e) {                 String constant = negative ? new String("-" + nm.substring(index))                                            : nm.substring(index);                 result = Integer.valueOf(constant, radix);             }      **EDIT2** : I was going through a tutorial where they count it as an advantage of writing logic of exceptional cases inside the exceptions: > Exceptions enable you to write the main flow of your code and to deal with > the exceptional cases elsewhere. **Any specific guidelines when to write logic in catch block and when not to?**


title: What to put in a try/catch?

text: **Note on the question: this is not a duplicate,Efficient try / catch block usage? was asked after this one. The other question is the duplicate.** I was wondering what was the best way to use try/catch. Is it better to limit the content of the try block to the minimum or to put everything in it? Let me explain myself with an example: Code 1:               try {       thisThrowsAnException();     }     catch (Exception e) {       e.printStackTrace();     }     thisDoesnt();      Code 2:               try {       thisThrowsAnException();       thisDoesnt();     }     catch (Exception e) {       e.printStackTrace();     }      Assuming that `thisThrowsAnException()`... well... can throw an exception and `thisDoesnt()`... I'm sure you got it. I know the difference between the two examples: in case the exception is caught, `thisDoesnt()` will be called in the first case, not in the second. As it doesn't matter for me, because the throwing of that exception would mean the application should stop, why would one use a version better than the other?


title: Is ok to throw exception in normal code path which eliminate a possible programmer error?

text: I know that exception should be thrown in exceptional case (e.g. out of memory, programmer error). For these cases, I don't need to worry about performance throwing these exception. But what happen if use exception in normal code path? In my case, use it to stop user code supplied function. So for given code, is `foo` better or `foo2` better? It is very likely that `outputFunc` will return false / throw exception.               // library provided function     void foo(std::function<void(std::function<bool(int)>)>);          // how user suppose to use it     foo([](std::function<bool(int)> outputFunc){         while (/*condition*/)         {             // user have to check the return value and stop work when it return false             if (!outputFunc(/*some value*/)) return;          }     });          // library provided function     void foo2(std::function<void(std::function<void(int)>)>);          // how user suppose to use it     foo2([](std::function<void(int)> outputFunc){         while (/*condition*/)         {            // this will throw exception and handled internally when it should stop            // user does not have to check the return value but they need to write exception-safe code             outputFunc(/*some value*/));         }     });      * * * In my case, the use of exception eliminate a possible programmer error (by not checking return value of `outputFunc`) and make code easier to write (no need to check return value) And the exception is throw/catch internally, no user code required to deal with them (except they need to write exception-safe code in the lambda, but we should always write exception-safe code)


title: Is rethrowing an exception leaking an abstraction?

text: I have an interface method that states in documentation it will throw a specific type of exception. An implementation of that method uses something that throws an exception. The internal exception is caught and the exception declared by the interface contract is thrown. Here's a little code example to better explain. It is written in PHP but is pretty simple to follow.               // in the interface          /**      * @return This method returns a doohickey to use when you need to foo      * @throws DoohickeyDisasterException      */     public function getThatDoohickey();          // in the implementation          public function getThatDoohickey() {              try {             $SomethingInTheClass->doSomethingThatThrowsAnException();         } catch (Exception $Exc) {             throw new DoohickeyDisasterException('Message about doohickey failure');         }              // other code may return the doohickey          }      I'm using this method in an attempt to prevent the abstraction from leaking. My questions are: Would passing the thrown internal exception as the previous exception be leaking the abstraction? If not, would it be suitable to simply reuse the previous exception's message? If it would be leaking the abstraction could you provide some guidance on why you think it does? Just to clarify, my question would involve changing to the following line of code               throw new DoohickeyDisasterException($Exc->getMessage(), null, $Exc);


title: Arguments for or against using Try/Catch as logical operators

text: I just discovered some lovely code in our companies app that uses Try-Catch blocks as logical operators.   Meaning, "do some code, if that throws this error, do this code, but if that throws this error do this 3rd thing instead".   It uses "Finally" as the "else" statement it appears.   I know that this is wrong inherently, but before I go picking a fight I was hoping for some well thought out arguments.   And hey, if you have arguments FOR the use of Try-Catch in this manner, please do tell. For any who are wondering, the language is C# and the code in question is about 30+ lines and is looking for specific exceptions, it is not handling ALL exceptions.


title: Partial recovery from an Exception

text: I have seen _Exception Handling_ blocks that they were `throw`ing the recently caught `Exception` in the `catch` block. Something like:               } catch ( Exception $e ) {         // Do some recovery here         callSomeFunction();              throw $e;     }      To me it doesn't make that much sense to `throw` the exact same `Exception` like this, but I'm not sure if I'm right or not. Maybe there are situations that that's the only option? My question is what are the pros and cons of this approach and shouldn't it be totally avoided as much as possible?


title: Starting point for building an iPhone app

text: I have one idea that I want to make an app for iPhone, I have recently bought a mac for the same purpose. I want to make small app and build on it in later versions. I work in in a small company and have 1 year of experience on working of iOS platform . I am a developer and don't have any design background so I want to know - should I take help from some designer? Or learn on my own and start coding for the app? I would like to know before starting out, what things should I consider or give more importance to. In general how should I approach building the app, design first and code later or reverse way.


title: how to evaluate own project

text: I am working on a open source project in pure `C`, that I have started some time ago, but only recently found time to add some features. I can clearly some weaknesses of my old design, so I am trying to refactor my old code. I have no idea however, how to evaluate properly my new code. Do you know about any techniques or tools for code evaluation? I am pretty good with object oriented design, but for about three years I had no contact with purely structural one. Therefore I don't have enough experience, to be able to discern between good and bad design choices.


title: Is it worth it for a developer to be a scrum master? Is it an official designation or?

text: Is it beneficial for a developer to become a 'scrum master'? Is this an official certification or just someone who specializes? What are the steps towards becoming one?


title: Are long methods always bad?

text: So looking around earlier I noticed some comments about long methods being bad practice. I am not sure I always agree that long methods are bad (and would like opinions from others). For example I have some Django views that do a bit of processing of the objects before sending them to the view, a long method being 350 lines of code. I have my code written so that it deals with the paramaters - sorting / filtering the queryset, then bit by bit does some processing on the objects my query has returned. So the processing is mainly conditional aggregation, that has complex enough rules it can't easily be done in the database, so I have some variables declared outside the main loop then get altered during the loop.               variable_1 = 0     variable_2 = 0     for object in queryset :          if object.condition_condition_a and variable_2 > 0 :          variable 1+= 1          .....          ...              .            more conditions to alter the variables          return queryset, and context       So according to the theory I should factor out all the code into smaller methods, so That I have the view method as being maximum one page long. However having worked on various code bases in the past, I sometimes find it makes the code less readable, when you need to constantly jump from one method to the next figuring out all the parts of it, while keeping the outermost method in your head. I find that having a long method that is well formatted, you can see the logic more easily, as it isn't getting hidden away in inner methods. I could factor out the code into smaller methods, but often there is is an inner loop being used for two or three things, so it would result in more complex code, or methods that don't do one thing but two or three (alternatively I could repeat inner loops for each task, but then there will be a performance hit). So is there a case that long methods are not always bad? Is there always a case for writing methods, when they will only be used in one place? UPDATE: Looks like I asked this question a over a year ago. So I refactored the code after the (mixed) response here, split it into methods. It is a Django app retrieving complex sets of related objects from the database, so the testing argument is out (it would have probably taken most of the year to create relevant objects for the test cases . I have a "this needs done yesterday" type work environment before anyone complains). Fixing bugs in that part of the code is marginally easier now, but not massively so. before :               #comment 1      bit of (uncomplicated) code 1a       bit of code 2a          #comment 2      bit of code 2a     bit of code 2b     bit of code 2c          #comment 3     bit of code 3      now:               method_call_1     method_call_2     method_call_3          def method_1          bit of (uncomplicated) code 1a           bit of code 2a          def method_2          bit of code 2a         bit of code 2b         bit of code 2c          def method_3         bit of code 3


title: collection naming - singular or plural

text: This is related to this question but not quite the same. BTW, I'm not a native English speaker. I keep having a hard time choosing a proper name for collections - Lets say that we have a collection of _item_ s and that each _item_ has a _name_. How will we call the collection of names such that the collection's name will be the most understandable under standard naming conventions?               var itemNames = GetItemNames(); // Might be interpreted as a single item with many names     var itemsNames = GetItemsNames(); // No ambiguity but doesn't look like proper English     var itemsName = GetItemsName(); // Also sounds strange, and doesn't seem to fit in e.g. a loop:     foreach( itemName in itemsName){...}      As native English speakers, how would you name your collections, and how would you expect them to be named?


title: Pair Rotation in a team for effective pair programming

text: We follow pair programming in our company and always face the issue of balanced and effective pair rotation within the developers on stories. We follow a simple metrics in which every developer's name is mapped with every other developer and we mark the respective intersection whenever two developers are pairing. This is not working out well, we cannot track how much time a pair has spent pairing and people forget to update the metrics many times. Tracking the pair rotation is helpful because we want the project knowledge to be shared across the team, and not just one pair. So usually what happens is, whoever is pairing keeps pairing till the entire story is completed (given they have better context), and no body else knows about what is being done & if the story or a regression/production bug comes back, the same pair has to pick it up (leaving whatever they are currently doing), which is what creates a bottleneck. Are there any known metrics that can be used for tracking the pair rotations.


title: Is C# development effectively inseparable from the IDE you use?

text: I'm a Python programmer learning C# who is trying to stop worrying and just love C# for what it is, rather than constantly comparing it back to Python. I'm caught up on one point: the lack of explicitness about where things are defined, as detailed in this Stack Overflow question. In short: in C#, `using foo` doesn't tell you what names from `foo` are being made available, which is analogous to `from foo import *` in Python -- a form that is discouraged within Python coding culture for being implicit rather than the more explicit approach of `from foo import bar`. I was rather struck by the Stack Overflow answers to this point from C# programmers, which was that in practice this lack of explicitness doesn't really matter because in your IDE (presumably Visual Studio) you can just hover over a name and be told by the system where the name is coming from. E.g.: > Now, in theory I realise this means when you're looking with a text editor, > you can't tell where the types come from in C#... but in practice, I don't > find that to be a problem. How often are you actually looking at code and > can't use Visual Studio? This is revelatory to me. Many Python programmers prefer a text editor approach to coding, using something like Sublime Text 2 or vim, where it's all about the code, plus command line tools and direct access and manipulation of folders and files. The idea of being dependent on an IDE to understand code at such a basic level seems anathema. It seems C# culture is radically different on this point. And I wonder if I just need to accept and embrace that as part of my learning of C#. Which leads me to my question here: is C# development effectively inseparable from the IDE you use?


title: Single Responsibility Principle - How Can I Avoid Code Fragmentation?

text: I'm working on a team where the team leader is a virulent advocate of SOLID development principles. However, he lacks a lot of experience in getting complex software out of the door. We have a situation where he has applied SRP to what was already quite a complex code base, which has now become very highly fragmented and difficult to understand and debug. We now have a problem not only with code fragmentation, but also encapsulation, as methods within a class that may have been private or protected have been judged to represent a 'reason to change' and have been extracted to public or internal classes and interfaces which is not in keeping with the encapsulation goals of the application. We have some class constructors which take over 20 interface parameters, so our IoC registration and resolution is becoming a monster in its own right. I want to know if there is any 'refactor away from SRP' approach we could use to help fix some of these issues. I have read that it doesn't violate SOLID if I create a number of empty coarser-grained classes that 'wrap' a number of closely related classes to provide a single-point of access to the sum of their functionality (i.e. mimicking a less overly SRP'd class implementation). Apart from that, I cannot think of a solution which will allow us to pragmatically continue with our development efforts, while keeping everyone happy. Any suggestions ?


title: How to determine if class meets single responsibility principle?

text: Single Responsibility Principle is based on high cohesion principle. The difference between the two is that highly cohesive classes feature a set of responsibilities that are strongly related, while classes adhering to SRP have just one responsibility. But how do we determine whether particular class features a set of responsibilities and is thus just highly cohesive, or whether it has only one responsibility and is thus adhering to SRP? Namely, isn't it more or less subjective, since some may find class very granular (and as such will consider a class as adhering to SRP), while others may find it not granular enough?


title: Lots of classes with only one single static method with same name as class - Code smell?

text: I'm trying to follow the single responsibility principle (SRP) in my applications. I have lots of CRUD classes I just name xxxxxManager. Following the SRP, I made 4 classes for each one : xxxxxCreator, xxxxxGetter, xxxxxDeleter, xxxxxUpdater They end up having only one static method : xxxxxCreator::create(Model $model), xxxxUpdater::update(Model $model), etc. This is a code smell for me. Am I pushing the SRP too far ?


title: Parallel.For Inconsistency results

text: I am using VB.net to write a parallel based code. I use _Parallel.For_ to generate pairs of 500 objects or in combination C(500,2) such as the following code; but I found that it didn't always generate all combinations which should be 124750 (shown from variable Counter). No other thread was runing when this code was run. I am using a Win-7 32 Bit desktop with Intel Core i5 CPU 650@3.2GHz, 3.33 GHz and RAM 2GB. What's wrong with the code and how to solve this problem? Thank You.                   Dim Counter As Integer = 0         Parallel.For(0, 499, Sub(i)                          For j As Integer = i + 1 To 499                              Counter += 1                              Console.Write(i & ":" & j)                          Next                      End Sub)         Console.Writeline("Iteration number: " & Counter)


title: Quoting for a project with closed source

text: I sit with a project that I need to quote, and until the job is awarded, I can only use "View source" to check, and ask a few questions about the system. That makes quoting outright impossible for me to do. My question is: how do one go about quoting for such a project? What kind of questions should I ask? Do I decline to quote? Due to uncertainty, do I pad my quote?


title: Should I include myself as an author after modifying 3rd-party code?

text: It's common practice to make some tweaks or fixes in 3rd-party code (be it a simple gist or an entire library). But it's also common that many of these code have they own licensing rules and eventually a header on every file with copyright informations. After making those modifications what's the correct thing to do next? Keep the licence info untouchable or try to update it including yourself with something like `@author` or `@revision` tags? Another common problem is changing the 3rd-party namespace/package to fit it to your project conventions. Some license types include these kind of information in their license block, can I change it freely? I know the answer for these questions depends on each license type, so to make my question more specific... Considering general license rules (usually they are different in minor aspects, right?), is ethical(or at least allowed) that I freely **add information** to the license block about my modifications and perhaps also **modify how do I refer** to it in my code (e.g use `YACorp.YALib` as `Utils.YALib`)? Actualy my concerns are more about "respect to the community" than the legal aspects, I'm asking more about how much we can "go wild" remaining ethical if our project can be considered private or personal.


title: Moving data between databases with XML

text: I just read this quote online: > XML is a very useful technology for moving data between different databases > or between databases and other programs. However, it is not itself a > database. Which is quoted from the book 'Effective XML: 50 Specific Ways to Improve Your XML'. I don't understand what you would bother moving data between databases in an XML format. Databases usually contain a lot of data, so wouldn't it be verbose to transform it into an XML format? Is there no way, to just serialize the database data into something less verbose, somehow, instead of bothering with conversions?


title: J2EE - Session swap

text: Application server - JBoss AS 7.1.1   JDK6   J2EE 1.3 My web application is more than 10 years old and facing this session swap problem in my portal. Noticed that swap happens mostly when many concurrent users accessing the portal and underlying windows server is busy (more than 90% CPU usage) To analyse this issue, I logged customer data (customer id, ip address, jsession id) to a table and found that customer having unique jsession id initially has his data and all of a sudden for the same jsession id and ip address receiving different customer data.               customer1  123.123.12.123   jsessionid123    11:10:02     customer2  123.123.12.123   jsessionid123    11:10:04      ip address (123.123.12.123) having jsession id (jsessionid123) somehow gets customer2 data Any order placed by customer1 in ip - 123.123.12.123 gets created for customer2, I confirmed this by calling customer2 and they confirmed that they didn't place the order. customer1 won't realise he placed order for customer2 - all the data gets changed, like basket items, customer object, products etc. Now I need to find a fix for this, but first I need to know which part of my code is creating this problem. Do I have to use a stress test software? or any better mechanism to find out the problematic code?


title: How is the Linux repository administrated?

text: I am amazed by the Linux project and I would like to learn how they administrate the code, given the huge number of developers. I found the Linux repository on GitHub, but I do not understand how it is administrated. For example the following commit: https://github.com/torvalds/linux/commit/31fd84b95eb211d5db460a1dda85e004800a7b52 Notice the following part: ![enter image description here](http://i.stack.imgur.com/dayjp.png) So one authored and Torvalds committed. How is this possible. I thought that it was only possible to have either pull or pushing rights, but here it seems like there is an approval stage. I should mention that the specific problem I am trying to solve is that we use pull requests to our repo. The problem we are facing is that while a pull request is waiting to get merged, it is often broken by a commit. This leads to a seemingly never ending work to adapt the fork in order to make the pull request merge smoothly. Do Linux solve this by giving lots of people pushing rights (at least there are currently just three pull requests but hundreds of commits per day).


title: How should I evaluate a training class?

text: My company is giving us the possibility to sign up for some offsite training classes on Design Patterns. Browsing through the brochures, I'm _already_ feeling bored (and somewhat repelled by the marketingy buzzwordy silverbulletty enterprisey managerese) - I already know the basics about design patterns (read the GoF book years ago, used a few as needed, read articles on the net, etc.). I'm worried that the training is going be mostly watching a powerpoint with stuff I mostly know, and arguing details over a UML diagram. My programming experience is mostly in games, simple web development and mathy stuff, in Python, C++ or simple scripting languages; I never worked on anything "enterprisey", or in Java or .Net (for some reason, Java and .Net seems especially associated with Design Patterns), nor am I planning to in the forseeable future. I'm much more interesting in things like functional programming and Haskell and making micro domain-specific-languages to solve specific problems - I'm closer to the "hacker" culture (I'm mostly self- taught) than to the "enterprise" culture. But maybe this is just me having too high of an opinion of myself and passing a good opportunity to learn useful stuff. Or being a snob and refusing to learn about different cultures. So, how could I tell if a Design Patterns class is going to be useful? How you found such trainings useful? How you ever felt apprehensive about them?


title: How to draw a (UML) class diagram when the classes are dispersed across a distributed system?

text: Basically how to denote that class foo is from a different server than class bar ?


title: Is it wise to include something like OpenSSL or GnuTLS with a project in a repository?

text: I am currently working on a project that makes use of the OpenSSL library for secure communications. Since this library is a requirement for building the project, I am considering including it in the project's repository. Here are the pros and cons as I see them: **Pros:**   * Self-contained build - with one exception, everything needed for building the project is contained in the repository. It would be nice if the user didn't need to go through the trouble of installing and configuring the development headers / libraries for OpenSSL. **Cons:**   * Security concerns - it goes without saying that the only version of OpenSSL that anyone should be using is always the latest. As soon as a new release is issued, I will need to update the version of OpenSSL in the project's repository. So the question boils down to this: > Is it wise to include a security library with the project that we need to > _always_ ensure gets updated whenever a new release is issued?


title: Is it a good idea to use something like the Twitter Bootstrap in production?

text: I'm interning at a new startup, and I've been tasked with designing the front- end of the site. I really, really want to use the new Twitter Bootstrap (http://twitter.github.com/bootstrap/). It's all CSS, looks amazing, works great, and lets me get to designing and not worrying about the little stuff. However, is this a good idea if it's a demo of a webapp that we're building that could become production code? Will it look silly and amateur if I use this instead of coding it all myself? Is the bootstrap too Twitter-ish for a real company's brand?


title: Communication Between Different Technologies in a Distributed Application

text: I had to a incorporate several legacy applications and services in a network- distributed application. The existing services and applications are written using different languages and technologies, including: java, C#.Net and C++; all running on MS Windows machines. Now I'm wondering about the communication mechanism between them. What is the simple and standard way? Thanks! PS. communications include simple message sending and remote method invocations.


title: What's the best way to retrieve a value and a status

text: Given that all else is equal, and there are no coding standards defining the best approach, what would be the recommended way in C++ to check that a value exists and return it if it does? For example, something like one of these declarations:               bool getMethod(double& ret);          double getMethod(bool& ok);          void getMethod(bool& ok, double& ret);          pair<bool, double> getMethod();          bool checkMethod(); // eg if (checkMethod())     double getMethod(); //        result = getMethod();      or something else, like return a struct The value may exist about 50% of the time. The existing code already does a lot of the last method, i.e. using a checkMethod() but I was wondering if that's really an efficient way to do it - via two calls (half the time).


title: Question on Graph

text: I am trying to implement a graph data structure in C#. I have the following interfaces:               public interface IVertex<TValue>     {         TValue  Value { get;}                 VertexList<IVertex<TValue>> Neighbours { get;}         int InDegree { get;}         int OutDegree { get;}     }          public interface IWeightedEdge<TValue, TWeight>      {         IVertex<TValue> source { get;}         IVertex<TValue> destination { get;}         TWeight weight { get; }     }      public interface IWeightedGraph<TVertexValue, TEdgeWeight>      {         bool AddVertex(TVertexValue value);         TVertexValue RemoveVertex(IVertex<TVertexValue> vertex);         bool RemoveVertex(TVertexValue value);         bool AddEdge(IVertex<TVertexValue> source, IVertex<TVertexValue> dest, TEdgeWeight weight);         bool RemoveEdge(IVertex<TVertexValue> source, IVertex<TVertexValue> dest);     }      From this, you can see that it is the responsibility of the Vertex class (the class implementing IVertex interface) to tell about its adjacent vertices (Neighbors function), its in degree, out degree etc. While I was designing this, I was told by a friend of mine that the Graph class (the one that will implement IGraph) should take the responsibility of operations like retrieving adjacent vertices ,finding the in/out degrees etc. His point is that the above operations are valid only when a vertex becomes part of a Graph. But my point is that a Vertex is standalone; it can exist even outside of a graph. So, the vertex should provide the operations on it. Which one you think is correct? Please share your thoughts on this.


title: Whether to open-source gigantic idea

text: So, I have this idea for a huge game that would take years to develop if I did it on my own (with help from friends) I've learned a lot about game programming, but nowhere near enough to start coding the thing itself. It would still take at least two years if I started a business and hired programmers How much will open-sourcing it speed up the project? Should I open-source it, given that I have no code to show for my learning in this kind of programming? Can an open-source project be directed to keep the original idea alive, or will it often veer away from the creator's original idea? Can an open-source project receive any kind of reliable funding (can we have investors, for example)? Should I make a business and hire programmers to get it moving, and then open- source it? If that ends up being the case, I'd like to send the full specification to anyone who wants to see it.


title: How do we differentiate between a computer and a calculator?

text: In this SO Question there is a comment by `starblue` that > A computer without loops is a calculator Is this true?   Is that the only difference?   Is there a set of criteria to differentiate or has the line become very blurred?


title: I can get visual studio for free through school, should I?

text: I am currently using dev++, I am a complete beginner, (Freshman CS major) learning C++. I can get one of the newest versions of visual studio (2008 or 2009 i think) for free through my school. Not sure if it is worth the trouble of getting. thoughts?


title: What are the boundaries of the product owner in scrum?

text: In another question, I asked about why I feel scrum turns active developers into passive developers, and it seems that the overall problem is not scrumy (related to scrum), and rather it's related to the bad implementation of scrum. So, here I have some questions about the scope of the responsibilities of PO (product owner) and the limitations he/she shouldn't pass.   1. Should PO interfere the UI design, when there are designers at work in scrum team? (an example of this which has happened to us, is to replace checkboxes with a drop down list with two items, namely, yes and no; or to make some boxes larger, or to left-align some content instead of centering them on the page, or stuff like that). If yeah, to what extent? Colors? Layout?   2. Should PO interfere in Design and architecture of coding? This hasn't happened to us yet, but I'm really curious about the boundaries. For example does PO has the right to change the platform (moving from ASP.NET MVC to PHP, or something like that), or choosing the count of servers (tier architecture), etc.   3. Should PO interfere in validation mechanisms? For example, this field should be required, or we don't need to get this piece of information from user. Sometimes, analyzers and designers confirm that something can be handled behind the scene, like extracting the user profile info from another source, instead of asking for it in UI.    4. How granular could/should PO get into the analysis and design? For example, a user story might be: "As a customer, I'd like to be able to buy new domains online". However, scrum team can implement this user story in a wizard of five steps, or in one single page. To which level PO should monitor, or govern, or supervise the technical analysis, design, and implementation? I asked these questions to judge whether our implementation is right or wrong?