Looking for monotonically increasing (integer) hash function

I'm looking for a `HashFunction(X,Y: Integer): Integer` that is monotonically increasing on X, then Y. So:   HashFunction(x1,y1) > HashFunction(x2,y2) if x1>x2   HashFunction(x,y1) > HashFunction(x,y2) if y1>y2 Does such an animal exist? Background: This question arises from a comment on   How to create single integer index value based on two integers where first is unlimited?


Why the overhead when allocating objects/arrays in Java?

How many bytes an array occupies in Java? Assume It's a 64bit machine and also assume there are N elements in an array, so all these elements would take up 2*N, 4*N or 8*N bytes for different types of array. And a lecture in Coursera says that it would occupy 2*N+24, 4*N+24 or 8*N+24 bytes for a N element array and the 24 bytes is called overhead, but didn't explain why the overhead is needed. Also objects have overheads, which is 16 bytes. What exactly are these overheads? What are these 24/16 bytes composed of? Also, do these overheads only exist in Java? How about C, C++ and Python?


How to refactor while keeping accuracy and redundancy?

Before I ask this question I will preface it with our environment. My team consists of 3 programmers working on multiple different projects. Due to this, our use of testing is mostly limited to very general black box testing. Take the following assumptions also:   * Unit Tests will eventually be written but I'm under **_strict orders to refactor first_**   * Ignore common **Test-Driven Development** techniques when given this environment, my time is limited.   * I understand that if this were done **_correctly_** , our team would actually **_save_** money in the long-term by building Unit-Tests before hand. I'm about to refactor a fairly large portion of the code that is critical. While I believe my code will accurately work when done and after our black box testing, I realize that there will be new data that the new code might not be able to handle. What I wanted to know is how to keep old code that functions 98% of the time so that we can call those subroutines in case the new code doesn't work properly. Right now I'm thinking of separating the old code in a separate class file and adding a variable to our config that will tell the program which code to use. Is there a better way to handle this? NOTE: We do use revision control and we have archived builds so the client could always revert to a previous build, but I would like to see if there is a decent way of doing this besides reverting. I want this so they can use the other new functionality delivered in the new build. Edit: While I agree I will need to write Unit Tests for this, I don't believe I will capture everything with them. I'm looking for ways to easily be able to revert to the old, functional code should anything happen. While I know this is a poor practice, I'm planning on removing this code after our team can guarantee that the new code works to the same standards as the old.


Multiple classes in a single .cs file - good or bad?

Is it advisable to create multiple classes within a .cs file or should each .cs file have an individual class? For example:               public class Items     {         public class Animal         {         }              public class Person         {         }              public class Object         {         }     }      Dodging the fact for a minute that this is a poor example of good architecture, is having more than a single class in a .cs file a code smell?


What's a good "toolset" of languages, frameworks, and anything else I need as an entry developer?

I'm a student of computer science but I am only taking entry level web development classes. I'm looking for some out-of-class reading, tutorials, and other ways of learning but I'm not sure what I should start in. What is a good set of programming languages (different paradigms?), frameworks, suggested projects, and maybe even some open-source communities that I should start to look at and start learning? Also, maybe even some books or blogs on development processes in the professional world. I'm looking to start getting in to professional development around the end of college. I understand practicing it will be the best way to learn anything but if I don't know what I should practice, I'm lost at that. :)


The project is almost complete, what can I do to retain interest and not lose focus?

So I find every project I get involved in, the start is great and I am all gun-ho lets do some coding. Next thing you know, the project is nearing completion, we are refining, testing, revising, waxing the car if you will and I just cannot retain focus. I get to this point and I cannot stop thinking about how to maintain and get the job done. Any comments on how to retain focus as project nears end and you cannot wait for next project?


Are #regions an antipattern or code smell?

In C# code it allows the #region/#endregion keywords to made areas of code collapsible in the editor. Whenever I am doing this though I find it is to hide large chunks of code that could probably be refactored into other classes or methods. For example I have seen methods that contain 500 lines of code with 3 or 4 regions just to make it manageable. So is judicious use of regions a sign of trouble? It seems to be to me.


Do you store mysql exports in your version control tool for reverting to in event of error?

We run an internal web server with in-house software to run a manufacturing line. When new product features are to be added, either or both of the following occur:   1. changes to the in-house server software may be required to support these - these are for significant changes in functionality, being code drive.   2. changes to the MySQL database for new entries for the part numbers, these are for smaller changes, configurations, changes to already existing values and parameters -- such changes don't require code changes. Ideally we'd want our changes to be here rather than in item 1. Item 1 is version controlled in Subversion, so previous revisions can be referred to for rolling back to in the event of problems introduced in the latest revision. But what about changes to the MySQL database? We have quality processes to ensure that such changes are error-free but there is always a chance that errors can pass through, e.g. mistake in data entry or faults with the code that uses the MySQL corrupting the database etc. We have a automated backup every 6 hours but what if we want more manual defined checkpoints in between these intervals, we could use the same backup system but I wondered if folks here used other methods to store previous states of databases, e.g. exporting the database as a plain text SQL dump -- at least with this method it would be possible to see diffs e.g. in Beyond Compare for trouble shooting. Thoughts?


In DOM, why is childNodes defined in the Node interface if only some node types can have childNodes?

In DOM, why is `childNodes` defined in the `Node` interface if only some node types such as `Element`, `Document` and `DocumentFragement`, can have `childNodes`? Is this considered a good design? In what cases this is admissible? I mean, isn't this like defining a **radius** on an interface Shape even though we know that not every Shape has a radius?


Naming functions that retrieve a value

I have this personal rule to start all function/method names with a verb. My verb of choice for functions or methods that get a value based on some data structure or object is _get_. I'm wondering if that's a good idea. The good thing about _get_ is that it doesn't really say anything about _how_ that value is being retrieved, just get it. Something like _calculate_ (apart from being awfully long) may be too much information. This applies to both functions and methods, i.e.:               float get_magnitude(Vector2d vector)     {         return sqrt(pow(vector.x, 2), pow(vector.y, 2));     }      or               float Vector2d::get_magnitude() const     {         return sqrt(pow(x, 2), pow(y, 2));     }      On the other hand, I sometimes end up with getter methods for read-only properties. It may make sense to use a more meaningful verb for anything that doesn't just return some property, and may not run in linear time. Is there a case to be made for either approach or is it just a matter of taste?


Is it a good idea to put declaration of protocols for delegates in a private category interface?

I have a View Controller or a View that implements `delegate` and `dataSource` methods of `UITableView`. These methods are not going to be used outside this class. So is it a good idea to make the declaration of the `UITableViewDataSource` and `UITableViewDelegate` inside the .m file with a private category? _For example_ : Instead of doing this: **MyViewController.h**               @interface MyViewController:UIViewController<UITableViewDataSource,UITableViewDelegate>     {}     @end      I put the declaration in the private category inside as there is no need for other objects to know whether my View Controller uses a TableView or not. **MyViewController.m**               @interface MyViewController()<UITableViewDataSource,UITableViewDelegate>     @end      and Implementation in the .m file being the same in both the cases.


Is having your own website important?

How necessary or important is it? I try to keep a running list of blogs or sites to follow, but a lot of the time I pull up someone's profile and notice _there isn't anything there_. Is it really important? I understand are different levels of programming (from C/C++ system programmers to Rails and even Haskell and J) and not everyone works in a language easily worked with for web based applications. Not everything is web- centric, however with the advent of _many_ popular and sometimes free services I don't think it's unreasonable to expect a majority of programmers to have a personal site.


If you need more than 3 levels of indentation, you're screwed?

Per the Linux kernel coding style document: > The answer to that is that if you need more than 3 levels of indentation, > you're screwed anyway, and should fix your program. What can I deduce from this quote? On top of the fact that too long methods are hard to maintain, are they hard or impossible to optimize for the compiler? I don't really understand if this quote encourages better coding practice or is really a mathematical / algorithmic sort of truth. I also read in some C++ optimizing guide that "dividing up a program into more functions improves its design" is frequently taught in CS courses, but it should be not done too much, since it can turn into a lot of JMP calls (even if the compiler can inline some methods by itself).


Can it be useful to build an application starting with the GUI?

The trend in application design and development seems to be starting with the "guts": the domain, then data access, then infrastructure, etc. The GUI seems to usually come later in the process. I wonder if it could ever be useful to build the GUI first... My rationale is that by building at least a prototype GUI, you gain a better idea of what needs to happen behind the scenes, and so are in a better position to start work on the domain and supporting code. I can see an issue with this practice in that if the supporting code is not yet written, there won't be much for the GUI layer to actually do. Perhaps building mock objects or throwaway classes (somewhat like is done in unit testing) would provide just enough of a foundation to build the GUI on initially. Might this be a feasible idea for a real project? Maybe we could add GDD (GUI Driven Development) to the acronym stable...


Role of linking, object files and executables

1. For a C or assembly program that does not require any other library, will linking be necessary? In other words, will conversion from C to Assembly and/or from Assembly to an object file be enough without being followed by linking?  If linking is still needed, what will it do, given that there is just one object file which doesn't need a library to link to?   2. Relatedly, how different are object files and executable files, given that in Linux, both have file format ELF?  Are object files those ELF files that are not runnable? Are there some executable files that can be linked to object files? If yes, does it mean dynamical linking of executables to shared libraries?


What are the best tactics for practicing touch typing?

I've been practicing typing over the past little while, and I'm wondering if there's any tricks to getting further. I started out at ~40 wpm back when I was typing with 6 fingers. It took a little while to learn to use 10 (about a week or so where I was at the ~20 wpm range), but I improved quickly, and I'm now typing at ~65 wpm. That's pretty good, but I seem to have hit a wall there (going from ~40 to ~20 and back up to ~65 took about 3 months of on-and-off practice, but this was 5 months ago and I haven't improved at all since then in terms of accuracy or speed). So far I've been using Klavaro exclusively. Is there anything special you have to practice in order to get into the 80-90wpm range, are there any specific tools I'd need, or does it just take longer to improve at that level? (I'm using a qwerty keyboard, and I don't want to switch to dvorak, but I think I should still be able to crack 80wpm, at least).


If you spot a software bug and fix it, do you tell the client?

I spotted a bug today in a web application that I develop and maintain for a client. I let the client know that I had spotted a problem and after a short time I fixed it and reported back the full details to them. In cases like these do you always tell your client? Even though it would be possible to fix the problem and tell no one?


Encompassing term for software and data in a system

I am writing up a description/guide/wiki of an "open source software framework for the easy integration and utilization of datasets, algorithms, tools, and computing resources". I feel like software integration framework sounds concise and to the point, but I want to emphasize that it can also independently integrate and process standalone data (i.e. data meaning something like columns of numbers in a text file, even if that particular example isn't technically correct). Also might as well take the chance to learn some new software development nomenclature. So I ask - is there some term that encompasses both data and software in software architecture?


How do I completely-self-study Computer Science?

Being a completely self taught programmer, I would like it if I could better myself by self-learning the computer science course taught to a typical CS grad. Finding different resources on internet has been easy, there is of course **MIT open course ware** , and there are Coursera courses from Stanford and other universities. There are numerous other open resources scattered around the Internet and some good books that are repeatedly recommended. I have been learning a lot, but my study is heavily fragmented, which really bugs me. I would love If somewhere, I could find a path I should follow and a stack I should limit myself to, so that I can be sure about what **_essential_** parts of computer science I have studied, and then systematically approach those I haven't. The problem with Wikipedia is it doesn't tell you what's essential but insists on being a complete reference. **MIT open course ware** for Computer science and Electrical Engg. has a huge list of courses also not telling you what courses are essential and what optional as per person's interest/requirement. I found no mention of an order in which one should study different subjects. What I would love is to create a list that I can follow, like this dummy one               SUBJECTS                                                        DONE          Introduction to Computer Science                                  *     Introduction to Algorithms                                        *     Discrete Mathematics                        Adv. Discrete Mathematics     Data structures                                                   *     Adv. Algorithms     ...      As you can clearly see, I have little idea of what specific subjects computer science consists of. It would be hugely helpful, even if someone pointed out essential courses from MIT Course ware ( + essential subjects not present at MIT OCW) in a recommended order of study. I'll list the Posts I already went through (and I didn't get what I was looking for there) Computer science curriculum for non-CS major? \- top answer says it isn't worth studying cse How can a self-taught programmer learn more about Computer Science? \- points to MIT OCW Studying computer science - what am I getting myself into? Overview of computer science, programming


My Cassandra consultant left me and now I'm thinking about reverting to mysql

I run a middle size community and some time ago I started to develop social capabilities such as follow, status update, wall etc. For some reason i thought that Cassandra was the right tool for the job so I looked online for a Cassandra developer and I found a very talented one. Unluckily in the midst of the development the dev left (too much jobs) and so I'm here with a very nice class, a very nice demo, but a lot of fears that I won't be able to handle basic things such as compaction, scaling etc. My biggest fear is to go online with all this coolness and then having a site inaccessible for hours or days. The mysql consultant (very talented too) keeps saying me that I should stick with Mysql which I know rather well and in case something's wrong we can manage. In that case I should take the class made for cassandra and abstract it for Mysql. My question is this: Should I find another dev/consultant and stick with Cassandra because for social things it is definitely the best tool for the job, or should I listen to the Mysql consultant and revert to Mysql? About 15k login each day Average 20 actions per user Avg 6 followers x user (These are current statistics, but of course I'd like to increase them as much as possible.)


Piece of code for interview debugging abilities test?

May be someone has a piece of code, that would work as a test for debugging abilities? We will give ability to use Visual Studio, so it should be hardly solvable by doing manual tracing and show us, that candidate is really good at debugging.


What things should be considered in the license etc when you're using some open source projects/ tools in your application

**What things should be considered in the license etc when you're using some open source projects/ tools** in your application(in my case, specifically a web application/website) ? What are the terms & conditions to look for in the license and in what ways can they impact my future business in technological, financial or any other domains ? In my case I am using several open source tools like some of the Google open source products, some from Apache and several others like that.


How to build a good service layer in ASP.NET?

I have looked through some questions, technologies for building a good service layer but I have some questions regarding this that I need help with. First some information of what I have for requirements. We currently have a number of web applications that talk to each other in a spiderweb looking way (all talking to each other in a confusing way via webservices and database data).   * We want to change this so that all applications go through a service layer where we can work more with cache and encapsulate common functionality and more.    * We want this layer to also have a Web API so that 3rd party clients can consume information from the service.  The problem I see is that if we build the service layer with say MVC4 Web API don't we need to communicate between the application using the webAPI meaning we have to construct URLs and consume JSON/Xml. That does not sound too effective. I assume a better method would be working with entities and WCF to communicate between the application but then we might loose the Web API magic? So the question is if there is a way to consume a service layer as both a Web API (JSON/XML) and as a more backend service layer with entities. If we are forced to use 2 different service layers we might have to duplicate some functionality and other bad things. Hope the question is clear enough and please ask if you need any more information.


When should I use the XML data type in SQL Server?

When should I use the XML data type in Microsoft SQL Server?


Build number when supporting previous version

I am developing and maintaining a web-based application that's used internally at my job. I am the only developer and so I'm not really using branches; everything happens on the trunk. I do tag releases in Git with the date and time, and I'm starting to transition to using a build number instead of date/time. In the production instance of the app (which is just a tag on the trunk), a bug has been discovered that needs to be fixed ASAP. In the meantime, I've been developing new features, but they're not ready to be distributed. Fixing the bug is easy: check out the tag into a new branch, fix, publish. However, in such a situation, **what should the fix's build number be**? If I follow the existing build strategy of incrementing a serial number, my build numbers will be, e.g.               1234: production     1235: development (with new features)     1236: production fix (doesn't have new features)      which doesn't seem to make sense. Alternately, incrementing the production tag's build number would lead to, e.g.               1234: production     1235: development (new features)     1235: production fix      which defeats the purpose of build numbers (uniquely identify a particular build). Using Git's revision ID is another option, but they're not exactly readable.


What would you change about Java if you have a chance?

After reading this post about C#, it is very interesting to hear what you consider wrong with Java and what would you like to change? I bet on "call to super|this must be first statement in constructor".


Best way to work easily with a database in remote programs?

In Database 101 you learned never to distribute the sensitive database password along with your program, since all a person has to do is reverse engineer the program, find where you actually need the original password for authentication, then echo/print that line. However when you have multiple remote programs that need to talk to a central database, what do you do? My hackish solutions used to involve PHP, tons of `GET` variables, and JSON. I would make a request to the server with a set mode and parameters, then parse the JSON output. It was buggy, not entirely secure (only slowed an attacker down) since I didn't have any registration mechanism, hard to scale, and made all existing ORM's useless. Besides, it was attempting to reinvent SSH or SSL, not something that's too terribly smart. What's the alternative though? What other options are out there that can provide security for the database while making it easy on me?


Is How the Company Makes Its Money One of The Most Important Determining Factors in their work environment, culture, etc

This is a viewpoint I've started to realize recently about some companies that I have worked for. They had their own software product that they developed in- house but most of the focus was on building an in-person sales team to push their product to businesses throughout the country. I figure that companies that are exclusively "online", meaning that their revenue source comes from online transactions where there is no "face" of the company to the customer would have a different work culture. Just curious if anyone has worked for both types of companies and notices a difference. I myself am hoping to get more into contract programming and figure that companies that don't have to employ a sales-force and things like that would be more focused on technology and maybe even willing to be flexible on partial telecommute, etc


Best way to transport response data from an AJAX request?

Some possibilities are JSON, XML, HTML and/or Javascript fragments. The democratic answer to this question is "it depends on the situation," but I am looking for why one may be better than the others.


does class reference itself static anti pattern in prism

I have an application and my desing approach look like this:               class Manager     {         public int State;              static Manager _instance = null;         public static Manager Instance         {             get { return _instance; }             set             {                 if (_instance == value)                     return;                 _instance = value;             }         }              public Manager()         {             State = 0;             Instance=this;         }     }     class Module1     {         public void GetState()         {             Console.WriteLine(Manager.Instance.State);         }     }     class Module2     {         public void GetState()         {             Console.WriteLine(Manager.Instance.State);         }     }     class Module3     {         public void GetState()         {             Console.WriteLine(Manager.Instance.State);         }     }      Manager class already registered in Bootstrapper like :                protected override void ConfigureContainer()      {            base.ConfigureContainer();            Container.RegisterType<Manager>(new ContainerControlledLifetimeManager());      }      protected override void InitializeModules()      {           Manager man= Container.Resolve<Manager>();      }      Question is do I need to define my manager object as static in its field to be able to reach its state? Or this is anti pattern or bad for performance?


How to deal with project managers who micromanage?

Perhaps I'm just naive, but when I try to decipher the wall of tasks I'm targeted to do over the course of a week, I just can't help but think whoever builds the project schedule needs to get some remedial training on basic project management. For example, I am assigned 13 tasks today, the shortest lasting .13 days (default time metric in Microsoft Project), and the longest lasting .75 days. I can't help but think that it is blatant micromanagement scheduling projects in sub 10 minute intervals. The effects of management are becoming evident in slipped tasks, resource assignment exceeding capacity by a factor of two at some points in time, and spending more time clearing tasks and figuring out what comes next than actually doing work. How can I convince the project manager to create tasks with larger duration and to see the larger picture? ![Micromanagement == insane schedules?](http://i.stack.imgur.com/pV1TT.jpg)


Word for author, of an add, edit, or delete?

Supposing I have an SQL table named `websiteArticle` containing articles filed by date under various categories. It has field names `id`, `category`, `date`, `subject`, `body`. As a matter of best practice, I also include `created` which is automatically filled in by the database with the date/time the article was inserted into the table. Also I include in `modified` (date/time) and `modifiedBy` (the `id` from `websiteUser`) which are filled in by the application. I like that, except that sometimes I also have a field for `deleted` which is a date/time that is filled in rather than deleting the record entirely. For brevity I don't want a separate `deletedBy` field. Also it is not needed since we do have a more detailed log in place. However, I do want to log the user who deleted it for convenience, overwriting the reference to the user who modified it. I could replace `modifiedBy` with `user` and update it in whenever the record is `created`, `modified` or `deleted`. Unfortunately `user` is ambiguous, as it could be the assigned `user`, and the record could have been modified by a different `user`. So I have date/time fields `created`, `modified`, `deleted`. I'm wondering what would be the appropriate field name for the user responsible for the same. Something like `author`, except that seems to only apply to `created`. Is there a less ambiguous word that works for all three? I searched the dictionary but didn't turn up any better results.


**From** http://stackoverflow.com/questions/4544588/difference-between-iphone- simulator-and-android-emulator The difference between emulators and simulators is that emulators mimic the software and hardware environments found on actual devices. Simulators, on the other hand, only mimic the software environment; they otherwise have access to all of the host system's hardware resources such as disk space, memory and processor speed. Apple always harps on the importance of device testing because iPhone Simulator does not emulate an iPhone processor, disk drive, memory constraints and whatnot. You hardly ever get memory warnings unless your Mac is struggling to manage resources itself, unless you simulate (again) memory warnings from the Simulator's menu item. Though android emulator emulates the ARM processors and certain hardware, it still doesn't do a good job of matching the CPU performance. Being an emulator it can match Memory consumption well, it can emulate certain simple devices well but fails when the devices gets complicated for example mobile GPU and HW media decoders. And as the emulation logic works on translating each ARM instruction to X86 instruction and executing its a performance hog and by design not cycle accurate. **My Question:** Why Android created emulator rather simulator?


How do I convince my boss (and other devs) to use/consider Unobtrusive JavaScript

I'm pretty new in our develepors team. I need some strong arguments and/or "pitfall" examples, so my boss will finally understand the advantages of Unobtrusive JavaScript, so that he, and the rest of the team, stops doing things like this:               <input type="button" class="bow-chicka-wow-wow"             onclick="send_some_ajax(); return false;" value="click me..." />      and               <script type="text/javascript">          function send_some_ajax()     {       // bunch of code ... BUT using jQuery !!!     }     </script>      I suggested using a pretty common pattern:               <button id="ajaxer" type="button">click me...</button>      and               <script type="text/javascript">          // since #ajaxer is also delivered via ajax, I bind events to document      //  -> not the best practice but it's not the point....          $(document).on('click', '#ajaxer', function(ev) {     var $elem = $(this);     ev.preventDefault();          });      The reason why my boss (and others) do not want to use this approach is that the Event-Inspection in FireBug (or Chrome Dev Tools) isn't simple anymore, e.g. with               <input type="text" name="somename" id="someid" onchange="performChange()">      he can immediately see what function executes on change-event and jump right to it in a **_huge JS file full of spaghetti-code_**. In the case of Unobtrusive JavaScript the only thing he would see is:               <input type="text" name="somename" id="someid" />      and he has no idea whether some events, if any, were bound to this element and which function will be triggered. I was looking for a solution and found it:               $(document).data('events') // or .. $(document).data('events').click      but, this "approach" caused it to take "too long ..." to find out which function fires on which event, so I was told to stop bind events like that. I'm asking you for some examples or strong advantages or any other kind of suggestions for "Why we should use UJS" **UPDATE:** suggestion to "change the job" is not an ideal solution. **UPDATE 2:** Ok, _I've not only suggested to use jQuery event-binding, **I did so**._ After I wrote all Event-Delegation, the Boss came to me and asked me, why am I doing event delegation with different approach and approach he **_dind't know_** I mentioned some obvious benefits, like - There are 15 input-fields and all of then have an `onchange` event (not only, some of them have also `onkeyup`) So it's more pragmatic to write this kind of event-delegation ones for ALL input- fields, instead of doing it 15 times, especially if all of the HTML will be rendered with PHP's echo -> `echo '... <input type="text" id="someid" ... />...'`


What's the opposite colour to "green" for a native thread?

Simulated threads are known as "green threads" in programming-language-wonk speak. They are compared to "native threads" as provided by the operating system, but is there an analogous colour for native threads, and what is it?


How to significantly improve Java performance?

The team over at LMAX have a presentation about how they were able to do 100k TPS at less than 1 ms of latency. They have backed up that presentation with a blog, technical paper (PDF) and the source code itself. Recently, Martin Fowler published an excellent paper on the LMAX architecture and mentions that they are now able to handle six million orders per second and highlights a few of the steps that the team took to go up another order of magnitude in performance. > So far I've explained that the key to the speed of the Business Logic > Processor is doing everything sequentially, in-memory. Just doing this (and > nothing really stupid) allows developers to write code that can process 10K > TPS. > > They then found that concentrating on the simple elements of good code could > bring this up into the 100K TPS range. This just needs well-factored code > and small methods - essentially this allows Hotspot to do a better job of > optimizing and for CPUs to be more efficient in caching the code as it's > running. > > It took a bit more cleverness to go up another order of magnitude. There are > several things that the LMAX team found helpful to get there. One was to > write custom implementations of the Java collections that were designed to > be cache-friendly and careful with garbage. > > Another technique to reach that top level of performance is putting > attention into performance testing. I've long noticed that people talk a lot > about techniques to improve performance, but the one thing that really makes > a difference is to test it Fowler mentioned that there are several things that were found, but he only mentioned a couple. Are there other architectures, libraries, techniques or "things" that are helpful to reach such levels of performance?


Best method to implement a filtered search

I would like to ask you, your opinion when it comes to implement a filtered search form. Let's imagine the following case:   * 1 Big table with lots of columns   * It might be important to say that this SQL Server You need to implement a form to search data in this table, and in this form you'll have several check boxes that allow you to costumize this search. Now my question here is which one of the following should be the best way to implement the search?   1. Create a stored procedure with a query inside. This stored procedure will check if the parameters are given by the application and in the case they are not given a wildcard will be putted in the query.   2. Create a dynamic query, that is built accordingly to what is given by the application. I am asking this because I know that SQL Server creates an execution plan when the stored procedure is created, in order to optimize its performance, however by creating a dynamic query inside of the stored procedure will we sacrifice the optimization gained by the execution plan? Please tell me what would be the best approach in your oppinion.


What's the difference between a marshaller and a serializer?

...and unmarshalling/deserializing? Wikipedia's explanation leaves me none- the-wiser! I'm a Java programmer, in case the terminology is used differently in different languages.


Offload traces into shared memory

There is a task to trace thread execution activity for posthumous analysis with minimum impact on latency/performance. Stack trace might be not enough to understand the reason of crash. Initially I was going to allocate some memory block for every thread and put circular buffer into it. So there wouldn’t be any data races and I can read contents of these buffers in core dump. But this is not really convenient first of all because sometimes core dump is not available (process is running on machine which I don’t have much access). Keeping everything the same but logging trace messages into shared memory would be slightly better because those buffers will not be lost with application crash and other application (which reads shared buffers - let’s call it trace-server) can provide access to traces after main application crash. Is it a good idea? Although I think it will work but do you think it's feasible to go into all these troubles? Have you seen anybody doing this?


Identity and Access Control in Web API vs WCF

Our team is looking to introduce Web API, MVC/ASP.NET implementation in our SOA. I am having a hard time trying to wrap my head around the identity and access control it has compared to WCF. WCF has **Windows, X.509, UserName, and WS-Trust** (probably more, but this is what I am familiar with), MVC's Web API seems to only have web application based identity and access control built into it: **Web Forms, Windows, and WS- Federation**. Has anyone made Web APIs using MVC that implements the protocols that WCF has? Should this even be done / am I trying to use Web API in a way it shouldn't be?


Avoiding boilerplate in PHP classes

I am working on a PHP code and as it grows getting more and more tired of repeating the same standard pattern again and again and again:               class BolerPlate     {         protected $property1;         protected $property2;         ...              public function __construct ($property1, $property2, ...)         {             $this->property1 = $property1;             $this->property2 = $property2;             ...         }     }      So I am re-typing here each property name 4 (!) times just to get the standard setup! In each class! It doesn't look elegant nor DRY to me. And re-typing the same names creates more bug opportunities. I wonder if there is any more elegant way or best practices to get the same setup with a code easier on the eyes :) EDIT. What I have in mind is some sort of factory method where I can supply the list of properties only once each. Or using variable variables and iterate over all properties?


Apache-2.0 CLA incompatible with outbound MIT/BSD/GPLv2 license?

A few open source projects currently collect Apache-2.0 Contributor License Agreements, but distribute the software under a license such as MIT, BSD, or GPLv2. According to the following chart (from David Wheeler), these licenses are incompatible with the Apache-2.0 License. ![enter image description here](http://i.stack.imgur.com/DRGMY.png) The FSF explains why Apache-2.0 is incompatible with GPLv2: > Please note that this license is not compatible with GPL version 2, because > it has some requirements that are not in that GPL version. These include > certain patent termination and indemnification provisions. By the same logic, Apache-2.0 is incompatible with permissive licenses such as MIT and BSD, which also lack these patent clauses. The Apache-2.0 CLA is not identical to the Apache-2.0 License, but the patent termination clause appears to be equivalent modulo the roles Contributor->Project versus Project->User. A CLA defines an "inbound" license giving certain permissions to the project. If the CLA terms match the outbound license, then it merely formalizes what Red Hat counsel, Richard Fontana, calls "inbound=outbound". If the CLA grants _more_ privileges to the project than appear in the outbound license (e.g., Apache-2.0 inbound, GPLv3 outbound), then it becomes a "maximalist" CLA, which are considered harmful by folks like Fontana and Bradley Kuhn, due to the asymmetric relationship between project leadership and contributors. But my question is about projects doing the opposite, distributing the software under a license that is _more permissive_ than the CLA. I have been assured that corporate lawyers looked over the CLAs, but I have been unable to get an explanation for why they believe it is okay to combine with the outbound license. **Is anyone aware of a legal theory under which a CLA defining an inbound license that is incompatible with the outbound license would be acceptable?** I think the project may be taking on liability by distributing under terms that they do not have permission for (according to the CLA). Using no CLA at all would be safer for the project due to the "inbound=outbound" convention, which could be made explicit via a DCO.


Best practice for validating XML messages

Two systems are communicating via XML messages on a message queue and any received message must be validated for structure, content and business logic before being processed. An XML schema offers validation on structure and content with data type restriction, required fields, choice structures and the like. But this of course only gets me half way there. In a system I am currently working on, we do the remaining validation by deserializing the message to an object structure and validating context with a dedicated code library. The problem is that first of all the validation is in two different places and it overlaps a bit since some validation can be done in both ways, and secondly maintaining the validation code can become tedious. Is there a better way to do this, any best practices or tools out there?


How often should a manager meet with his subordinate who is a team leader?

Ours is a software concern and we have a team structured like so: manager->team leads->team members. We are following the agile programming model and trying to develop a product in a collaborative fashion. We have daily morning meetings with team members and their team leads to discuss progress and issues. When it comes to TL->Manager, most of the time they do not have items to discuss on a daily basis since TL goals would be for weekly plan and such. Most of the time, we just discuss about resources and it is less technical. I just want suggestions on how the manager & team lead interaction should be and whether the current system we have is fine. Please share your thoughts or ideas.


How do I assess whether my expectations to the interviewees are adequate?

Our company is hiring C++ developers and we have to estimate applicants skills based on resumes and (usually) code samples. I find it problematic to decide whether I'm realistic in my assessments. For example, there was a guy who stated two software development jobs, 5 years of experience total. He claimed that he worked in a project for porting some operating system to new hardware and one of his duties was "fixing bugs in the operating system". Then I open the sample and see the following:                char buffer[someSize];      strncpy( buffer, someString, someSize );      obviously this code will not null-terminate the destination once the string is of length equal to or greater than `someSize` and the program might run into undefined behavior. Now my thought goes like this: "that guy claims he fixed bugs in the operating system code and now he can't properly use a simplest C runtime function... WTF???" and this motivates me to write a feedback to our HR that he can only qualify for a position right above the entry level. What bothers me I can't get rid of a feeling that I'm being too harsh and demanding. How can I decide if my expectations are realistic or not in such situations?


How do you name "javascript:" prefix in inline event handlers?

In the following code:               <a onclick="javascript:alert()">      how do you name the `javascript:` part? Protocol, pseudo-protocol, scheme, label, prefix? I am only trying to figure out a common name for it, not technically correct term based on what it actually is at the end. So when I say for example "javascript protocol" most people would be able understand what I mean. (I need to use this in a documentation)


How to efficiently sort a recursively defined Stack?

I am trying to implement a recursively defined Stack. Is there any efficient method apart from copying the elements from Stack in array, sorting them and again pushing them on stack? (I know C/C++, Java)               //Stack definition:     Stack     {         E element;         Stack topOfSubStack;     }


SEO Friendly URL In Website

I want to develop a website in CodeIgniter framework in which I can access any webpage via slug. For example just like WordPress and Magento we can access category page by `www.sitename.com/category_type/category_detailpage` And also we can access that Category_detail directly just by adding its slug after main URI `www.sitename.com/category_detailpage`. How I have to design schema of slug table in database if you have any case study Project Code for this Slug Directory in CodeIgniter then please let me know. I want to manage whole websites slug in only one table. But I haven't clear idea about how I can manage category / subcategory / detailpage in only one table and then how can I access it using slug only? I wants to make my own custom framework in codeigniter so that I can access any page via slug only whether it's category page subcategory page or any single page. How can I achieve that?


Drag and drop model for modelica

**Is there any way to connect`Modelica` with `JaamSim`?** As I want an open source GUI with drag and drop option for simulation with `Modelica` running in back-end. _I have already tried`SimForge` but there is no drag and drop option in it whereas `JaamSim` has drag and drop option but it doesn't runs Modelica for back-end processing._ I am basically looking for a open source GUI built using JAVA.


objects, classes, types

How does an object oriented programmer understand the word "type"? I'm not aware of there being a type theory for object oriented programming because whenever someone mentions type theory it is always in the context of some kind of functional programming language so what does "type" mean in the object oriented context?


Persisting type in Java - should I be using flags?

Is there some specific piece of advice around persist values that indicate type? Specifically I want to know if I should persist a flag/state indicating the type in persistence or not. I get the feeling I'm forgetting/not understanding some core concept of OO or data modelling. Something that's been on my mind for the last while is to consider when to use flags and when not to, and intermixing this idea of recreating objects of some certain type out of persistence. The reason for my concern over flags is that in the software I often create (in-house created corporate software developed with Java), these flags become pieces of information which are hard to maintain and which subsequent developers need to be aware of in order to maintain them (perhaps creating code bloat). So, when I persist my `foo`, should I persist with it some flag that indicates whether it is a `foobar` or a `foobo`? Is there specific advice about this, some gap in my OO-foo or data modelling that I'm forgetting?


How can a statically typed language support duck typing?

I understand what dynamic and static type systems are, and what duck typing is. But I don't understand how you can have a static language that supports duck typing. To my understanding only a dynamically typed language can support duck typing. This answer from StackOverflow explains that _"Duck typing is something that is completely orthogonal to static, dynamic, weak, or strong typing."_ It gives an example from C++ for duck typing in a statically typed language, but I'm not a C++ programmer and I don't understand it. I'd like an explanation of how it's possible for a static language to support duck typing.


What is the best approach to studying TAOCP

I have a question what is the best way to study 4 volumes of The Art of computer programming and Hacker delight by Henry S. Warren ? Is there any website that focus on study group that uses TAOCP? I am familiar with C/C++. What are the best books to prepare for the TAOCP? And what is the best way to create a Demo portfolio to ensure employers that I am well versed in TAOCP?


Claim based authorization for application framework?

I am developing a framework that makes common data management tasks easier for a couple of future applications built on top of it, including document management, data versioning, retention, locking etc. I am currently using .NET, SQL Server and EF Code First. One of the requirements is the ability to flexibly manage access control to the data. It should be easy to declare rules like > "If a user belongs to a project X, he should be able to access and modify > documents related to this project." During my research I came across **claim based access control** which seems to provide the necessary flexibility. I am a bit stunned however by the apparent complexity and not sure if using this would be overkill.   1. As far as I understand, claim based access control is usually used to retrieve the authorization information from an external provider. Does it still make sense to use this if the application manages the access control itself, i.e. the authorization rules are in the same database as the application data? I feel like setting up an external service just for authorization is definitely overkill for our applications.   2. I have found a lot of examples on how to retrieve the authorization with Windows Identity Framework (WIF), but not many on how to implement the authorization and storing of authorization rules.   How difficult would it be to implement something like this with WIF? Are there already any available providers that already use SQL Server to store the authorization information? Or anything in WIF I can simply extend to make this happen? All I found are examples using the application config file. I hope my questions are not too broad. I am rather new to the whole topic claim based access control and trying to determine if it is applicable for my scenario and if so, where to start. **Update** : I tried to narrow the scope of the question down a bit. If this is still considered too broad, I will split it up further. I think however that both questions are closely related and that it makes sense to ask and answer them together.


What's the best way to review a code before it's committed to the trunk? (SVN)

What's the best way to review a code before it's committed to the SVN trunk? One idea that I am thinking of is to having the developer to commit his code to a branch and then reviewing his code while merging the branch revisions into the trunk. Is this a good practice? If not, what else could be done to review a code before it's committed to the trunk?


How to set-up a simple subversion workflow

I am trying to set-up a simple SVN workflow at home. I am new to subversion (and programming) so I have been reading the official PDF documentations but still not sure about how to set-up my repository. I am working mainly with python, bash and rsl (Renderman Shading Language) So I already have a /dev structure on my disk as this: ![/dev structure](http://i.stack.imgur.com/Zy9no.png)   * http://imageshack.us/f/708/devstructure.png/ And I have a /site structure that links to my /dev folder: ![enter image description here](http://i.stack.imgur.com/i82P0.png)   * http://imageshack.us/f/651/sitestructure.png/ So obviously starting to use SVN will change this approach that I already have in place. The question is when I am setting-up my SVN repository for the work I do in my /dev folder: **Will I set-up a separate repository for each different programming platform?** and **Where exactly I should be placing my repository?** Thanks.


Can publicly accessible code be closed source?

Is it possible, legally, for code to be publicly available online, but have copyright protection?


Play 2 with Scala or Java?

I want to develop a big personal project using Play 2 Framework. I am expert with Java language but it seems, with the few articles I read that Play 2 works perfectly and especially with Scala. I've never worked with Scala but I already learned concept as closures, functional programming etc... Learning it would be interesting. I am really motivated for but I wonder if there are some people who have started coding with Play2/Java and have changed for Play2/Scala that could explain their major concrete advantages.


BSD Software license usage

We are a company and we want to use 30% of the BSD opensource software to plug and play it with our source code, can we do that. Further this program will not be distributed and only will be accessed by our clients using our own software. Is it possible for us to do the above without any restrictions. Kindly give me feedback on the above soon as possible.


What are some non-MS languages that can write xlsx (Excel 2007+) documents efficiently?

Unfortunately, Excel format is required for the project I am working on. I have no problems getting the data I need in objects and arrays, and currently PHPExcel is doing handling the document generation. It works, but it's slow and loopy. Was wondering if there is a more efficient server language to generate Excel documents (not CSVs). This is a pure Linux environment so I need to stay away from .NET. I am open to any programming language that does it cleanly and efficiently.


Interacting with multiple localized webservices

I'm having trouble managing multiple web services that each have a slightly different list of supported languages For example, say we support English, Chinese, and French in our web service using the typical ISO language and country codes and we call out to two different services, **A** and **B**. If someone comes in with a Spanish locale, we fall back to English which is fine and dandy since everyone supports English. However, **A** only supports English and Chinese so when a customer comes in with French, we need to know to fall back to English for that request (while still using French internally). **B** , on the other hand, does support all three but splits Chinese into two: Traditional and Simplified. It would be nice to perform that same split internally (more specific is usually better), but **A** only recognizes the non-split code so we'd have to keep track of both anyway. Right now we have a separate database table with a list of mappings from one combination to the other for each webservice we call, but that's definitely not scalable. Soon we will need to add another mapping table for a service we discovered has weird behavior for Indonesian (instead of falling back to a sane working default, they give us a pretty little 404) and I'd like to see if there's a better strategy out there than multiple mapping tables.


How do you update your production codebase/database schema without causing downtime?

What are some techniques for updating a production server's code base / database schema without causing any downtime?


Best practice to sort then reverse, or write "backwards" comparator?

I wrote a comparator for a custom class of mine and when I ran my code I realised the output of my list of these objects was in the reverse order as to what I wanted. It was "ascending" as opposed to "descending". This was because I stuck to the spec of compare where a return value of less than 0 means the other object is less than this and so on. To fix this I called the reverse method on my list, but I could've also changed the compare method so that it returns greater than 0 where the other object is less than this. What is seen as the standard for this case and why?


Writing a Compiler Compiler - Insight on Use and Features

> This is part of a series of questions which focuses on the sister project to > the Abstraction Project, which aims to abstract the concepts used in > language design in the form of a framework. The sister project is called > OILexer, which aims to construct a parser from grammar files, without the > use of code injection on matches. > > Some other pages associated to these questions, related to structural > typing, can be viewed here, and ease of use, found here. The meta-topic > associated to an inquiry about the framework and the proper place to post > can be found here. I'm getting to the point where I'm about to start extracting the parse tree out of a given grammar, followed by a Recursive Descent parser which uses DFA to discern forward paths (similar to ANTLR 4's LL(*)), so I figured I'd open it up to get insight. ### In a parser compiler, what kinds of features are ideal? So far here is a brief overview of what's implemented:   1. Templates   2. Look ahead prediction, knowing what's valid at a given point.   3. Rule 'Deliteralization' taking the literals within rules and resolving which token they're from.   4. Nondeterministic Automata   5. Deterministic Automata    6. Simple lexical state machine for token recognition   7. Token automation methods:      * Scan - useful for comments: Comment := "/*" Scan("*/");     * Subtract - Useful for Identifiers: Identifier := Subtract(IdentifierBody, Keywords);        * Ensures the identifier doesn't accept keywords.     * Encode - Encodes an automation as a series X count of base N transitions.        * UnicodeEscape := "\\u" BaseEncode(IdentifierCharNoEscape, 16, 4);          * Makes a unicode escape in hexadecimal, with hex 4-transitions. The difference between this and: [0-9A-Fa-f]{4} is the resulted automation with Encode limits the allowed set of hexadecimal values to the scope of IdentifierCharNoEscape. So if you give it \u005c, the encode version will not accept the value. Things like this have a serious caveat: Use sparingly. The resulted automation could be quite complex. What isn't implemented is CST generation, I need to adjust the Deterministic automations to carry over the proper context to get this working. For anyone interested, I've uploaded a pretty printed of the **original form of the T *y♯ project**. Each file should link to every other file, I started to link in the individual rules to follow them, but it would've taken far too long (would've been simpler to automate!) If more context is needed, please post accordingly. **Edit 5-14-2013** : I've written code to create GraphViz graphs for the state machines within a given language. Here is a GraphViz digraph of the AssemblyPart. The members linked in the language description should have a rulename.txt in their relative folder with the digraph for that rule. Some of the language description has changed since I posted the example, this is due to simplifying things about the grammar. Here's an interesting graphviz image.


Separation versus Segregation

The term "segregation" is used in the CQRS pattern. What's the difference between segregation versus separation in this case?


Condition coverage for If(A && B) - measuring the input or code exercised?

I have been studying condition coverage for last few days. In a book "The Art of Software Testing" they highlight that it does not assure decision coverage, because for example > IF(A && B) `A=True, B=false` and `A=False,B=True` satisfies the condition coverage but the decision is always `False`. I wonder, how can this satisfy the coverage? The `True` value of `B` will actually never be tested because of short circuiting so how it can satisfy the coverage?


Naming the project containing only interfaces

I've extracted interfaces from my repository classes, like ICustomerRepository, IProductRepository and so on. The project which contains the repositories is named X.DataAccessLayer. Should I call the project with the interfaces X.DataAccessLayerInterfaces, or what is better? And I definitely have to keep the interfaces in a separate project (I have 2 projects with implementations of these interfaces).


Do records showing the daily work of programmers exist?

Are there screencasts on the Internet showing screens of programmers that decided to record their daily work and show their programming style? I'm interested in seeing how other programmers effectively use tools like an editor with various features, debugger, looking for bugs, profiler etc. Maybe such "crazy programmers" exist that record everything they do and in the evening they realize that they did great mental job very efficiently and have the record, can additionally comment their intents which they still remember and share their effective hacks and coding style with other programmers. Is there such a resource for learning (doesn't matter if free or payable)? One particular portal or company which is focusing on this particular type of training and is leading in this area is sufficient for the answer.


Learning functional programming

This question is similar to Choosing a functional programming language. I want to learn functional programming but I am having troubles choosing the right programming language. At the university I studied Haskell for 2 months, so I have a basic idea of what a functional language is. I have read a lot that functional programming change your way of think. I started to take a look to Clojure, which I like for several reasons(code as data, JVM, etc). What stops me from continue learning Clojure is that it is not a pure functional language and I am afraid of ending up using imperative/OO style. Should I learn Haskell or keep on learning Clojure? Thanks in advance P.D: I am open to any other language.


What is the significance of the output of Function Point analysis

I am a beginner in Software Engineering principles. This question have only academic significance. I read about Function Point analysis.We will be getting an integer value as output for Function Point analysis. What all things can be inferred from that output? I know that it is an estimation technique. But couldn't understand how to read that output


How should I design a PHP class autoloader?

I have a fairly simple folder structure where the main classes are in a folder, and any classes used by those classes are in a subfolder with the same name as that class.               /exampleClass.php     /exampleClass/usedByExampleClass.php      I am trying to come up with a simple autoloader for this naming convention. So far, my idea is to use underscores in the class name wherever there might be a forward slash in the class path. This way I can simply replace all underscores with forward slashes in the autoloader, and load the class file. This means that the class name found in file:               /exampleClass/usedByExampleClass.php      would be:               exampleClass_usedByExampleClass      These class names end up being very long however, and I would like to shorten them while still having a simple autoloader for this folder structure. Any ideas or thoughts on how to achieve both short class names and a simple autoloader for this folder structure?


Teaching programming (languages) in central/northern Europe

I hope this question is not going to be off-topic; in case you think there'd be a better place to ask it, please let me know. Anyway, I'm currently doing my PhD working in bioinformatics. I would, however, like to turn away from academia eventually and instead go into teaching programming or, preferably, programming languages (e.g. Perl, which feels like my "mother tongue"...) - not as a school teacher, but with a company (in Germany or Scandinavia). It'll take me another one to one and a half years to complete my PhD, so I would like to know how I could/should use that time to raise my chances of getting into the profession I'd be interested in. Are there any Perl certificates I should aim to obtain, for example? In case there's anything that comes to mind when reading this, please let me know. Thanks a lot in advance!


XML: Multiple roots + text content outside the root. Does anyone do it?

I have another one of those "is it done in XML" questions (my last one about xml comments hasn't been answered if anyone has a good explanation) I was just wondering if anyone, anywhere would:   1. Use multiple `root` elements in an XML document   2. Put text content outside of a `root` element W3C discourages these practices, Javascript's `DOMParser` doesn't even allow these cases, and I can't think of one sane reason to do either of these things. However, I know how bizarre some implementations of XML have been, so I wouldn't be surprised. Does anyone have any real world examples where this would be done? I will also accept an answer that specifies if other mainstream parsers allow doing either of these.


How can I license networked applications?

I have five applications residing on servers. Some of these applications are socket (C/C++) based, others are web based (Java, PHP). I need to give licenses to these applications on the basis of the number of users that can access, the type of functionalities and type of users. What kind of business model should I use? I have a few in mind:   1. Create a java webservice that will be mounted on a license data, and all the servers will communicate with it when a user logs in any of the above applications.   2. Do a socket based server.   3. Mount a lisence file on each server and make each one communicate with its file individually and act as the license rules. If you have other solutions please shoot.


Agile unified process vs. agile lifecycle process

I wanted to know the difference between agile lifecycle and agile unified process(AUP). I do understand that AUP is a modified version of RUP using agile methodology. Can you please elaborate on the differences between the two


Long File Extensions: Why Not

I'm finishing up my app for iPad, and the file extension (used mostly so that Mail and Dropbox know what program to open the files in) is 12 characters long. The only file extension that is anywhere near as long is `tax2010`. Why is there so little variation on this topic, and **what kind of problems can I expect by using a long file extension for my app?** These files will be mailed, copied, and shared*. In all tests, it works perfectly. * I hope.


Codeigniter modular separation with Phing

I am thinking of managing a product source I am doing using Codeigniter + HMVC. Right now my folder structure is something like this:               application       |-modules           |-module1           |  |--controllers           |  |--models           |  |--views           |-module2           |  |--controllers           |  |--models           |  |--views     assets       |-themes          |-default            |-module1            |  |-- module1 theme files            |-module2            |  |-- module2 theme files      I am thinking of cleaning this up and making the modules self contained at development time, like this               application      |-- this will only contain the core files ()      |--modules (an empty directory OR core modules)     modules       |-module1       |  |-controllers       |  |-models       |  |-themes       |  |  |-default       |  |  |  |-module1 default theme files       |  |-assets       |  |  |-css (css files for just this module)       |  |  |-js (js files just for this module)       |-module2       |--//same as above      And then use Phing to build the project during which, the modules will be copied to respective folders, css files and js files will be minified (SCSS compiled) and images copied to respective folders. This looks great for deploying changes, but I think it will just increase development time, as every time I make any changes, I will have to build even to see it in development. Have any one used this approach to development using CI? or even better? I want to keep my core core more trackable and separate the modules for better version controlling, as I will be able to add those modules to the project as sub projects.


working on open source project is bad from a programmer view?

I am working in a software company where we are mostly working on websites which are based on open source like dotnetnuke or `nopcommerce` or any other and i am totally bored with all this as there is no scope for doing something new as most of the code is already done in these open source i know the open source are good for company as they save their time and earn more money but working on open source project is bad from a programmer view ? i learn some good things from these open source also...like entity framework from `nopcommerce` 1.9


How come centralized source control solutions don't do branching in place

With centralized source control like Perforce and SVN, when they create a branch, they create a whole new directory. However, git and other distributed source control solutions, in my experience, are able to update the branch in place as it were. That is, they apply the differences between the two branches to the files. This seems to me to be the far superior option as it saves huge amount of duplication for large projects, quicker to switch branches etc... What is the reason for this? I can't see any reason why there being a centralized authority affects the clients ability to diff the two branches and modify the changes.


How to handle asynchronous calls in an offline application

I'm using an offline application's javascript API and I'd like to know if I can use deferred objects to handle the callbacks. The API calls do not use HTTP, the calls are to and from the applications local database. The only way I've been able to display information is by using 'setTimeout' on subsequent calls, which I know, is terrible! So I have a long list of callbacks and timeouts.               var jsObj = {};     var anotherObj = {};          //first async call     methodName("arg1", jsObj, callback);          function callback(result){            jsObj["data"] = result;          }          //second async call     setTimeout(function(){methodName("arg1", anotherObj, callback2);}, 200);          function callback2(result){            jsObj["data"] = result;          }          //wait     setTimeout(function(){            $("#content").html(JSON.stringify(jsObj));          },300);      Is there anyway to refactor this? Any advice is appreciated. I've looked at the following post, but I'm not sure it would work. I'm aware I can create custom deferred objects (jQuery), but altering the API to use this or any other method of promise objects seems unrealistic.


How do you guard against hidden overflows

consider the following:               (i+j)/2      i and j are both 32 bit integers and the result should also be. But in the little equation, there's a hidden overflow, i+j could become larger then a 32 bit integer even though the result would always be a 32 bit integer.               public class Sum{          public static void main(String []args){             int i = 2147483647;             int j = 2147483647;                                    System.out.println((i + j)/2);          }     }      Gives me -1 as a result. How do you guard against situations that can overflow but are not always obvious. Is there a pattern that describes this? (apart from declaring everything long) I'm looking for a general answer, the java example is just to provide an example, my Delphi does the same.


Doesn't an event bus affect global state?

"Minimize mutable global state" is a more or less accepted program design principle. The reason often cited is that having global state can affect two components that don't are seemingly unrelated. In other words, a component mutating global state would have no idea who else it is effecting since it doesn't know what other component has a dependency on that global state. Tangentially, a pattern that is often recommended for building decoupled software is the event bus pattern where a component capable of generating events broadcasts it over a bus and components interested in certain events subscribe on the same bus to receive said events. My question is - doesn't the argument that holds for global state hold in the case of event bus too? After all, when broadcasting an event, I have no idea who else I am breaking since I have no way to know what other components are listening for it. Further, just as in the case with global state, reading the code might not make the dependencies of components on a certain even clear at the site of broadcast either. The only difference between the two that I can think of is that an event is a _transient_ state versus global state in the form of static variables or shared objects, that might be persistent.


Do dynamic typed languages deserve all the criticism?

I have read a few articles on Internet about programming language choice in the enterprise. Recently many dynamic typed languages have been popular, i.e. Ruby, Python, PHP and Erlang. But many enterprises still stay with static typed languages like C, C++, C# and Java. And yes, one of the benefits of static typed languages is that programming errors are caught earlier, at compile time, rather than at run time. But there are also advantages with dynamic typed languages. (more on Wikipedia) The main reason why enterprises don't start to use languages like Erlang, Ruby and Python, seem to be the fact that they are dynamic typed. That also seem to be the main reason why people on StackOverflow decide against Erlang. See Why did you decide "against" Erlang. However, there seem to be a strong criticism against dynamic typing in the enterprises, but I don't really get it why it is **that** strong. Really, why is there so much criticism against dynamic typing in the enterprises? Does it really affect the cost of projects that much, or what? But maybe I'm wrong.


Which (programming) specialities are needed in a good web development team?

At first glance, I'd say a good programming team needs to understand the following matters:   * The details of the core language / framework   * HTML, (asynchronous) javascript   * SQL / data model   * Usability / UI design   * Security   * Project management. If this team is not complete: what is needed?


Maybe monad vs exceptions

I wonder what are the advantages of `Maybe` monad over exceptions? It looks like `Maybe` is just explicit (and rather space-consuming) way of `try..catch` syntax. **update** Please note that I'm intentionally _not_ mentioning Haskell.


How to teach your users/customers to send better error descriptions

I often have to deal with customers or users which are reporting errors in applications. Most of the time their content is something useless as   * ERROR!!!   * x does not work without much more information. For resolving the issue I have to request every single detail of them, which often is more time consuming than fixing the issue itself. Other send information in formats which are not ideal, like screenshots (of data records, **not** of errors) although they could send a link (we have access to the systems) and so on. How do you tell your users/customers to describe the problems with more details so that the whole process could be easier for both sides? ### edit This question is more about the social skills, than how to achieve programmatic collection of logs and error information. I'm aware of the fact that this should be part of good software design.


How to avoid being overwhelmed when doing code review?

I'm pretty new to code review, and I feel often overwhelmed by incoming changes. I mean when there are serious code changes, coming from several developers I tend to accept everything without reviewing the whole, especially when I have lots of stuff to finish up. What are the techniques to help in being efficient in this area ?


Does compliance to WCAG 1 AA prevent the use of Javascript?

I have read the WCAG documentation and I am confused. Does compliance to WCAG 1 AA preclude the use of Javascript?


Punishing users for insecure passwords

I'm thinking about limiting the rights of users who choose insecure passwords (insecurity of a password being determined by length, how many types of characters (upper/lower case, numbers, symbols, etc.) are used, and whether it can be located in a rainbow table) to limit how much damage their account can do if compromised. I don't have an application for this idea yet, but say I'm writing a forum or something: Users who use 1234 as a password might have to fill out a captcha before posting, or be subject to rigorous anti-spam measures such as timeouts or Bayesian filters rejecting their content. If this forum is very hierarchical, allowing for "promotion" to moderators or whatever by some means, this would either stop them from gaining privileges at all or telling them they have privileges, but not letting them exercise them without a change to a more secure password. Of course this couldn't be the only measure of security, but it might go well next to otherwise good security practices. What do you think? Is this just overdoing it, stealing focus away from more important security practices, or is it a good way to limit risk and encourage users to use safer passwords (and hopefully convince people you are using good security practices)?


how easy is html/css?

many people say that html/css is something easy, it looks easy at first sight but when i worked on some projects i noticed that :   * same value works differently depending on other properties and on the targeted element.   * we need to know default values that browser affect to every property in every element.   * we can't be sure how the page will be rendered until we test, even if we are experts.   * we can't say we really know html/css until we know the algorithm used by the rendering engine and it's a huge responsibility for the engine to work with such complicated recursive layout. shortly, i have worked on desktop & web development for about 3 years and i have never seen such complicated thing to learn (html/css) **question :** Is html/css really hard to master ?


Best approach for bidding a project

We basicly have project that always turn around the same pattern. But, it sometime happens that we have project that go absolutly at the opposite of what we usualy do. It become now more difficult to bid and give this bidding to a potential client. In harder case, there's sometime things which look _very_ difficult to do and we just don't have an idea of how much time it could take... We also (for sure) want to take as less possible time to bid this knowing that we should maybe never get the project. So, my questions are;   * On what you base your time?    * What are the factors to consider (I know it's a bit hard as you don't see the base informations).    * Is there any tools that can help? To wrap it all, is there a better way to do it and if yes, what is this way?


Should coding standards be enforced by the continuous integration server?

Should coding standards/style be enforced by the continuous integration server running static analysis tools (ex. PMD, StyleCop/FxCop) and failing the build if the standards are not followed? What types of rules should not be used to fail the build?


Value of Internationalization in the iPhone App store?

I have several iOS/iPhone apps that have been continually selling in small amounts in over 2 dozen different countries, even though the app UIs and all the store descriptions are only in English. In a few countries where English is not the official or native language, a few apps are selling far better than is proportionate for those country's population size compared with the U.S. So why Internationalize apps? What kind of increase, if any, in sales might a typical app see if it is Internationalized into given local languages? Which major languages might be likely to see the greatest improvement in app sales or downloads due to a localized app description?


Maturity User Guide, Documentation and Ease-of-learning PHP-framework

I'm at the very start of a longtime running project with continual development. Because of that I'm hoping to make a good decision in which Framework will be right for this. Previously I've worked with Codeigniter. A plusside is the huge community with a great User Guide. A few of the downsides are the backwards compatibility with PHP4 which holds it back and (therefor) the lack of OOP. Because of that, I'm considering the use of a Framework like Kohana or Yii. I'm writing 'considering' because I'm not sure that the User Guide, Documentation is sufficient for us. My question is not to start a blog-like upside / downside comparison. My question is whether or not you have experienced drawbacks from a more or less imcomplete User Guide, Documentation like Kohana or Yii.


In functional programming, are local mutable variables with no side effects still considered "bad practice"?

Is having mutable local variables in a function that are only used internally, (e.g. the function has no side effects, at least not intentionally) still considered "non functional"? e.g. in the "Functional programming with Scala" course style check considers any `var` usage as bad My question, if the function has no side effects, is writing imperative style code still discouraged? e.g. instead of using tail recursion with the accumulator pattern, what's wrong with doing a local for loop and creating a _local_ mutable `ListBuffer` and adding to it, as long as the input is not changed? If the answer is "yes, they are always discouraged, even if there is no side effects" then what is the reason?


Design flaws and dealing with humiliation from it

Have you always been fundamentally correct in the software designs you proposed? When you give out some design that was fundamentally wrong, you tend to lose the respect of your fellow team members. No matter what you do after that you end up being crosschecked for everything thing you propose after that incident. This is especially worse when you are new to a team and they don't know your past where you have had some good success stories. Maybe the reason you gave a bad design was because of lack of experience or knowledge or both in that area. How have you who have faced such a situation dealt with it? Is this like a one time thing in your career or does it happen on and off? Does one put this behind or does one in such a situation need to look for a new line of work? Some honest feedback please... Thank you.


Is using os.environ to store the value of command line switches pythonic?

I write CLI-executable Python 3 scripts regularly to do data compilation and some maintenance tasks, and try to adhere to PEP 8 and the Google Python Style Guide when doing so. Google's guide says to avoid using global variables, while PEP 8 offers naming conventions but doesn't really encourage or discourage use of them, so I don't use them. However, I've lately found myself using a "verbose" option/switch a lot along with a "`printv`" function to use while debugging. It usually looks like this:               def printv(opts, msg, **kwargs):         if opts.verbose: print(msg, **kwargs)      As incredibly lazy as I am, I'd like to make it so I don't need to pass the `opts` argument (which is an `OptionParser` object) to `printv`. The simplest method would be to use a global variable, sure. Another thought I had would be to set a "VERBOSE" variable in `os.environ`, since the switch is, conceptually, making a change to the execution environment. Obviously it's counter-intuitive, but is it pythonic?


PHP vs C# performance

I have a application that is part console application written in C# and part PHP web application. The console application connects to multiple serial devices and reads data pertaining to moisture and temperature in a Grain Dryer. [The application] then stores the information in a MySQL database. The PHP reads the MySQL database and displays the information to the user (simple). I have also written a PHP script to email / sms the user if one of the temperatures of moistures reaches alarm levels (alarm levels are read off the device and stored in the MySQL database). Currently, I post to the PHP page with each "update" from the device (10 seconds) and check each value against it's limits. If an alarm is required I send it off and update the database indicating an alarm has been sent. This looks like (pseudo code)               IF moisture IS GREATER THAN moisture_high_critical_limit THEN       IF moisture_high_critical_alarm_has_been_sent IS FALSE THEN         SEND_ALARM();         moisture_high_critical_alarm_has_been_sent = TRUE;       END IF     ELSE IF moisture IS GREATER THAN moisture_high_warning_limit THEN       IF moisture_high_warning_alarm_has_been_sent IS FALSE THEN         SEND_ALARM();         moisture_high_warning_alarm_has_been_sent = TRUE;       END IF     ELSE IF moisture IS LESS THAN moisture_low_critical_limit THEN       IF moisture_low_critical_alarm_has_been_sent IS FALSE THEN         SEND_ALARM();         moisture_low_critical_alarm_has_been_sent = TRUE;       END IF     ELSE IF moisture IS LESS THAN moisture_low_warning_limit THEN       IF moisture_low_warning_alarm_has_been_sent IS FALSE THEN         SEND_ALARM();         moisture_low_warning_alarm_has_been_sent = TRUE;       END IF     END IF      _**The above IF statement is repeated for every temperature and moisture reading from the device, which can be quite a few._** Should this type of processing be happening in my Console application? Then if a Alarm notification is required post to the page only to send the email / SMS? Processing this information in the console application will reduce my total number of handshakes with the MySQL Database. But if the MySQL Database is hosted locally will this have much impact? I will eventually benchmark both (if it seems the doing the processing in the console application is in fact the right approach), however there is a lot of code to port over so I thought I'd come here and ask first.


Factory Pattern and/or Dependency Injection?

I understand the concept and can use both the Factory Pattern and Dependency Injection, however they seem a little at odds with each other conceptually. Is it a case of using one over the other? Or can they be used in conjunction with each other? If using DI would you hard code the creation of classes within a Factory? Wouldn't this defeat the point of DI? As the factory is dependant on the existence of the classes it creates, and thus would need them passed to the factory at runtime when using DI. Or would you pass the classes that the factory is meant to create to the factory is meant to create? If so wouldn't that defeat the point of building a factory in the first place? As the Injector would basically be doing all the work of the factory. Thank you very much for your attention, I look forward to your insights.


Comparison between ATAM method and analysis tools provided by ADLs

This is one of my assignment for this semester. And just to be clear, this question is not about the answer to my assignment as I have already finished it, it is more about the sanity of the question I am confused because as I know from the textbook, ATAM is a software architecture evaluation process which has multiple phases and steps. On the other hand, "analysis tools" provided by ADLs is just a sub-set of the evaluation process. More over, each ADL provides different set of tools for analyzing the architecture. I think that comparing between the two concepts is somehow weird and just confusing. I mean it is like comparing the whole computer and the graphic card itself. They have some relationships but they are not in the same scale. The graphic card is meant to be used by the computer to process graphical stuff. Each graphic card has its own characteristics and functionalities, some are better than another. Without the graphic card, the computer can still run, but without the computer the graphic card is nothing In short, my question is "Is it possible to do that kind of comparison? "


What are MPEG I, P and B frames?

I was recently going over MPEG articles and videos to understand how it works. I understand what I, P and B frames do but I do not understand how the prediction is calculated.   Assume that I want to record a video of a ball falling from the sky to the ground and then bouncing a couple of times before finally coming to a halt.   Also, I am not clear with the concept of the 16x16 macroblock. Please tell me:   * how prediction is calulated  * what is macroblock and how it helps in MPEG encoding     My references:   * MPEG Prediction * Video on MPEG conversion


User Acceptance Testing Defect Classification when developing for an outside client

I am involved in a large development project in which we (a very small start up) are developing for an outside client (a very large company). We recently received their first output from UAT testing of a fairly small iteration, which listed 12 'defects', triaged into three categories : Low, Medium and High. The issue we have is around whether everything in this list should be recorded as a 'defect' - some of the issues they found would be better described as refinements, or even 'nice-to-haves', and some we think are not defects at all. They client's QA lead says that it is standard for them to label every issues they identify as a defect, however, we are a bit uncomfortable about this. Whilst the relationship is good, we don't see a huge problem with this, but we are concerned that, if the relationship suffers in the future, these lists of 'defects' could prove costly for us. We don't want to come across as being difficult, or taking things too personally here, and we are happy to make all of the changes identified, however we are a bit concerned especially as there is a uneven power balance at play in our relationship. Are we being paranoid here? Or could we be setting ourselves up for problems down the line by agreeing to this classification?


Dealing with selfish team member(s)

My team is facing a difficult quandary, a couple of team members are essentially selfish (not to be confused with dominant!) and are cherry-picking stories/tasks that will give them the most recognition within the company (at sprint reviews etc. when all the stakeholders are present). These team members are very good at what they do and are fully aware of what they are doing. When we first started using agile about a year ago, I can say I was quite selfish too (coming from a very individual-focused past). I took ownership of certain stories and didn't involve anyone else in it, which in hindsight wasn't the right thing to do and I learnt from that experience almost immediately. We are a young team of very ambitious twenty somethings so I can understand the selfishness to some extent (after all everyone should be ambitious!). But the level to which this selfishness has reached of late has started to bother me and a few others within my team. The way I see it, agile/scrum is all about the **_team_** and not individuals. We should be looking out for each other and helping each other improve. I made this quite clear during our last retrospective, that we should be fair and give everyone a chance. I'll wait and see what comes out of it in the next few sprints. In the meantime, what are some of the troubles that you have faced with selfish members and how did you overcome them?


Event Aggregator.. not getting a response, how to determine completion?

I'm rewriting a vehicle tracking application, a google maps based thing.. The users are able to search for a vehicle by typing a few characters of the vehicles "callsign". My application is based around a sort of "event bus" within Backbone.. when a search occurs I send a message on the bus saying something like "does anyone match this?".. If a marker matches the search term it responds with a sort of "yes, I match!".. My challenge arises when no-one matches, I get no response.. it feels a little hacky to "wait a little while" and check if a response has been recieved.. The application is based around Backbone.js and using the Event Aggregator pattern described in the answer to this question on Stack Overflow: http://stackoverflow.com/questions/7708195/access-function-in-one-view-from- another-in-backbone-js Is there a well defined design pattern that might assist me here? Sending a request for a response and not getting any responses?


How to change documentation expectations from "risk management" to a "project risk"

We are trying to introduce some agile concepts to the business folks but one of our biggest hurdles is their expectations for documentation - the quantity, the authorship/ownership of the documents, the lifecycle of the documents, the timing of the authorship, and the material that should be documented. The business folks are very much in a traditional mindset. For them, documentation is a risk management tool. What can we do to help them view documentation as a risk and a requirement? We've tried indicating in the project timelines how much extra time is spent on documentation. Their response is it helps them estimate project costs and reduces risk. We respond with empirical evidence showing it hasn't worked to date. They respond with "that's IT's fault for reasons x, y, z" and then introduce more documentation to account for IT's failings. And then it spirals on and on until the baggage is un-bearable. Regarding authorship, we've tried to convince the business that IT doesn't want or need certain documents and that the business is capable of producing them without IT if they feel it's needed. So they will produce something, and then hold us accountable for its contents even though it is (from our perspective) un-related to us and un-vetted by us. So when we try to vet their documents, we get sucked in and then the questions of ownership and maintenance rear their ugly heads. From everything I've read, this is a no-win situation. Is there any advice or thoughts to help us transform their expectations of documentation to light- weight, just-in-time/just good enough documents? If needed, find more background in my previous question.


Java - Use polymorphism or bounded type parameters

Suppose I have this class hierarchy...               public abstract class Animal {         public abstract void eat();         public abstract void talk();     }     class Dog extends Animal {         @Override         public void eat() {         }              @Override         public void talk() {         }     }          class Cat extends Animal {         @Override         public void eat() {         }              @Override         public void talk() {         }     }      And then I have....               public static <T extends Animal> void addAnimal(T animal) {         animal.eat();         animal.talk();     }          public static void addAnimalPoly(Animal animal) {         animal.eat();         animal.talk();     }      What's the difference when using bounded type parameters or polymorphism? And when to use one or the other?


Improve address lookup usability and accuracy?

In my application,I have a feature like this: The user wants to add a new address to the database. Before adding the address, he needs to perform a search(using input parameters like country,city,street etc) and when the list comes up, he will manually check if the address he wants to add is present or not. If present, he will not add the address. Is there a way to make this process better. maybe somehow eliminate a step, avoid need for manual verification etc.


Zend 'Page Tile' view helper

I've created a ZF2 view helper `PageTitle` (extending `Zend\View\Helper\AbstractHelper`). As the name of the helper suggests , it is responsible for rendering the page title for each action view script. So within _each action view script_ (not layout) I would call :                echo $this->pageTitle('My Page Title', 'some-icon-class-name');      This would render the required HTML output

 My Page Title

      The plugin also contains another view helper (`button`) within it; its job is to render zero or more form button elements. My trouble comes when I need to pass these _page specific_ buttons/links. My current solution is to provide an array of 'buttons' as a third parameter.               $this->pageTitle('My Page Title', 'some-icon-class-name', array(       'button label 1' => array(         'attributes' => array(           'class' => array('some-class-name', 'another-class'),           'data-foo' => 'bar',         ),      )));      (Above is just an example of what I have tried to demonstrate the issue. This is in fact numerous buttons, each with several 'attributes' each) I think the above approach is messy, certainly within the view. It also defeats the purpose of even having a view helper as I will need to provided this config again each time I need to reuse the page header (some pages may use other views as children). Some solutions I have considered. **Create a page title service factory, per page** Each factory will create a new `PageTitle` plugin and inject the 'button' config into it. This is then registered ti the view plugin manager under a unique plugin name. So, as an example, I would change the call in my view to:               echo $this->mySpecificPageTitle(); // no args as pre-constructed      The downside here is that I then need to create allot of factories (just so I can provide very slightly varied arguments). **Provided a 'service' name to the plugin** (this is similar to the navigation view helper) then then helper calls this service and it returns the required configuration. For example:               echo $this->pageTitle('My Page Title', 'some-icon-class-name', 'MyButtonService');      So within the helper:               $buttonConfig = $serviceManager->get('MyButtonService');      This however again means that I would need to create a factory for each 'MyButtonService' I need.


Git Repository Setup

I am moving my companys source control from TFS to GIT. We have TFS currently defined as.   * Project Collection /      * / Client A        * / Product A       * / Product B       * / Product C     * / Client B        * / Product D       * / Product E       * / Product F What is the best way to do this in Git? I have thought about the following:   * Repository (Client A)      * Branch (Product A)     * Branch (Product B)     * Branch (Product C)   * Repository (Client B)      * Branch (Product D)     * Branch (Product E)     * Branch (Product F) What do you think is the best approach as the design is slightly different?