Will using multiple recordsets in one database request be more efficient?

I am redeveloping an old ecommerce website which is currently written in C# ASP.NET 2.0. Because this is a reasonably high volume website and has suffered performance issues I want to develop in the most efficient manner possible. To minimise database trips (using SQL Server 2012), as database performance is the usual bottleneck in the current system, I am looking at creating stored procedures that return everything required for the current page in one query as multiple recordsets. For example the home page query might return the promotional banner image filenames and text, the new release products, the top selling products, etc. The product page might return the product details, related products, etc. I can't remember seeing this technique used often if at all. Is returning all data in a single database request more efficient than retrieving the same data in several database requests? Are there any flaws in doing this?


How to remove redundant code that enables button. Or "if" statement

I got probably "micro optimization" problem. I got **"History number"** , **"Next Number"** , **"Reset"** buttons, as well **"label"** for text. Every time I click At **"Next number"** button I would like to show random number in the **label** , and add this number to **history array** where I keep track of the past number. Every time I click at **"History number"** it would randomly show one of the random numbers from **history array**. Every time I click at **"Reset"** button, it would just clear **history array**. And you can see that, that clicking at the **"History number** makes only sense when the **history array** is NOT empty. And I wonder how to do this, without redundant **"if"** statement at the **"history number"** callback. Or Deactivating **"history number"** button at the start of the program. Then activating it **EVERY** time the **"next number"** is clicked (which is uuugly). And deactivating this button again on **"Reset"** button. This scheme on whiteboard demonstrate what I mean : ![Scheme that demonstrate buttons label and concept](http://i.stack.imgur.com/GOwQB.jpg) And I have JavaScript code where I implemented one of ugly solution (latter one, with deactivating and activating on appropriate callbacks). http://jsbin.com/aJESAYu/17/edit PS: I stumbled upon this problem writing in Objective-C, but I though, that it would be stupid to publish repository with iOS Objective-C code, while not everybody have to have Xcode. So I done Javascript Example. So don't restrict your answers to only on language. PS2: I though about having two **"next number"** functions. 1) One that would have the line of code that enable **"history number"** button and 2) second without. At the start the 1) function would be handler. And at the end of that 1) function, the handler would replace itself to the 2) function. Also the **"reset"** handler would put again handler to the 1) function. PS3: I know, this could be overkill. But I just several times struggled with this kind of situation. And I wonder if there are better solution. Thank you very very much in advance.


Version control of application data

Put very simply, my company's product is a webapp with a database backend. We have a stage environment and a production environment for each of roughly 100 clients. There is a separate database for each environment. The database contents come from a number of CSV files that are created and maintained by our (non-technical) data team. Data is client specific and must also be updated when dev adds new features to the product. However, not all clients use the same version of the product, so not only the contents but also the structure of the CSVs varies by client. Currently, the CSV files are versioned in SVN. However, there is no separation between tested and untested data. My team is responsible for loading new data to customer environments, but we've gotten burned before by loading untested data to a production environment. The clear answer to this is to mimic a development setup and create a trunk, branches, and tags, where trunk is always stable (tested data), branches contain experimental/untested changes, and tags are created every time new data is loaded to an environment. My question involves the dependency between data and code...when dev makes a release that includes new features, the data has to be updated to accommodate those features before we can upgrade the code on an environment. How can we track whether the data for a particular client is compatible with a particular version of code? My first instinct is to create a branch in the data repo every time a code upgrade is planned for a given customer. The branch name would correspond to the release number. However, because the code version on our production boxes usually lags significantly behind that on our stage environments, the data team would have to work in two branches simultaneously, ensuring that new features for the latest and greatest code only go in the newest branch, but fixes continue to go in the older branch as well. Of course, once the code on stage and production diverge, we cannot be 100% sure that the data fixes we test on stage will work on the older code installed in production. Does anyone have any ideas about how we can manage this process better?


Get user specific data client or server side

Websites that have membership systems and shopping carts usually show different information on the page depending on whether the user is signed in or not, whether there are items in the cart, etc etc. The rest of the page is often the same for all users, signed in or not. To show this user specific information you can either do it on the server side as the page is rendered, or on the client side with an AJAX call when the page loads. Doing it on the client side might have some benefits in performance of the server as server side load is reduced as the page can be served from cache, and although the user specific data still has to be generated on request it will be minimal. The disadvantage is another request to the server, of course. Looking for opinions on the pros and cons of each technique and what is commonplace on big high-volume websites. What do Stack do?


How to Explain Coding is not just Copy and Paste to non Software Developers?

We have 6 people in my group. My boss and the others are all SQL developers with little understanding of programming, design patterns, good object oriented design, etc. But, they have all taken a Java course in college. When new projects come up, I am usually asked to give a time estimate for how long my part will take. If this project is needed with quick turn around and they don't like the estimate I have given them, they will look at previous modules/portlets I have built and say things like, "It basically looks the same as Project X, so you should be able to just copy/paste that code and modify the SQL a little. You should be able to do this in 1/2 the time you gave us". Recently, it got so bad, my boss called me into a daily status update meeting with the group there, and each of the SQL developers asked me why I couldn't just copy/paste the existing code. They even `took the wiki documentation I created` from the previous projects and **began explaining my documentation to me**. Has anyone else ran into this? How do you handle this?


How does Observer create loosely-coupled design?

I completely understand the Observer design pattern, what it is for and how to implement it. I also understand what the term 'loosely-coupled' means. But I'm not sure how Observer makes designs more loosely-coupled. For example, let's say I want objects B and C to get updates from object A about it's state. The Observer pattern is a great way to do that. But one could also implement this with a more 'brute-force' way, not using the pattern. Please explain to me how the Observer pattern allows for more loosely-coupled designs. I'm not sure I completely understand. Thanks _(Again, I understand what 'loosely-coupled' means, but not exactly how Observer allows for designs to be more loosely-coupled)._


What should someone learn to become a great web-app builder by 2015

My brother just started learning some html/css at school and he loves it. He asked me to give my advice on what languages to learn in order to build great web-apps by the time he leaves school. (2015 or something like that.) I did some research, and right now I want to tell him (in this particular order):   * HTML -> HTML5   * CSS -> CSS3   * Javascript -> jQuery -> AJAX   * PHP -> Zend Framework   * MySQL   * Ruby -> RoR I would like to know if this is correct before I waste his time. Stackoverflow seems like a place where people know the answer to these kind of questions ;). Thanks!


Designing classes containing the same objects but different amount of them

I am creating a main object, MACHINE, which will contain a diversity of several other objects -- AXIS, AMPLIFIER, ENDEFFECTOR, etc. The number of contained objects will vary depending on the MACHINE model object that I am using. For example, a certain machine might have one AXIS and one ENDEFFECTOR; another 3 AXIS and 2 ENDEFFECTORS, etc. I was planning to create subclasses with each machine model, and initialize the respective number of contained objects depending on the model. My fear is that there is going to be an explosion of machine models, as well as quite a lot of repeated code and settings among subclasses. I get the feeling that there is a cleaner way to implement this, but I am not sure how to. Any ideas will be greatly appreciated.


Can referentially transparent functions have side effects?

I read everywhere that referential transparency and side-effects are mutually exclusive for all functions, however, what about the case in which a function changes some state that has no effect on its outputs. For example:               global_variable = 0          def foo(a,b):         global_variable += 2         return a + b          # Other code ...      Now, if you call this function, it seems to fit the standard definition of referential transparency while it also changes state and thus has side- effects. With that in mind, I wonder, do I misunderstand referential transparency or the even the idea of a side-effect? Is it correct to say that the function foo is both referentially transparent and has side-effects? To an extent, I feel that it is counter-productive to expand the definition of referential transparency with the condition that side-effects with no effect on the return value of a function still excludes functions from being considered referentially transparent.


Are there any algorithms for splitting or combining words into their more common form?

Are there any existing algorithms which can look through a list of words and split or combine words into their more common form? For example, I have a list of many business names in the health care industry. The word "`healthcare`" is often written "`health care`". There are also business names which might be split or combined, such as "`Walmart`" and "`Wal mart`". Are there any algorithms which can look at my list of words and identify that "`healthcare`" is more often written as two words, and that "`Wal mart`" is more often written as a single word? I'm looking for the names of existing algorithms (which can help when searching the web), or links to existing white-papers or blog posts. I'd prefer an algorithm that doesn't depend on a dictionary or other external list of words or business names. EDITS: Background: I already have some code that is moderately successful at this task. The code was thrown together without much rigor. I hoped there were some established algorithms, which would likely be more academic and complete then what I've come up with. This question is not about the method I've come up with, but saying "it's impossible" doesn't convince me. Clarification: The "more common form" of a word is the way the word(s) are most often written. For example, "`Walmart`" appeared many times, and "`Wal mart`" appeared many times, but "`Walmart`" appeared more often then "`Wal mart`" and so "`Walmart`" is the "more common form" of the word. I don't expect this algorithm to produce perfect results. Like any machine learning problem, I expect the results to be dependent on the quality of data I give it, and how much data I have.


Interface questions for using Command Pattern and Dependency Injection together

I have many projects that have essentially the same high level requirement: test all hardware on a device. Each device can have a different communication protocol, requires different test equipment to exercise the device, etc. So, at a high level a test is essentially the following:   1. obtain handles to test equipment   2. apply stimulus to device   3. measure/detect/record something measurable   4. remove stimulus   5. store results   6. handle errors  I thus created an interface class ( CTestEquipment ) as every piece of test equipment can be a concrete class with a unique implementation. The device under test can be considered a piece of test equipment as well. I'm using Dependency Injection for the driver of the test equipment. This is to allow for easy changes from one driver to another and to keep the driver and the equipment somewhat decoupled. For instance, a power supply might use a GPIB driver, a VISA driver, or raw serial commands. Each project can choose which is applicable and change one line ( the driver instantiation ). Next, I created classes to implement the Command pattern for the test equipment/device. So, CTestEquipment inherits from CCmdReceiver. A concrete command class calls the execute method which via the receiver calls the test equipment's tx/rx methods. Those methods call the underlying driver. Questions/Problems: How do I extract the received data from the command? Right now execute has no arguments and returns nothing. A concrete command might only transmit, only receive, or do both so the execute interface needs to either return a value even when there's no received data or some other way I need to be able to access it. CSetSerialNumber has no received data. CGetMode does. Since the command is calling tx/rx which ultimately calls the driver's tx/rx how do I package the data to those calls since each driver could take something different? I've contemplated a CPacket interface and various concrete implementations but then how do I make sure passing a concrete class that doesn't match the driver is caught?               //--------------------------------------------------------------------------------------     // CCommand     //      Abstract interface that defines the execute method     //--------------------------------------------------------------------------------------     class CCommand     {     protected:     CCmdReceiver *      _rcvr_p;            // receiver interface          // Default Constructor     CCommand()     {}          public:     // Constructor     CCommand         (         CCmdReceiver *  r               // receiver interface         ) :        _rcvr_p      ( r )     {}          // Destructor     virtual ~CCommand()     {}          // Method to Execute the Command     virtual void execute() = 0;     };          //--------------------------------------------------------------------------------------     // CCmdReceiver     //      Abstract interface that defines the command action     //--------------------------------------------------------------------------------------     class CCmdReceiver     {     public:     virtual void flush() = 0;          virtual void rx( std::vector< unsigned char > & v ) = 0;          //virtual void tx( std::string const & s ) = 0;     virtual void tx( CPacket * p ) = 0;     };          /*------------------------------------------------------------------------------     Test equipment driver abstract base class     ------------------------------------------------------------------------------*/     class CDriver     {     public:     /*--------------------------------------------------------------------------     Constructor     --------------------------------------------------------------------------*/     CDriver() :         _is_open            ( false )     {}          /*--------------------------------------------------------------------------     Destructor     --------------------------------------------------------------------------*/     virtual ~CDriver()     {}          //protected:     /*--------------------------------------------------------------------------     Close the Driver         Must be implemented in a derived class     --------------------------------------------------------------------------*/     virtual void close() = 0;          /*--------------------------------------------------------------------------     Get the Received Data     --------------------------------------------------------------------------*/     template< typename tVal >     tVal getRxData();          /*--------------------------------------------------------------------------     Determine if the Driver is Open     --------------------------------------------------------------------------*/     virtual bool isOpen()     {     return( _is_open );     }          /*--------------------------------------------------------------------------     Open the Driver         Must be implemented in a derived class     --------------------------------------------------------------------------*/     virtual void open() = 0;          /*--------------------------------------------------------------------------     Receive Data     --------------------------------------------------------------------------*/     virtual void rx()     {}          /*--------------------------------------------------------------------------     Set Open/Closed Flag State     --------------------------------------------------------------------------*/     inline void setOpenState         (         bool const & open = true         )     {     _is_open = open;     }          /*--------------------------------------------------------------------------     Transmit Data     --------------------------------------------------------------------------*/     virtual void tx         (         std::string const & cmd         // command to transmit         )     {}          private:     bool    _is_open;           // flag to indicate if protocol is open     };          //--------------------------------------------------------------------------------------     // Abstract Test Equipment Class     //      Utilizes constructor DI for device driver     //      Utilizes RAII for open/close     //--------------------------------------------------------------------------------------     class CTestEquipment : public CCmdReceiver     {     public:     /// Constructor     CTestEquipment         (         boost::shared_ptr< CDriver > const &                     drvr        // device driver         ) :         _drvr           ( drvr ),         _init_cnt           ( 0 )     {     _drvr->open();     incInitCnt();     }          /// Destructor     virtual ~CTestEquipment()     {     if( isInitialized() )          {          _drvr->close();          }     }          /// Function to Access the Equipment's Driver     inline boost::shared_ptr< CDriver > const & accessDriver() const     {     return( _drvr );     }   // accessDriver()          /// Decrement the Initialization Count     inline void decInitCnt()     {     --_init_cnt;     }   // decInitCnt()          /// Get the Initialization Count     inline int getInitCnt() const     {     return( _init_cnt );     }   // getInitCnt()          /// Increment the Initialization Count     inline void incInitCnt()     {     ++_init_cnt;     }   // incInitCnt()          /// Check if Initialization has Occurred     inline bool isInitialized() const     {     return( _init_cnt >= 1 );     }   // isInitialized()          /// Determine if the Driver is Open     inline bool isOpen() const     {     return( _drvr->isOpen() );     }   // isOpen()            protected:     /// Reset the Equipment     virtual void reset()     {     //_drvr->reset();     }          /// Function to Receive Data from the Equipment     inline void rx()     {     _drvr->rx();     }          /// Function to Set the Device to a Default State     virtual void setToDflts()     {}          /// Function to Transmit a Command to the Equipment     inline void tx( std::string const & cmd )     {     _drvr->tx( cmd );     }          /// Function to Transmit a Command, Receive the Response, and Return the Parsed    Value     template< typename tVal >     tVal txRx         (         std::string const & cmd         // command to transmit             )     {     _drvr->tx( cmd );     _drvr->rx();          return( _drvr->getRxData< tVal >() );     }          protected:     boost::shared_ptr< CDriver > const &             _drvr;              // device driver     int     _init_cnt;          // initialization count     };          class CGetMode : public CCommand     {     public:     CGetMode         (         CCmdReceiver *  rcvr            // command receiver         );          void execute()         {         // G: what type is cmd?         // G: what type is buffer?         // G: how do we access buffer?         _rcvr_p->flush();         _rcvr_p->tx( cmd );         _rcvr_p->rx( buffer );         }      };          //--------------------------------------------------------------------------------------     // CSetSerialNumber     //     Extends command interface. Implements the execute method and invokes it on a receiver.     //--------------------------------------------------------------------------------------     class CSetSerialNumber : public CCommand     {     public:     // Constructor     CSetSerialNumber         (         CCmdReceiver *  rcvr                // command receiver         );          void execute()         {         // G: what type is cmd?         _rcvr_p->tx( cmd );         }     };


How much effort should I invest in creating loosely coupled designs?

I am currently learning about design patterns. I think most people would agree that these patterns are great tools, but should be used with moderation and not as the answer for everything. Using them too much would over-complicate the application with little benefit. Patterns should be used only where they can be the best solution or help in the creation of a good solution (do you agree?). With this in mind: The book I'm reading (Head First Design Patterns) frequently emphasizes the importance of **loose coupling**. This loose coupling is acheived by following principles such as 'program to an interface, not an implementation' and 'encapsulate what varies'. Basically, most patterns I learned so far exist mostly to allow designs to be loosely coupled, and thus more flexible. I understand the importance and benefits of loose coupling. But my question is, **how much effort should one actually invest in creating loosely coupled, flexible designs?** Those who oppose design patterns say that the costs to using these patterns often outweighs the benefits. You invest a lot of time in creating a loosely coupled design using some pattern, **where in reality - the loose coupling, 'programing to an interface, not an implementation', and all of these principles - might not actually be so important.** What I'd like to know, is how much effort should I actually put in creating additional levels of abstraction and designs, only to allow my application to follow OO principles such as loose coupling, programmign to an interface, etc. Is it really worth it? How much effort should I put in this?


Premature optimization in deciding how to optimize?

We have a class that has been properly identified for optimization. We've done the profiling and testing, and it's a problem. Now we have two possible approaches for optimizing this class:   1. There is some very low-hanging fruit. We can rewrite this in a few days in such a way that the interface and results aren't changed, so we don't have to change any code that uses the class. We can see what effect this has on performance and go from there. This seems to me to be a very low risk, low investment approach.   2. Since we're already going to be making changes, we could go all out in our optimization. The suggested approach would implement a third-party engine and require us to change the code that uses this class, as well as transform the existing client data that is sent to the class into a format usable by the third-party engine. This may not take too much longer to code, but there would be much more testing required. This seems like a very high-risk, high-investment change and will require a lot of extra testing to make sure we don't break the calling code and don't break the existing client data. I of course can't test ahead of time, but the second approach will _probably_ execute more quickly and be more memory-efficient. However, I'm not sure how much faster, and I'm not sure if the extra effort will even be worth it. I'm not sure that once we made the low-risk changes, we would still consider the the code to be a valid target for optimization. You can probably guess which approach I would rather take. I'm at odds with a coworker on this one. So here's my question: Is the second option premature optimization despite the fact that we've already identified this code for optimization? What's the approach that should be taken in this situation?


Backtracking with Killer Sudoku

I'm developing a Killer Sudoku solver for a school project. I've programmed 10 human strategies showing what they are doing in order to be the most educational possible. It can solve hard Killer Sudokus right now but my teacher proposed that I use backtracking to solve every possible grid. I've been trying for one week searching for general resources on backtracking or resources based on Sudoku... The fact is that with Killer Sudoku, you can't just say a cell has a solution without relying on zones and on what the previously written cells imply on zones and possibilities everywhere. What I'd like to do is something which applies all my strategies everytime it suggests a number to be more efficient and return the only solution. But to apply strategies, we need a copy of the grid right ? So I can clone my objects totally using some methods and I can apply my strategies using another method. What would be the structure for this function ? PS: I've tried several times to write some code and everytime the solution returned was incorrect. (The grid can easily be checked for validity) It was something like this :               def bt(sudoku)       if sudoku.valid? then         true       else         sudoku2 = sudoku.clone         sudoku2.first_cell_not_solved.possibilities.each do |p|           sudoku2.first_cell_not_solved.solution = p         end         sudoku2.apply_all_strategies         if sudoku.completed?           return sudoku.valid?         else           bt(sudoku2)         end       end     end


How to render a terrain using height maps and getting basic collision detection on top of the terrain and camera (moving on the terrain)

I have loaded a .RAW file into a 2x2 array in my class. The way I am rendering it works fine but I am struggling to get the camera to move on top of the terrain. The terrain renders from 0,0,0 (x,y,z) as that is where I put my camera. My camera class allows to the "camera" to move through the scene. I want to be able to "walk" on top of the terrain with some basic collision detection (if possible). Any tips on where to go for this or any tips?


What are the three main technologies for a redesign of a COBOL legacy system

There exists an application that reports financial data of a bank to a national bank (all located in Europe). It is a legacy system that is written mainly in COBOL. Only the user interface is written in Java. The business logic is stored as complex data base tables and entries. Without knowing all internals, the system can hardly be changed according to new financial regulations. Thus, the current system is very hard to debug and unmaintainable. My aim is now to identify state-of-the art technologies/methods for a redesign and rewrite of the whole system. What would you consider as the three most important technologies to use for a rewrite of a COBOL System in finance? Current considerations include:   1. Using a DSL approach (domain specific language)   2. Using a modern programming language like Scala   3. MS OLAP cube (suggested by a colleague, not by me)


Is it OK to Use Dropbox in a Web Installer?

So I'm working in a modding project and they gave me the installing part as to do. We plan to publish it between **30 Aug. - 01 Sept.** **My question is;** is it logical to use **Dropbox** to download files in the **web installer**? I saw Dropbox's public folder has **10 GB download bandwith** limit daily, after reaching that; they lock the account. I can insert a quota function and can use more than one Dropbox accounts. But it seems (not sure but) it's illegal or opposite to company's politics. I don't know is the same bandwith limit applies to downloading directly from the **root folder.** Also total size of the packages reaches **1 GB**. This why I'm afraid of the bandwith limit. And, if you **don't recommend** using Dropbox, what would you advise? I think a simple web automator with **Mediafire** is a good choice but resuming download will **not be** possible. Also I have a **Fileserve Premium Account** (a friend of mine gave as a gift) but most probably it will be banned after using different IP's at the same time. One more thing I'm writing it in **C#**. Thanks...


Windows GUIs: How Long Will 'Deprecated' APIs Last?

Note I said 'deprecated' and not 'abstracted'. Back in the days of the MFC, the WinAPI wasn't deprecated because, from what I've read, the MFC merely abstracted the WinAPI. There's a difference, for a deprecated API is one who's functionality has a newer slide-in replacement as opposed to a layer on top. I ask in light of the direction Windows has taken. First, GDI objects were bypassed with WPF by using DirectX. Unless I've read misinformation, this means the Windows GUI could have been reimplemented in an API that doesn't need GDI underneath. Then came Windows 8, announcing the move to HTML/JavaScript interfaces, which means DirectX isn't needed too. Ha. Of course it is, the IE engine running such interfaces probably uses hardware acceleration provided by DirectX these days. But GDI isn't needed right? In fact, because GDI isn't needed anymore, doesn't that deprecate GDI, GDI+, MFC, and the various other templating libraries built on the GDI? Now, contrary to common thought, it's known that Windows traditionally took backwards compatibility very seriously. But how long will they go before dropping GDI? How long until .NET's core libraries are rewritten to call the kernel and private low-level Windows routines directly for services without going through the WinAPI itself? After all, C# supports unsafe code, so the public WinAPI layer being bypassed isn't inconcievable even for the lower- level stuff. I'm not talking about the C code being eliminated or anything like that. Just wondering if some of the public interfaces presented by Windows might not be available if MS deems them unneccessary in the future.


How did you get good practices for your OOP designs?

I realized I have a difficulty creating OOP designs. I spent many time deciding if this property is correctly set it to X class. For example, this is a post which has a few days: http://codereview.stackexchange.com/questions/8041/how-to-improve-my-factory- design I'm not convinced of my code. So I want to improve my designs, take less time creating it. How did you learn creating good designs? Some books that you can recommend me?


Dilemma of QA vs. iterations

In my company, we successfully working with agile practices - but without using iterations. The main reason is that we can't find a clean way to fit in QA in an iteration cycle. We understand QA as an extra bit of verification to a _certain build_ (release candidate) before this build gets deployed to the customer. The point is to avoid that a single malicious commit damages the whole release. Since you never know which one it is, QA has to wait until _all_ features/commits for the release are in the build. (No famous last words "It was just a tiny change" allowed.) If QA finds bugs in a release candidate, developers fix these bugs in the respective release branch (and merge it into trunk). When all bugs are fixed, a new build is deployed for QA to re-test. Only when no bugs are found in a certain release candidate, it's offered to the customer for verification. This usually takes around two to three candidates, about one week, per release. The time to write the fixes is typically much lower than the testing efforts. So in order to keep the developers busy, they work on release N+1 while QA works on N. Without using iterations, this is no problem because we can overlap the work for releases N and N+1. However, from what I understand, this is not compatible with iteration-based approaches like Scrum or XP. They demand an iteration to be releasable at its end with all testing effort to be incorporated in the iteration. I find that this necessarily leads to one of the following unwanted results: **(A)** Developers are idle at an iteration's end because QA needs time to verify a release candidate and bug fixing work is not fully keeping devs busy. **(B)** QA starts working already before first release candidate is ready. This is what is mostly recommended on Stack Exchange. But it's not what my company understands as QA because there is no specific release candidate tested. And the "tiny change" that breaks everything can still be introduced unnoticed. **(C)** Bugs are carried over to the next iteration. This is also recommended on Stack Exchange. I don't think it's a solution at all. It basically means that we are never getting a verified build because whenever bug fixes are made, new, unverified commits are added to the same branch as well. **Is there any way out of this dilemma?**


Do changes in performance violate the Liskov Substitution Principle?

Say I have:               interface Thing     {         GetThing();     }          class FastThing : Thing      {         public int GetThing()         {             return 1;         }     }          class SlowThing : Thing     {         public int GetThing()         {             return GetThingFromDatabase();         }     }      Is this a violation of the Liskov Substitution Principle?


How many developers before continuous integration becomes effective for us?

There is an overhead associated with continuous integration, e.g., set up, re- training, awareness activities, stoppage to fix "bugs" that turn out to be data issues, enforced separation of concerns programming styles, etc. At what point does continuous integration pay for itself? **EDIT: These were my findings** The set-up was CruiseControl.Net with Nant, reading from VSS or TFS. Here are a few reasons for failure, which have nothing to do with the setup: _Cost of investigation_ : The time spent investigating whether a red light is due a genuine logical inconsistency in the code, data quality, or another source such as an infrastructure problem (e.g., a network issue, a timeout reading from source control, third party server is down, etc., etc.) _Political costs over infrastructure_ : I considered performing an "infrastructure" check for each method in the test run. I had no solution to the timeout except to replace the build server. Red tape got in the way and there was no server replacement. _Cost of fixing unit tests_ : A red light due to a data quality issue could be an indicator of a badly written unit test. So, data dependent unit tests were re-written to reduce the likelihood of a red light due to bad data. In many cases, necessary data was inserted into the test environment to be able to accurately run its unit tests. It makes sense to say that by making the data more robust then the test becomes more robust if it is dependent on this data. Of course, this worked well! _Cost of coverage, i.e., writing unit tests for already existing code_ : There was the problem of unit test coverage. There were thousands of methods that had no unit tests. So, a sizeable amount of man days would be needed to create those. As this would be too difficult to provide a business case, it was decided that unit tests would be used for any new public method going forward. Those that did not have a unit test were termed 'potentially infra red'. An intestesting point here is that static methods were a moot point in how it would be possible to uniquely determine how a specific static method had failed. _Cost of bespoke releases_ : Nant scripts only go so far. They are not that useful for, say, CMS dependent builds for EPiServer, CMS, or any UI oriented database deployment. These are the types of issues that occured on the build server for hourly test runs and overnight QA builds. I entertain that these to be unnecessary as a build master can perform these tasks manually at the time of release, esp., with a one man band and a small build. So, single step builds have not justified use of CI in my experience. What about the more complex, multistep builds? These can be a pain to build, especially without a Nant script. So, even having created one, these were no more successful. The costs of fixing the red light issues outweighed the benefits. Eventually, developers lost interest and questioned the validity of the red light. Having given it a fair try, I believe that CI is expensive and there is a lot of working around the edges instead of just getting the job done. It's more cost effective to employ experienced developers who do not make a mess of large projects than introduce and maintain an alarm system. This is the case even if those developers leave. It doesn't matter if a good developer leaves because processes that he follows would ensure that he writes requirement specs, design specs, sticks to the coding guidelines, and comments his code so that it is readable. All this is reviewed. If this is not happening then his team leader is not doing his job, which should be picked up by his manager and so on. For CI to work, it is not enough to just write unit tests, attempt to maintain full coverage, and ensure a working infrastructure for sizable systems. _**The bottom line:_** One might question whether fixing as many bugs before release is even desirable from a business prespective. CI involves a lot of work to capture a handful of bugs that the customer could identify in UAT or the company could get paid for fixing as part of a client service agreement when the warranty period expires anyway.


When does Continuous Integration add value?

> **Possible Duplicate:**   >  How many developers before continuous integration becomes effective? When does continuous integration (such as CruiseControl) add value to a project?   Do factors such as   * Number of Unit Tests   * How often changes are made   * Branch development   * Team Size make a difference in the value added by continuous integration, or is it something that's always worth the trouble?


Parallel computing using xcode

I'm making mandelbrot fractals in C using Xcode and I want to use parallel computing but everything I've tried so far doesn't work. Such as This Question and other how to guides. Whats the easiest way to use frameworks such as mpi.h to run my program in parallel?


MVC design pattern. Overloading controller responsibilities

I'm developing a desktop application with a GUI. To do so, I'm using the MVC design pattern for the GUI part. For now the application consists of a single window (view) with one controller interacting with the backend (model). The interaction is becoming more complex day by day with the controller getting more and more methods to handle inputs and adding more dependencies with model objects. Since it's a best practice to keep the classes and methods small I feel like delegating some tasks, is it right? Is there any clean way to do so? Regarding the dependencies with the model, I'm using a facade object, but again I feel like it's getting too overloaded.


Refactoring a 1500 LOC method that only builds the graphical UI

I'm currently scratching my head over how to refactor a method that basically only builds the UI. The method is more than 1500 lines of code (LOC) long - and counting. It has grown, there was no plan how to approach this. You **might** find this familiar. Anyway, it's basically just one large method that goes a little something like this:                   .         .         .              # null checks         null_checks_bx = Box(True)              null_checks_ck = CheckBox()         null_checks_ck.set_text('Null checks throwing exceptions of type:')              if 'doNullChecks' in options:             null_checks_ck.set_active(options['doNullChecks'])         else:             null_checks_ck.set_active(True)              # dict to sorted list: extract values from dict by list comprehension         exceptions = sorted([exception.get_full_name() for exception in JavaTypes.exception_types])              null_checks_se = Selector()         null_checks_se.add_items(exceptions)         null_checks_se.set_enabled(null_checks_ck.get_active())              if 'nullChecksExceptionFullClassName' in options:             null_checks_se.set_value(options['nullChecksExceptionFullClassName'])         else:             # default to first entry             #(defaulting to doEquals = True and doHashCode = True by using hardcoded Commons Lang implies availability of Commons Lang NullArgumentException)             null_checks_se.set_value(JavaTypes.exception_types[0].get_full_name())              # callback         Callbacks.sync_model_active_status(null_checks_ck, null_checks_se)              null_checks_ck.add_clicked_callback(lambda: Callbacks.sync_model_active_status(null_checks_ck, null_checks_se))              null_checks_bx.add(Label(indent), False, True)  # dummy indent label         null_checks_bx.add(null_checks_ck, False, True)         null_checks_bx.add(null_checks_se, False, True)              # relationship entity class constructor calls         relationship_constructor_calls_bx = Box(True)         #relationship_constructor_calls_bx.set_spacing(5)         #relationship_constructor_calls_bx.set_padding(3)              relationship_constructor_calls_ck = CheckBox()         relationship_constructor_calls_ck.set_text('Instantiate relationship entities (if all necessary columns present)')              if 'doRelationshipConCalls' in options:             relationship_constructor_calls_ck.set_active(options['doRelationshipConCalls'])         else:             relationship_constructor_calls_ck.set_active(False)              relationship_constructor_calls_bx.add(Label(indent), False, True)  # dummy indent label         relationship_constructor_calls_bx.add(relationship_constructor_calls_ck, False, True)              # relationship not-null checks: this is an option independent of the null checks!         relationship_not_null_checks = Box(True)         #relationship_not_null_checks.set_spacing(5)         #relationship_not_null_checks.set_padding(3)              relationship_not_null_checks_ck = CheckBox()         relationship_not_null_checks_ck.set_text('Not-null checks before relationship instantiation')              relationship_not_null_checks_ck.set_enabled(relationship_constructor_calls_ck.get_active() and not null_checks_ck.get_active())              if 'doRelationshipNotNullChecks' in options:             relationship_not_null_checks_ck.set_active(options['doRelationshipNotNullChecks'])         else:             relationship_not_null_checks_ck.set_active(True)              # callback         Callbacks.sync_convenience_constructor_options(null_checks_ck, relationship_constructor_calls_ck, relationship_not_null_checks_ck)              null_checks_ck.add_clicked_callback(lambda: Callbacks.sync_convenience_constructor_options(null_checks_ck, relationship_constructor_calls_ck, relationship_not_null_checks_ck))         relationship_constructor_calls_ck.add_clicked_callback(lambda: Callbacks.sync_convenience_constructor_options(null_checks_ck, relationship_constructor_calls_ck, relationship_not_null_checks_ck))              relationship_not_null_checks.add(Label(indent), False, True)  # dummy indent label         relationship_not_null_checks.add(Label(indent), False, True)  # dummy indent label         relationship_not_null_checks.add(relationship_not_null_checks_ck, False, True)              # build final box         checks_bx = Box(False)         checks_bx.set_spacing(5)         #checks_bx.set_padding(3)         checks_bx.set_homogeneous(True)         checks_bx.add(omit_auto_increment_columns_bx, False, True)         checks_bx.add(omit_auto_timestamp_columns_bx, False, True)         checks_bx.add(null_checks_bx, False, True)         checks_bx.add(relationship_constructor_calls_bx, False, True)         checks_bx.add(relationship_not_null_checks, False, True)              # callback         Callbacks.sync_model_active_status(convenience_constructors_ck, checks_bx)              convenience_constructors_ck.add_clicked_callback(lambda: Callbacks.sync_model_active_status(convenience_constructors_ck, checks_bx))              # need wrapped box for Panel class         constructors_bx = Box(False)         constructors_bx.set_spacing(5)         constructors_bx.set_padding(3)         #constructors_bx.set_homogeneous(True)         constructors_bx.add(convenience_constructors_bx, False, True)         constructors_bx.add(checks_bx, False, True)              constructors_pn = Panel(TitledGroupPanel)         constructors_pn.set_title('Constructors')         constructors_pn.add(constructors_bx)              # getters and setters         is_conversion_bx = Box(True)         #is_conversion_bx.set_spacing(3)         #is_conversion_bx.set_padding(3)              is_conversion_ck = CheckBox()         is_conversion_ck.set_text('Convert respective column names starting with "is_"')         is_conversion_ck.set_tooltip("Column is_incognito => getter isIncognito() (not getIsIncognito()) and setter setIncognito()")              if 'doIsConversion' in options:             is_conversion_ck.set_active(options['doIsConversion'])         else:             is_conversion_ck.set_active(True)              is_conversion_bx.add(is_conversion_ck, False, True)              # generate code for relationship getters and setters to synchronize with column fields         sync_relationship_pk_fields_bx = Box(True)         #sync_relationship_pk_fields_bx.set_spacing(3)         #sync_relationship_pk_fields_bx.set_padding(3)              sync_relationship_pk_fields = CheckBox()              .         .         .      You get the point. What I don't see is what the criteria might be to split this method up so the code will become more managable, more understandable etc pp. **What are the best practices here?** I could create some methods that would create recurring types of panels and widgets, but this would become a rather tedious effort for what I fail to see the real gain. Again, what are some useful, practical approaches to large, clumsy methods that only build the graphical UI? Thanks PS: oh and BTW the UI is a single Dialog in a standard, windowed application (no web), and this dialog has 6 tabs which contain mostly check boxes, radio buttons, and text boxes. It is a code generation plugin that the user can choose a lot of options from. I might post an image as soon as I get the plugin running again...


What is Atomicity?

I'm really struggling to find a concrete, easy to grasp, explanation of Atomicity. My understanding thus far is that to ensure an operation is atomic you wrap the critical code in a locker. But that's about as much as I actually understand. Definitions such as the one below make no sense to me at all. > An operation during which a processor can simultaneously read a location and > write it in the same bus operation. This prevents any other processor or I/O > device from writing or reading memory until the operation is complete. > Atomic implies indivisibility and irreducibility, so an atomic operation > must be performed entirely or not performed at all. What does the last sentence mean? Is the term `indivisibility` relating to mathematics or something else? Sometimes the jargon with these topics confuse more than they teach.


How to represent a tree structure in NoSQL

I'm new to NoSQL and have been playing around with a personal project on the MEAN stack (Mongo ExpressJs AngularJs NodeJs). I'm building a document editor of sorts that manages nodes of data. Each document is actually a tree. I have a CRUD api for documents, to create new trees and a CRUD api for nodes in a given document. Right now the documents are represented as a collection that holds everything, including nodes. The children parent relationship is done by ids. So the nodes are an map by id, and each node has references to what nodes are their children. I chose this "flat" approach because it is easier to get a node by id from a document. Being used to having a relation table between nodes and documents, a relation table between nodes and children nodes I find it a bit weird that I have to save the entire "nodes" map each time I update a node. Is there a better way to represent such a data type in NoSQL?


Good implementation strategies for encapsulating shared data in a software pipeline

I'm working on re-factoring certain aspects of an existing web service. The way the service APIs are implemented is by having a kind of "processing pipeline", where there are tasks that are performed in sequence. Unsurprisingly, later tasks may need information computed by earlier tasks, and currently the way this is done is by adding fields to a "pipeline state" class. I've been thinking (and hoping?) that there's a better way to share information between pipeline steps than having a data object with a zillion fields, some of which make sense to some processing steps and not to others. It would be a major pain to make this class thread-safe (I don't know if it would even be possible), there is no way to reason about its invariants (and it's likely it doesn't have any). I was paging through the Gang of Four design patterns book to find some inspiration, but I didn't feel like there was a solution in there (Memento was somewhat in the same spirit, but not quite). I also looked online, but the second you search for "pipeline" or "workflow" you get flooded with either Unix pipes information, or proprietary workflow engines and frameworks. My question is - how would you approach the issue of recording the execution state of a software processing pipeline, so that later tasks can use information computed by earlier ones? I guess the major difference with Unix pipes is that you don't just care about the output of the immediately preceding task. ======== As requested, some pseudocode to illustrate my use case: The "pipeline context" object has a bunch of fields that the different pipeline steps can populate/read:               public class PipelineCtx {         ... // fields         public Foo getFoo() { return this.foo; }         public void setFoo(Foo aFoo) { this.foo = aFoo; }         public Bar getBar() { return this.bar; }         public void setBar(Bar aBar) { this.bar = aBar; }         ... // more methods     }      Each of the pipeline steps is also an object:               public abstract class PipelineStep {         public abstract PipelineCtx doWork(PipelineCtx ctx);     }          public class BarStep extends PipelineStep {         @Override         public PipelineCtx doWork(PipelieCtx ctx) {             // do work based on the stuff in ctx             Bar theBar = ...; // compute it             ctx.setBar(theBar);                  return ctx;         }     }      Similarly for a hypothetical `FooStep`, which might need the Bar computed by BarStep before it, along with other data. And then we have the real API call:               public class BlahOperation extends ProprietaryWebServiceApiBase {         public BlahResponse handle(BlahRequest request) {             PipelineCtx ctx = PipelineCtx.from(request);                  // some steps happen here             // ...                  BarStep barStep = new BarStep();             barStep.doWork(crx);                  // some more steps maybe             // ...                  FooStep fooStep = new FooStep();             fooStep.doWork(ctx);                  // final steps ...                  return BlahResponse.from(ctx);         }     }


REST vs RESTful vs "normal" web service - the same or not?

I've read a couple of definitions and discussion on REST and/or RESTful applications, but I still do not understand the real meaning of it. I usually work with the apps which either fetch data via GET or send data via POST to some web service (usually a PHP script) which then either get data from the database or do writing into the database. Now, is this a RESTful app? If not, what would be a RESTful app? What is difference between RESTful concept and the concept I worked so far with? Please explain via an example. Also, someone is talking about the REST and someone about RESTful apps. I found that the REST term refers to the theoretical concept, while RESTful is used when we talk about the specific app. Is this right or there are real differences between REST and RESTful apps?


Why is there a gap between JBoss EAP and the JBoss AS/Community edition?

Admittedly new to this but I wanted to understand why there is a gap between Red Hat's JBoss EAP project (their _enterprise_ version) and JBoss AS/Wildfly/community project. Looking at this post from Red Hat, it seems that they don't withhold the source/patches. Makes sense since withholding the source would be a GPL violation, which in spirit wants source distributions so end users can recreate/reuse the binaries. So if the sources are identical, then why isn't the AS/community version **_exactly_** at par with the EAP version? Shouldn't they be bit-exact, like having the same SHA256 value? It appears that the AS/community version usually lags by several hundred patches (from here, "Intro" section) > _Talking about the latest JBoss Application Server is always tricky. Red Hat > simultaneously offers two versions of JBoss: community edition, the current > release where is 7.1.1-Final, and Enterprise Application Platform, EAP, > edition where JBoss AS component version is 7.1.3-Final. The difference > between these is actually a few hundred bug-fixes, which is enormous ..._ Since EAP binary distribution is controlled by Red Hat, surely there is enough community interest that the community itself rebuilds and redistributes AS/Wildfly binaries that are at-par with the EAP binaries, right? (a single Maven server should suffice). I mean look at the popularity of CentOS (the community version of Red Hat Enterprise Linux) - the community IS interested in using software in production without RedHat's blessings/support. So, what am I missing here?


Hashing + security as it pertains to a theoretical file sharing site

These days it's possible to hash a file client-side, send the hash to the server, and have the server check whether or not that file is already uploaded. If it is, we can skip the file upload and make it appear to upload almost instantly to the user. This can also save have oodles of bandwidth for a large site. This has some important security implications, however.   1. If the user is clever, he can use this information to determine what files are already on the server, including illegal or sensitive documents   2. He can produce millions of fake hashes, send them to the server, and hope for a collision to gain access to random documents   3. There is a legitimate but unintentional collision where the hashes are the same, but the file is actually different My question is: is it worth the trade-off? Can we mitigate some or all of these problems? How?


How to Determine Frequency (In Hertz, Real Time) with Java Sound

I've been looking around and I've found some questions similar to mine but have never been quite satisfied with the answers. I'm more or less a Java n00b, although I am moderately proficient with C++ and I would consider myself intermediate to advanced, as a programmer in general. I'm looking to write a program in Java that functions similarly to a tuner - what I want to do is record an instrument's pitch over about a 3 second time frame, and to measure the average deviation. (This is for a band class.) What I'm thinking is that I'll have a big array of numbers, and each entry in the array will be a number in terms of frequency. I want to be able to loop through the array, and calculate the average Hertz for displaying it on screen or something. So what I want to do is have some way of "polling" (for lack of a better word) the microphone to see what frequency is being inputted right that instant. Is there a simple way to accept audio input from a microphone in terms of Hertz? This will be in Java, under a Windows platform.


Which books or references cover design of domain specific languages?

There are a lot of books on domain specific languages (DSLs). Such books talk about compilers, interpreters, parsing, lexing, semantic analysis, and other various bits someone needs to implement a DSL. I already know how to implement a DSL; I've implemented several. However, several such DSLs have been monsters to work with. One starts out with whatever features one wants to support in the DSL, only to find that more features get added later, resulting in a mess of wacky and inconsistent conventions. I'm going to be designing a new DSL here and I want to start off on the correct foot, with an eye this time for future expansion of the language. The few books I've been able to find on language design seemed to be focused on general purpose (and C derived) language design, which is not a path that makes sense for my domain. What kinds of references or books are available on this topic?


Networkx / Python : Is using a class for a node better practice than defining multiple attributes?

I've read through the NetworkX tutorial and documentation, but was unable to find real world answers for this question. Usually when using NetworkX, I might use strings to define nodes, then set several attributes. e.g.               G = nx.Graph()     G.add_node('John Doe', haircolor = 'brown')     G.node['John Doe'][age] = 22      However, it seems like declaring a class with members instead of attributes is better in practice, especially when there are many attributes and readability might be an issue.               class Person:          name = None          age = None          Person p     p.name = 'John Doe'     p.age = 22     G.add_node(p)      Could someone be kind enough to validate my reasoning? I lack the foresight to see if Networkx node/edge attributes would be preferable.


Ruby IDE code completion

I just started writing some ruby in my spare time and am currently using Netbeans 7 with the Ruby and Rails plugin v0.111. I'm primarily a Java programmer coming from IntelliJ and Eclipse. One downside of my Ruby programming setup is that my Netbeans isn't very helpful when it comes to code completion. This seems due to the fact that Ruby is not strongly typed and since the IDE doesn't know the type it can't suggest methods. As a result I must spend a lot of time in my browser looking at documentation and switching back to my IDE to manually type in the method there. Are there any changes I can make to my setup to get code completion for Ruby or is it pretty much impossible due to the nature of the language? How do other developers work with Ruby, other than memorizing all the methods in the Core Library?


Jumping from 16-bit console to protected-mode game programming.

I am a just a little script kiddy, but I want to make the jump from just doing standrard console games in C++ to full graphic video games. I am just wondering if there are any good Directx 11 tutorials that I could start with.


Is BDD scalable for medium to large projects?

In every Website you read about BDD (Behaviour Driven Development) you find a very simple nice example showing you how obvious and easy is it to define your requirements. But trying to implement this process in a big product (not a calculator example) showed me that things can get (or will get) pretty complex and unreadable; especially changing requests at a later point means a lot of work to correct the Integration tests for this. So I'm wondering, is BDD really worth it? Does it solve a problem that other techniques don't!


Combining KanBan in a SCRUM process

Does anybody have an experience in combining KanBan in SCRUM, could this work, would this make sence or would it be an overdesign?


Alternative to simplexml_load_string() function

I am using `simplexml_load_string` for xml string interpreting to object from results of a REST API. It's working fine in my local server, which is using PHP5. But my hosting is in Yahoo and the service provider is giving me PHP4. For that I need to change the way of interpreting XML string to object to another method, which I don't know how to do.


Why is ~0 a Sequence of 1s

Why is `~0` a sequence of `1` bits and not just a single bit? Where do the extra `1` bits come from? Does this mean `~1` a sequence of `0` bits or just a single `0` bit? My understanding was that the `~` operator is applied on the specific bits mentioned.


IntelliJ IDEA vs phpStorm for developing PHP projects?

I'm a Java Developer, and now I'm using **IntelliJ IDEA Ultimate Edition**. Is it worth to buy **phpStorm** for developing PHP projects? Also, are there any other features for PHP developers which **IDEA** doesn't have? Thanks in advance!


how to prevent visual studio from messing with my code's identation?

Visual Studio 2010 automatically changes indentation of my code from this ::               public void fetchWebserviceCounters()  {         csv = new StringBuilder();         try  {            Category = new PerformanceCounterCategory("Web Service");            foreach (String instance in Category.GetInstanceNames())  {               counters = Category.GetCounters(instance);               foreach (PerformanceCounter counter in counters)  {                   if (counter.CounterName == "Total Bytes Sent" | counter.CounterName == "Total Bytes Recieved") {                      csv.Append(counter.CounterName + ",");                      csv.Append(counter.NextValue().ToString() + ", ");                   }               }            }        }        catch (Exception e) {                 Console.WriteLine(e.Message);        }        Console.Write(csv.ToString());      } to this               public void fetchWebserviceCounters()         {             csv = new StringBuilder();             try             {                 Category = new PerformanceCounterCategory("Web Service");                 foreach (String instance in Category.GetInstanceNames())                 {                     counters = Category.GetCounters(instance);                     foreach (PerformanceCounter counter in counters)                     {                         if (counter.CounterName == "Total Bytes Sent" | counter.CounterName == "Total Bytes Recieved")                         {                             csv.Append(counter.CounterName + ",");                             csv.Append(counter.NextValue().ToString() + ", ");                         }                     }                 }             }             catch (Exception e)             {                 Console.WriteLine(e.Message);             }             Console.Write(csv.ToString());         }      **How can i prevent Visual Studio from Doing this to My code**


Reverse horizontal and vertical for a HTML table

There is a two-dimensional array describing a HTML table. Each element of the array consists of:   * the cell content   * rowspan   * colspan Every row of this two dimensional array corresponds to `<td>` cells of a `<tr>` of the table which my software should generate. I need to "reverse" the array (interchange vertical and horizontal direction). Insofar I considered algorithm based on this idea: make a rectangular matrix of the size of the table and store in every element of this matrix the corresponding index of the element of the above mentioned array. (Note that two elements of the matrix may be identical due rowspan/colspan.) Then I could use this matrix to calculate rowspan/colspan for the inverted table. But this idea seems bad for me. Any other algorithms? Note that I program in PHP.


How should code "Goal Tending" be handled by a Development Manager?

First allow me to coin a term: > _**code goal-tending:** Checking out code in the morning, then silently > reviewing all of the changes made by the other developers the previous day > file by file, (especially code files you originally developed), and fixing > formatting, logic, renaming variables, refactoring long methods, etc., and > then committing the changes to the VCS._ This practice tends to have a few pros and cons that I've identified:   * **Pro** : Code quality/readability/consistency is often maintained   * **Pro** : Some bugs are fixed due to the other developer not being too familiar with the original code.   * **Con** : Is often a waste of time of the goal-tending developer.   * **Con** : _Occasionally_ introduces bugs which causes hair-pulling rage by developers who thought they wrote bug-free code the prior day.   * **Con** : Other developers get aggravated with excessive nitpicking and begin to dislike contributing to the goal-tender's code. Disclaimer: To be fair, I'm not actually a development manager, I'm the developer who is actually doing the "goal tending". In my defense, I _think_ I'm doing this for good reason (to keep our extremely large code base a well oiled machine), but I'm very concerned that it's also creating a negative atmosphere. I am also definitely concerned that my manager will need to address the issue. **So, if you were the manager, how would you address this problem?** UPDATE: I don't mean for this to be too localized, but some have asked, so perhaps some background will be illuminating. I was assigned a giant project (200K LoC) three years ago, and only recently (1 yr ago) were additional developers added to the project, some of which are unfamiliar with the architecture, others who are still learning the language (C#). I generally do have to answer for the overall stability of the product, and I'm particularly nervous when changes are surprisingly made to the core architectural parts of the code base. This habit came about because at first I was optimistic about other developer's contributions, but they made way too many mistakes that caused serious problems that would not be discovered until weeks later, where the finger would be pointed at me for writing unstable code. Often these "surprises" are committed by an eager manager or a co-worker who is still in the learning phase. And, this probably will probably lead to the answer: we have no code review policy in place, at all.


Scala/SBT - Documenting Configuration Change for Releases

I'm trying to collect different ways of managing configuration across multiple environments. I have a requirement to document configuration changes for the deployment plan. Dev values are defaults in the code and QA manages their own as well so the documenting and sharing of the info is a critical point. Rather than copy/pasting diffs into tickets, I'm wondering if there is a sharper way to do this. Keeping multiple copies of the config for each env seems to be divergent change. Manually documenting is just hard work and very error prone. Should be copy/pastable. I think templating may be an option but not sure how we'd plug that into build. Custom code is fine so I guess we could make a new build target if needed. Using scala/sbt but a maven solution or any other would be fine as it can be translated.


Ensure data entered by users adjusts to what actually is

This is more of a usability issue I'd say, looking of suggestions on it. I have a system that depends on the data entered by the users to be correct, as in the address exists, the name is correct, etc. This is all for places. Now the way I figured I could do this is that I have every entry peer reviewed, as in, have 5 other users check and ensure the data is correct before allowing it to be indexed and viewed on the site. The problem with this approach is that the site isn't one where the users will inhabit long, just log on look for a place and that's it, so they might not be inclined to verify that other user's entries are correct. What do you think about this, can anyone suggest a solution that might adjust to my situation?


OOP - How to handle multiple instances of a class

In OO programming, what's the preferred way of handling multiple instances (objects) of a single class? Say you want to write a program where a random number of circles get drawn on screen, where every circle is an instance of a Circle class, and when you click a button, every circle changes color. How would you do that? I see two ways, either to use a static variable (array) in the class holding all instances, along with a static function which loops through that array and calls a recolor method on each instance. Or to use the same variable and method, but instead put it in a separate class, maybe called CircleManager.


Are areas a good organizational feature, or just extra work?

Do `Areas` in ASP.NET MVC end up being a help or just a drag in the end (because of the URL construction)? Would it be better to have subdirectories inside the main Controllers folder? or are there any other options to organizing a project? _**EDIT_** For example, this is your average link without Areas:               @Html.ActionLink("Home","Index","Home")      and this is your average link with Areas:               @Html.ActionLink("Home","Index", new { Area = "", Controller = "Home"})      Could the following work? (Main controller with subdirectories) ![Main controller with subdirectories](http://i.stack.imgur.com/6Y9N2.png) I'm just trying to find out if implementing Areas in a project is worthwhile, because I also read that it can be problematic when using Dependency Injection. And is there an alternative to Areas?


Most efficient way of finding entities in a grid?

I'm working on my first game; a tower defense. So far It's coming along nicely. The only issue I am having (so far) is I can't figure out a way to effciently discover if an entity has entered a towers line of sight. So far I have considered just having every entity run though each known entity and calculate LOS, but that would bog down extremely quick. Then I thought of just having a bounding box for each tower and one each game step see if anything is in the bounding box. I have the same performance issue with that. Can anyone put forth some advice to put me on the correct track?


Are there studies about the disadvantages of using issue tracking systems?

I don't like issue tracking systems because:   * It takes too much time to describe issues in it. This discourage its usage.   * You create a place to keep your bugs. And if there is a place for them, people usually don't care too much about fixing a bug cause they can put it there so that someday someone can fix it (or not).   * With time, the bug lists gets so long that nobody can deal with it anymore, taking up a lot of our time. I prefer handling issues using post-its on a white board, face-to-face conversations and killing important bugs as soon as they appear. I don't care too much to keep track of bug history because I don't think that it is worth the overhead. Am I alone here? Are there studies (book/article/whatever) about the disadvantages (or great advantages) of using issue tracking systems?


Should 'mathematical' functions follow mathematical notation?

I suppose this question is going to be immediately flagged as subjective, but which do you think is better:               double volume(double pressure, double n_moles, double temperature) {       return n_moles * BOLTZMANN_CONSTANT * temperature / pressure;     }      or               double volume(double P, double n, double T) {       return n*R*T/P;     }      **In other words, should functions that implement some equation follow that equation's notation, or should they use more verbose names?**


Independent contractors posting projects to their portfolio

I'm about to hire freelance contractors to do small pieces of my web projects. Is it standard to allow them to put the project on their portfolio? Say a simple debugging task getting a specific mobile problem fixed in <5 hours. I'm just concerned as it could potentially dilute my company's portfolio by having it listed by each contractor when in fact the majority of work is done by me. I'm trying to build a portfolio here as an agency. I think it's a risk for my company since I'm working hard to get clients and the whole point is putting projects on _my_ portfolio. Am I wrong here? Is there an standard policy for this? Perhaps a limited policy whereby attribution is required to the agency? Did exactly X for agency Y (link).


What is a proper way of building Winform apps with multiple "screens"

What's a proper way of building a Winform app that has multiple 'screens'? For example, I'm trying to write a small backup program (mainly for giggles), and I've been dumping controls and containers onto the form. I'm using panels and group boxes to separate out the different screens (eg: I'm using a panel to hold all of the controls for the "Settings" window, and another panel to show all the current backups that have been set up). Well, my form.cs file ballooned into a massive amount of code, and I feel like I'm doing something wrong. I can hardly find anything in the file, and I'm ready to start over. This project was just for me to expand my knowledge of C# and .NET, so starting a new project is not a huge deal.


How to learn ASP.NET MVC without learning ASP.NET Web forms

First of all, I am not a web developer but I can say that I understand in general the difference between PHP, ASP.NET, etc. I have played a little with ASP.NET and C# as well, however, I didn't continue the learning path. Now I'd like to learn ASP.NET MVC but there is no a book for a beginner in ASP.NET MVC so I had a look at the tutorials but it seems that I need to learn C# first and SQL Server and HTML, am I right? So please tell me how can I learn ASP.NET MVC directly (I mean without learning ASP.NET Web forms). What do I need to learn (You can assume that I am an absolute beginner). **Update:** It is true that i can find ASP.NET MVC tutorial that explain ASP.NET MVC, but I used to find ASP.NET web forms books that explain SQL and C# at the same time and take you step by step. In ASP.NET MVC I don't know how can I start! How can I learn SQL in its own and C# in its own and then combine them with ASP.NET MVC!


Co-worker uses ridiculous commenting convention, how to cope?

A co-worker in the small start-up I work at writes (C++) code like this:               // some class     class SomeClass {              // c'tor         SomeClass();              // d'tor         ~SomeClass();              // some function         void someFunction(int x, int y);     };               // some function     void SomeClass::someFunction(int x, int y) {              // init worker         m_worker.init();              // log         LOG_DEBUG("Worker initialized");              // find current cache         auto it = m_currentCache.find();              // flush         if (it->flush() == false) {                  // return             return false         }              // return         return true     }      This is how he writes 100% of his code: a spacer line, a useless comment which says nothing other than what is plainly stated in the following statement, and the statement itself. This is absolutely driving me insane.   A simple class written by him spans 3 times as much as it's supposed to, It looks well commented but the comments contain no new information. In fact the code is completely undocumented in any normal definition of "documentation". All of the comments are just a repetition of what is written in C++ in the following line. I've confronted him several times about it and each time he seems to understand what I am saying but then goes on to not change his coding and not fix old code which is written like this. I've went on and on again and again about the distinct disadvantages of writing code like this but nothing get through to him. Other co-workers doesn't seem to mind it as much and management doesn't seem to really care. What do I do?   (sorry for the rant)


Why shouldn't you use JDBC in Java applets?

I've heard people saying usage of JDBC (Java Database Connectivity) isn't recommended in Java applets. All I they say is: 'because of the security reasons'. What 'security reasons' do they mean? What would a potentially 'bad person' do when he/she found out about JDBC used in an applet, placed somewhere on a website? To make one's applet safe, it is wise to place a servlet between an applet and a database. I believe most programmers do it, I would like to know why.


Project Proposal templates/requirements

When drafting a project proposal, do you use any standard template? What features/information should be included? What is nice to have included? What sort of boiler plate information should I shove in? Do you find any design pattern or concept particularly helpful?


While learning is it better to use other's plugins or develop my own?

As I have been learning to program, be it in my intern-ship or school, I have often come across situations where an extra piece of software is needed (from fairly basic to quite complex) and I am almost always told that I shouldn't waste my time developing a solution and use something someone else has already done. Does it make sense to do this or should I take the time to research and develop my own? At the moment I'm doing my final project which I have 15 weeks to complete, but the tutor and my classmates tell me not to bother. I can't help but think I am letting opportunities pass me by.


Why is a small fixed vocabulary seen as an advantage to RESTful services?

So, a RESTful service has a fixed set of verbs in its vocabulary. A RESTful web service takes these from the HTTP methods. There are some supposed advantages to defining a fixed vocabulary, but I don't really grasp the point. Maybe someone can explain it. Why is a fixed vocabulary as outlined by REST better than dynamically defining a vocabulary for each state? For example, object oriented programming is a popular paradigm. RPC is described to define fixed interfaces, but I don't know why people assume that RPC is limited by these contraints. We could dynamically specify the interface just as a RESTful service dynamically describes its content structure. REST is supposed to be advantageous in that it can grow without extending the vocabulary. RESTful services grow dynamically by adding more resources. What's so wrong about extending a service by dynamically specifying a per-object vocabulary? Why don't we just use the methods that are defined on our objects as the vocabulary and have our services describe to the client what these methods are and whether or not they have side effects? Essentially I get the feeling that the description of a server side resource structure is equivalent to the definition of a vocabulary, but we are then forced to use the limited vocabulary in which to interact with these resources. Does a fixed vocabulary really decouple the concerns of the client from the concerns of the server? I surely have to be concerned with some configuration of the server, this is normally resource location in RESTful services. To complain at the use of a dynamic vocabulary seems unfair because we have to dynamically reason how to understand this configuration in some way anyway. A RESTful service describes the transitions you are able to make by identifying object structure through hypermedia. I just don't understand what makes a fixed vocabulary any better than any self-describing dynamic vocabulary, which could easily work very well in an RPC-like service. Is this just a poor reasoning for the limiting vocabulary of the HTTP protocol? # Reflection Just to clarify my thoughts a little better than I have done. Suppose you are designing any general purpose API, maybe not even web facing. Would you be happy if someone said you can only use these method names on your objects? REST isn't restricted to HTTP, but consider the situation where every API you write, web facing or otherwise simply consisted of objects containing GET POST PUT and DELETE methods. So that object.foo method you wanted to define isn't possible. You have to define a new object called foo, and call its GET method. That's essentially how REST works, and it makes me a little uncomfortable to think about it. You don't have any better generic understanding of what foo does, you were just forced to create a new object for what is essentially a method on a parent object. Furthermore your API is no less complex, you have just hidden interface complexity by creating more objects. RESTful web services force us to adopt an interface which may or may not be sufficient in the context of the API we are exposing. Perhaps there is a good reason for doing this with web facing APIs, but a good reason to not adopt standard interfaces for every object in every general purpose API. A practical example would be appreciated.


Does command/query separation apply to a method that creates an object and returns its ID?

Let's pretend we have a service that calls a business process. This process will call on the data layer to create an object of type A in the database. Afterwards we need to call again on another class of the data layer to create an instance of type B in the database. We need to pass some information about A for a foreign key. In the first method we create an object (modify state) and return it's ID (query) in a single method. In the second method we have two methods, one (createA) for the save and the other (getId) for the query.                   public void FirstMethod(Info info)         {             var id = firstRepository.createA(info);                        secondRepository.createB(id);         }              public void SecondMethod(Info info)         {             firstRepository.createA(info);             var key = firstRepository.getID(info);             secondRepository.createB(key);         }      From my understanding the second method follows command query separation more fully. But I find it wasteful and counter-intuitive to query the database to get the object we have just created. How do you reconcile CQS with such a scenario? Does only the second method follow CQS and if so is it preferable to use it in this case?


How are software tests done at tech startups?

I've seen a lot research articles and tech blogs that boast the benefits of software testing. I've convinced on that. But since all the software testing research are conducted by large software companies, I do not believe they really apply to startups. Since startups have different needs and constraints compared to large software companies. So this raised the questions. Should tech startups write automated tests? If so, are they done in the same manner as the large software companies? (smoke test, regression test, etc.) It's best if you can refer some research articles on this subject..since I was unable to find any on my own. (I must admit that even though I'm still early in my career, but I have yet to see a startup that's seriously committed to writing automated tests)


Why was Tanenbaum wrong in the Tanenbaum-Torvalds debates?

I was recently assigned reading from the Tanenbaum-Torvalds debates in my OS class. In the debates, Tanenbaum makes some predictions:   1. Microkernels are the future   2. x86 will die out and RISC architectures will dominate the market   3. (5 years from then) everyone will be running a free GNU OS I was a one year old when the debates happened, so I lack historical intuition. Why have these predictions not panned out? It seems to me, that from Tanenbaum's perspective, they're pretty reasonable predictions of the future. What happened so that they didn't come to pass?


Do I need an IDE to develop Android apps?

After reading some articles on Google, I decided to start working on Android apps since it's an open source platform from Google. So I wanted to create some apps.I have Android 2.2 Os So I just googled it to find the things and I finally found this link to create Android apps. Is this the link that enables me to create apps or does we need any other IDE? Like we have gcc for c and VC++ for C++. What other things to do I need to set up to get going on this?


Want to create a simple gui app using C++ but dont know what to use

I have learned C++ to an intermediate point and now I'd like to create something beyond a console program. I would like to create a simple program that grabs info from specific text files and displays it in a GUI. Just simple statistics. Nothing complex like a spreadsheet or anything. I also know batch, and could use that for the none gui things, as I can put script together in much quicker speeds than writing C++. I don't have any issue having the batch scripts running in the background while the GUI opens, or is running. I have QT but learning it seems to be intimidating. What I'd like to do are simple things, like grabbign info from external files, but that seems to be difficult in Qt. I understand events signals and slots, but the Qt library is overwhelming and it seems like I need to learn everything I learned to create a C console app, all over again. And I don't want to do that. I also have Visual Studio 2012. Should I use that instead? What are my options here to create a simple GUI program with C++? I'm sick of just creating console apps. Thanks.


Understanding parameters

I have read this statement: "A parameter is used as a sort of temporary messenger, carrying data originating from outside the constructor or method and making it available inside it." So, does that mean that values of parameters are stored at first in the constructors and then passed to fields? I still didn't understand the meaning of that. Any good explanation?


Approach to algorithm for assignment of resources

We have a requirement to be able to match people with locations based on availability and certain conditions. Let's say I have a group of people each with 3 types of things they may need to park. A car, a truck and a boat. Each person also indicates their preferred parking location (choices 1, 2 and 3). I also have a list of parking locations which can handle a certain number of each of those things. The goal is to match everyone up so that we maximum usage. The main requirement is that each individual person has to be able to park everything in the same location OR they don't get to park at all. Example:   Starting with the parking locations I have:               Lot    Cars    Trucks    Boats     A       2       0         2     B       2       1         3     C       0       5         0      For people I have:               Person    Cars    Trucks    Boats    Choice 1  Choice 2  Choice 3     Tom        2       1         0         A         B         C     Betty      1       0         1         B         C         A     Sam        0       2         0         C         A         B     Pat        3       2         1         A         C         B      My initial thought is to simply sort the people by the number of items they have (largest to smallest). Then attempt to place each one based on choice. IE: I'd try to place Pat first (most items), but couldn't because no lot meets the requirements. Then I'd try Tom, who would go into Lot B. Etc. Do you know of any issues with that approach? Bonus points: is there a name for this type of problem?


Evolution of an Application: how to manage and improve core engine?

The web application I work on has been live for a year now, but it's time for it to evolve and one of the ways in which it is evolving is into a multi-brand application - in this case several different companies using the application, different templates/content and some slight business logic changes between them. The problem I'm facing is implementing a best practice across the site where there are differences in business logic for each brand. These will mostly be very superficial, using a an alternative mailing list provider or capturing some extra data in a form. I don't want to have if(brand === x) { ... } else { ... } all over the site especially as most of what needs to be changed can be handled with extending the existing class. I've thought of several methods that could be used to instantiate the correct class, but I'm just not sure which is going to be best especially as some seem to lead to duplication of more code than should be necessary. Here's what I've considered: 1) Use a Static Loader similar to Zend_Loader which can take the class being requested, and has knowledge of the Brand and can then return the correct object.               $class = App_Loader::getObject('User', $brand);      2) Factory classes. We use these in the application already for Products but we could utilise them here also to provide a transparent interface to the class. 3) Routing the page request to a specific brand controller. This however seems like it would duplicate a lot of code/logic. Is there a pattern or something else I should be considering to solve this problem? 4) How to manage a growing project that has multiple custom instances in production? _Update_ This is a PHP application so the decisions on which class to load are made per request. There could be upwards of 100+ different 'brands' running.


Best Practices To Build a Product Registration System?

What are some practices I should use in a product registration system I'm building? I likely can't stop all malicious hacking, but I'd like to slow them down a great deal. (Note, I know only PHP.) I'm talking about things like encrypting traffic, testing the encryption from hacking like a man-in-the- middle attack, etc. The other concern I have is that this needs to work on most PHP5-based web hosting environments, which may not have mcrypt installed.


What are graph datastores better at doing than other datastores and why?

Where previously there was only relational databases, the data store world is now rife with options like Key-Value, Document, and Graph datastores. Unfortunately, every datastore likes to show how it can be used for _anything_ , but none of them really help people figure out when to use one model over another. So, the question is: **What "things" are graph datastores better at than relational datastores?** (ie. faster, simpler, more flexible, more powerful) **What makes them better at doing those things?**


What is the best approach to storing a multi-dimensional array with unknown bounds?

I'm trying to store content scraped from several lyric and chord websites into separate variables into either a multi-dimensional array, or into separate string arrays, but I've been stuck trying some different approaches. I've searched through the site and have found many questions that were similar, though incompatible or difficult to adapt with my project. If content was stored in a multi-dimensional array, it would look like this: _Search Site > Artist > Link to artist page > Song > Link to song page > Tab types (Chords, Lyrics, Tabs) > Link to tab type (Chords, Lyrics, Tabs) > Content_ A good visual representation of this array would look like this: http://i.stack.imgur.com/GrATD.jpg Keep in mind the content is **dynamic** , so it is not possible for me to hard-code array bounds without first retrieving the size of the content I'm storing (e.g. amount of songs per artist) Below are the approaches I've tried and their shortcomings, or where I failed to implement correctly: _Multi-dimensional (jagged) arrays_ required explicit bounds, and only the rightmost array can be resized. (This approach can be made to work by setting explicit bounds after all content has been captured, but creating temporary variables and passing them all to the multi-dimensional array requires a lot of code and seems like a "dirty" solution to my problem.) _Tuples_ seemed promising, but for some reason, I was not able to create a tuple containing different variable types, or the approach was confusing. _Individual arrays_ did not give me enough flexibility and required creating multiple new arrays dynamically. (e.g. an array for the list of songs for a specific artist, another for the tab links in a specific song, etc.) I'm sure I've tried others, but I cannot remember at the moment, I've seen a similar approach done with **_Structures_** on a sample for a user control here and others who implemented a local database to contain all the elements. All that is needed is an approach that is simplistic but functional. Any help is gladly appreciated. Another representation here: ![representation](http://i.stack.imgur.com/h65Hf.jpg)


Is it a good idea to "#define me (*this)"?

This macro can be defined in some global header, or better, as a compiler command line parameter:               #define me (*this)      And some usage example: **some_header.h:**               inline void Update()     {         /* ... */     }      **main.cpp:**               #include "some_header.h"          class A {     public:         void SetX(int x)         {             me.x = x;                me.Update();          }              void SomeOtherFunction()         {             ::Update();         }              /*             100 or more lines             ...          */              void Update()         {             // ...          }              int x;       };      So in a class method when I access a class member, I am always using `me`, and when accessing a global identifier I always use `::`. This gives the reader which is not familiar with the code (probably myself after a few months) localized information of what is accessed without the need to look somewhere else. I want to define `me` because I find using `this->` everywhere too noisy and ugly. But can `#define me (*this)` be considered a good C++ practice? Are there some practical problematic points with the `me` macro? And if you as C++ programmer will be the reader of some code using the `me` macro, would you like it or not? **Edit:** Because many people arguing not specificaly contra using `me`, but generaly contra explicit this. I think it may not be clear what are benefits of "explicit this everywhere". **What are benefits of "explicit this everywhere"?**   * As a reader of the code you have certainty what is accessed and you can concentrate on different things than verify - in some distant code - that is really accessed what you think is accessed.    * You can use search function more specifically. Search "`this->x`" can give you more wanted results than only search "`x`"   * When you are deleting or renaming some member, compiler reliably notifies you at places where is this member used. (Some global function can have same name and exist chance you can introduce error if you are not using explicit this).   * When you are refactoring code and making non-member function from member (to make better encapsulation) explicit this shows you place which you must edit and you can easily replace this with pointer to instance of class given as non-member function parameter    * Generally when you are changing code, there are more posibilities to errors when you are not using explicit this than when you are use explicit this everywhere.    * Explicit this is less noisy than explicit „m_“ when you are acessing member from outside (`object.member` vs `object.m_member`) (thanks to @Kaz to spot this point)   * Explicit this solves problem universaly for all members – attributes and methods, whereas „m_“ or other prefix is practicaly usable only for attributes. I would like to polish and extend this list, tell me if you know about other advantages and use cases for **explicit this everywhere**.


Algorithms for data structures in distributed system

The hash table data structure can be easily spread across multiple machines with a simple algorithm to distribute the keys:               machine_to_query = item_key % machine_count      When you want to read and write key value pairs, you use the key to work out which machine stores the data, then you talk to that machine. If you want a count of the total number of items, you'd need to request the count from each server and add them up. What algorithms exist for efficiently managing data structures where the data is partitioned across multiple machines? Distributed algorithms, not parallel algorithms. How might something like a sorted array work in a distributed fashion? Efficiently.


Socket connection to external IP through server

I am working on an application using sockets. Essentially I want to stream data between two clients. Since I can't connect the two clients together directly (they aren't on the same network), I will need to connect the two through a server. ![enter image description here](http://i.stack.imgur.com/gLpR0.png) My client-side is written in Java but the server-side could be written in any language. I have already explored using socket.io etc. but the issue I ran in to is that Java doesn't have a nice websocket solution. What other options are there out there to achieve the same effect? The solution I have in mind right now is basically "forwarding" the stream from one client to the other through the server, but there could be a better way out there...


Big switching from one platform to another

As an example I want to switch from C#/.NET to Scala/Jvm. I'm working as a self-employed and I'm free to choose my favorite language/platform. Having more than 8 years of experience in C#/.NET leads me to have lots of reusable codes, libraries and framework. I can work on my projects and ideas without thinking about language so I'm focused on what I'm doing. Why should I do such migration? Because;   * Scala is open-source and innovative   * Scala runs on JVM which is cross-platform that decreases costs and some risks   * Scala has all C# feature (with something more)   * Benefit of Java comminuty   * More open-source libraries in Java platform   * Doing open-source in .NET is a little harder and doesn't get attention as it does in Java or other plaforms. Is it OK to manage such a big risk and learn a new language/platform (in this case, Scala, Play framework, etc.) and use it in at least a small commercial project to find out if it's suitable?