How to add image support to client-server database application?

I have an architectural question about a project that I am working on. Currently it is a simple .NET C# application that runs on several client machines, and communicates with a central MySQL server for data storage. There is not an application or service on the server at this time, just MySQL. I would like to add image support so that users can add images to the database (and view after the fact), but after storing the images directly in MySQL as `BLOB` I've decided this approach is a bad idea, as suggested in many posts on SO. The application can't store images on the local filesystem because they would then be inaccessible to other users not on the same local host. That being the case, I'm not sure how best to implement image support otherwise:   * The machines are all Windows-based, I can set up a shared folder but then I have the headache of maintaining a mapped network drive and user credentials/permissions.   * I've thought of adding another application (or service) that runs on the server and handles reading/writing of images on the server side, but this seems redundant in light of the fact that the computers already are capable of file transfers.   * Should I consider creating an application on the server to handle all communications between clients and the SQL database, adding filesystem communication there?


Writing to event log - best practice if log is full

I have an application that writes to its own Event Source. The Event Source itself is created upon install to prevent user vs admin access issues at runtime. Should writing to our own Event Source fail, the event is instead written to the Application log (two events actually, on for the original event data, and another saying 'Could not write to own event log because...' or something similar). We've recently discovered a problem that when the Application event log is full, the exception is unhandled. Now granted, I could just eat the exception (similar to what this answer says). So what is the best behavior? The application is attempting to log the issue and attempting to log that there is a problem. Should I eat the exception, let the logging operation fail silently and continue execution? Or should I let the exception bubble up the call stack so that user/developers know of the issue? What's the recommended approach under these conditions?


Move a player to another team, with players stored in one arraylist and teams in another using java

Basically I have a team class, which has an array list that store the players in. In the driver class there's an arraylist that stores the teams. Anyhow I've worked out how to add a player to a specific team and likewise remove a player from said team. Where I'm hitting problems is when I try to transfer one player to another. My understanding is to scan through the first team, and get the player. Then somehow add this player to another, by scanning through the chosen team and add to it? I've tried this way but it seems to replace the original player with the new player in both teams. My other approach would be to somehow return the parameters of the player object, create another with the return parameters, remove the original then add the new instance in the other team? Really not quite generally how I can go about this, been trying all afternoon!   If someone could offer me a general idea, then I can go off and apply the understanding to practice.


How to store exception messages

How are exception messages commonly stored? for any domain. I'm thinking about this from a maintenance standpoint.               if(!Condition1)         throw new Exception("Some exception");          if(!Condition2)         throw new Exception("Some exception");      If it was decided that the exception message in that snippet needed to be changed, it would have to be changed in two places; leaving it wide open for inconsistent messages and such. How better to store exception messages then? Perhaps as a static class with constants?               public static Exceptions     {         public const string CONDITION_NOT_MET = "Some exception";     }     ...     if(!Condition1)         throw new Exception(Exceptions.CONDITION_NOT_MET);          if(!Condition2)         throw new Exception(Exceptions.CONDITION_NOT_MET);      Are they often (in production) hardcoded?


Validation and Verification explanation (Boehm) - I cannot understand its point

Hopefully my last thread about V&V as I found the B.Boehm is text which I just do not understand well (likely my technical English is not that good). http://csse.usc.edu/csse/TECHRPTS/1979/usccse79-501/usccse79-501.pdf Basically he says that verification is about checking that products derived from requirements baseline must correspond to it and that deviation leads only to changes in these derived products (design, code). But he says it begins with design and ends with acceptance tests (you can check the V model inside). The thing is, I have accepted ISO12207 in terms of all testing is validation, yet it does not make any sense here. In order to be sure the product complies with requirements (acceptance test) I need to test it. Also it says that validation problems means that requirements are bad and needs to be changed - which does not happen with testing that testers do, who just checks correspondence with requirements.


Is there an open source license with proprietairy-like terms?

Is there any license meeting the following criteria:   * source code available (users allowed to browse the source)   * users are allowed to modify the code with credits to the original author   * not allowed to sell the software itself or any other program using code from it   * can be sold by original author


Knowing so much but application is a problem?

In my work, my friends always tell me, you know so much about computer science, electronics engineering,..etc. But I have difficulty in applying them and my code is crap. How to solve that problem? Will I be better or programming isn't my career? For example, yes I know OCTree that is used for space partitioning in games and it is used for optimization, did I implement it? No, but I know about it in principle.. Do I know algorithms like Sorting, Searching,..etc? Yes, and I know them pretty well, but didn't implement them.. When I get a task, I struggle in applying the things that I know...


When defining directory path, should a trailing slash be included?

Say I'm defining a directory and then including files from it. Is it better practice to do:               define('PATH', 'C:/xampp/htdocs/includes/');     require PATH.'header.php;      or:               define('PATH', 'C:/xampp/htdocs/includes');     require PATH.'/header.php;


Using foldr to append two lists together (Haskell)

I have been given the following question as part of a college assignment. Due to the module being very short, we are using only a subset of Haskell, without any of the syntactic sugar or idiomatic shortcuts....I must write: _append xs ys : The list formed by joining the lists`xs` and `ys`, in that order_               append (5:8:3:[]) (4:7:[]) => 5:8:3:4:7:[]      I understand the concept of how foldr works, but I am only starting off in Functional programming. I managed to write the following working solution (hidden for the benefit of others in my class...) : > append = \xs -> \ys -> foldr (\x -> \y -> x:y) ys xs However, I just can't for the life of me, explain **_what the hell is going on!?_** I wrote it by just fiddling around in the interpreter, for example, the following line :               foldr (\x -> \y -> x:y) [] (2:3:4:[])      which returned `[2:3:4]` , which led me to try,               foldr (\x -> \y -> x:y) (2:3:4:[]) (5:6:7:[])      which returned `[5,6,7,2,3,4]` so I worked it out from there. I came to the correct solution through guess work and a bit of luck... I am working from the following definition of foldr:               foldr = \f -> \s -> \xs -> if null xs then                                   s                                else                                   f (head xs) (foldr f s (tail xs) )      Can someone baby step me through my correct solution? I can't seem to get it....I already have scoured the web, and also read a bunch of SE threads, such as How foldr works


Is having C++ header files without extension a good practice?

I have an argument with a collegue of mine regarding the C++ guidelines to follow. He currently designs all his libraries that way:   * He uses inconsistently uppercase and lowercase letters in his filenames   * Some of his headers don't have any extension I believe that having no extension is something reserved for C++ standard files and that using uppercase letters is error prone (espcially when you deal with code which is meant to work on both Windows and Linux). His point is that he follows `Qt` conventions (even for code that doesn't uses Qt) and keep saying : "If Qt does it that way, then it can't be bad." Now I try to keep an open-mind, but I really feel bad when I have to work on/with his libraries. Is there a common established set of rules regarding this ? Does the standard tell something about it ? Thank you very much.


Dynamic Fields/Columns

What is the best way to allow for dynamic fields/database columns? For example, let's say we have a payroll system that allows a user to create unique salary structures for each employee. How could/should one handle this scenario? I thought of using a "salary" table that hold the salary component fields and joining these columns to a "salary_values" table that hold the actual values. Does this make sense? **Example Salary Structures:** Notice how the components of the salary can be shared or unique. \-- Jon's Salary --               Basic           100        Annual Bonus    25        Tel. Allowances 15      \-- Jane's Salary --               Basic             100     Travel Allowances 10     Bi-annual Bonus   30


Best practices for deploying multilingual API

I have a hobby project and it looks like there is need to have some API library (which in turn is a wrapper over existing http API) at least for two languages - JavaScript and Python, adding support to Perl would be nice as well. The question is - what are the best practices for minifying the cost of supporting and developing of such multilanguage APIs? Is it better to choose one language and write just wrappers that for other ones? Or it's better do move slower but to implement thoroughly each method on each language.


Is Independent Java Development Worth it Compared to Objective-C?

First I would like to say that I'm not developer, but I love to code whenever I can. I mainly use Perl which is the language I use when doing System Administration. For different reasons (that I'm not sure of) I recently have been told to learn Java by my manager, so I'm starting to do so. I was thinking that I should take advantage to the situation to build some Android Apps. But it seems that Objective C has increased in popularity recently because of the iPhone and iPad. I want to know if it's worth it to develop with Java for Android compared with to develop with Objective C for iPhone (or iPad). Of course, not based on the APP functionality, let's say someone has developed the APP X for both platforms. In which platform would it become the worthiest? And no, I'm not gonna learn both (sadly ain't got much time) Thank you!


industry averages for time spent on maintenance

A manager recently announced that were were spending far too much time fixing bugs. I guess he thinks we should write perfect code all the time (whilst still hitting those impossible deadlines of course!) and it made me wonder what the industry average of time spent bug fixing v writing new code was. So does anyone have any metrics on time spent bug fixing against new code development? Or is there any empirical analysis of bug fixing time for the industry as a whole? Is 50% spent bug fixing too much, or about right? How about 20% or 33%? I'm happy to accept anecdotal evidence from personal experience as that would form part of some statistics here that I could compare our performance against.


Shouldn't documentation be written together with tests rather than in the code?

It is popular to write documentation in the same file as the code and extract that using software to generate documents. In order to not affect performance, the documentation is written within commented lines, in a DSL designed just for the purpose of that. And that often results in cumbersome source file. Nowadays, test driven development is popular, and usually tests are written on separate files from the code. Since test files are not run during production, it does not interfere with performance, and hence test are not written within commented lines in a DSL, but are written in the same programming language as the code. Doesn't it make more sense to write documentation in the same file as tests not in commented lines but in the same programming language using DSL? For each syntactic element like class, method, first a documentation telling the features of it can be written, and then test can follow it. That would make things nicer in my opinion. I have scripting languages like Ruby in mind if that makes difference.


What "code smells" are there that are a symptom that an event listener model is required?

What are the symptoms in a code base that indicate that an event-listener approach is required? It seems to me that when there are classes that need to be called by multiple, not defined at design-time set of other classes, you need some sort of signaling framework, but I would like to hear what other situations are there that would be improved by changing to an event-based model.


Development Test Interview

I have a development test I am required to solve a given problem with any language of my liking in about 8 hours. The company is GFI if anyone was wondering. How can I truly prepare for such a test?


How to continue development without the webservice?

We make iOS apps where we often get data in a list from an API, then we select the data and go to the next ViewController. Often it happens that the server is down or some API is not ready. What is a good development practice where we can continue our regular work flow without depending on the webservice and then when its ready without making much changes continue using the web-service and till then use some fixed data.


Is using dynamically generated code as cache a good idea?

I have a web search interface that can compare products in a table. This data set changes a few times a week. I have been storing a "DISTINCT" list (used for parametric selection) in a `cache` table. The query is computationally expensive because it involves table joins and thousands of records, hence the reason to cache it. I was wondering if it is a good idea to "cache" certain data in PHP in dynamically generated code. The idea is that I could create a cache.php file that is 'included' which has the data in arrays for PHP to use without going to the database. This PHP file could be cached using any of the PHP compiler caches out there. I'm not having speed issues (yet), but I don't like the idea of having to ask the database for cache data, as it seems the overhead of the php->mysql transaction is expensive.


Why is Java not 'pure' OOP?

Java is designed in a very OO approach, and somewhat even 'forces' programmers to program within the OO paradigm (which can be considered good or bad, a matter of opinion). However while _almost_ everything in Java is a class or an object, primitive data types (`int`, `double`, etc) are not. While I see no advantages to this, there are disadvantages. For example, when a method wants to take in as a parameter 'any value', it usually declares the parameter of type `Object`, the supertype of all classes in Java. However if the programmer wants to input an `int` to the method - a perfectly valid value - he/she has to 'box' the value in an instance of the `Integer` class, created specifically for these kinds of needs (as far as I understand). My question is: why aren't primitives in Java classes, like everything else?


What naming anti-patterns exist?

There are some names, where if you find yourself reaching for those names, you know you've already messed something up. For example: **XxxManager**   This is bad because a class should describe what the class does. If the most specific word you can come up with for what the class does is "manage," then the class is too big. What other naming anti-patterns exist? **EDIT** : To clarify, I'm not asking "what names are bad" -- that question is entirely subjective and there's no way to answer it. I'm asking, "what names indicate overall design problems with the system." That is, if you find yourself wanting to call a component Xyz, that probably indicates the component is ill concieved. Also note here that there are exceptions to every rule -- I'm just looking for warning flags for when I really need to stop and rethink a design.


Does it make sense to use ORM in Android development?

Does it make sense to use an ORM in Android development or is the framework optimized for a tighter coupling between the UI and the DB layer? * * * **Background** : I've just started with Android development, and my first instinct (coming from a .net background) was to look for a small object- relational mapper and other tools that help reduce boilerplate clode (e.g. POJOs + OrmLite \+ Lombok). However, while developing my first toy application I stumbled upon a UI class that explicitly requires a database cursor: `AlphabetIndexer`. That made me wonder if maybe the Android library is not suited for a strict decoupling of UI and DB layer and that I will miss out on a lot of useful, time-saving features if I try to use POJOs everywhere (instead of direct database access). * * * **Clarification** : I'm quite aware of the advantages of using ORM _in general_ , I'm specifically interested in how well the Android class library plays along with it.


Is C++11 Uniform Initialization a replacement for the old style syntax?

I understand that C++11's uniform initialization solves some syntactical ambiguity in the language, but in a lot of Bjarne Stroustrup's presentations (particularly those during the GoingNative 2012 talks), his examples primarily use this syntax now whenever he is constructing objects. Is it recommended now to use uniform initialization in _all_ cases? What should the general approach be for this new feature as far as coding style goes and general usage? What are some reasons to _not_ use it? Note that in my mind I'm thinking primarily of object construction as my use case, but if there are other scenarios to consider please let me know.


Is there a universal date format that anyone in the world can understand?

In Canada, everyone is familiar with the date format `YYYY-MM-DD`. In Europe or South Africa, they prefer `DD-MM-YYYY`. There are users from South Africa who get confused with the `YYYY-MM-DD` date format. Is there a way to handle this situation? I was thinking of using the following method format for all: `Feb 02, 2011`


What are the hardest parts of the C++/C#/Java programming languages?

Just wondered what are the features of the three main programming languages which show you are an 'expert'? Please exclude 'practical' skills such as indenting. Am I right in saying for C++ the most difficult aspect to master is STL/generics? Java seems much easier as memory is handled for you. I'm not entirely sure on C# either? I'm trying to use this to guage my current level of ability and what i wish to aim for. ps this was posted on stackoverflow but got binned due to arguing, please do try to keep it civil as I am really interested in the answers from everyone :)


Do programmers possess the means of production?

I was listening to The Servile State by Hilare Belloc this morning and pondering whether or not I possessed the means of production, as did the peasant of the Middle Ages; as did not his descendants after the oligarchs of England forced him into servitude. The means of production was the arable land that the serf was seated on, which, even though not legally his, was illegal to evict him from. So, as programmers, with the hitherto unknown supply of free tools and resources, have we reclaimed as a class of workers, unlike any others, the means of production? Given the chance, a midrange PC and a stable internet connection, could we not each of us be wholly self-sufficient and not just wage-earners?


Web application deployment and Dependencies

I have a free software web application that using other free software scripts for appearance. I have trouble to decide whether should I copy source code of used scripts to my project main repository or list them as dependencies and ask user (who installs application to his server) to install them himself? Since some of scripts solving browser compatibilities issues and I'm not a good web designer (i hate to check my web site on IE to see compatibility) using the newest version of scripts is preferable and second solution works here. But it has problem with scripts aren't backward-compatible with versions I've used them for development. Maybe another method is well-known for this issues that I don't know them.


When is it not appropriate to use the dependency injection pattern?

Since learning (and loving) automated testing I have found myself using the dependency injection pattern in almost every project. Is it always appropriate to use this pattern when working with automated testing? Are there any situations were you should avoid using dependency injection?


Why c++? Where to start?

I know there was many questions like this one, but please hold on one more. All programming languages I know now are made for web purposes. I've been learning ActionScript, php and a bit of Javascript, AJAX, etc.. I've liked php very much but I'm still looking something I'll really love! That's why I want to try something new. Can You tell me what are positives and negatives of this language? Is there some big example of C++ usage? Is it a good language to start this journey (maybe You can recommend something else)? Are there some good video tutorials which I can buy on CD/DVD? Could You recommend some books? @edit: After reading Your answers and some info on the internet I'm confused about two languages. Those are C++ and Python. Python can be used for web so it combine great with my current knowledge. But how about Python for desktop applications? Is it hard to build cross-platform apps? Could You compare for me this two languages? PS. I'm really glad about all of Your answers. It is very helpful for me & it forces me to productive thinking about my future ;)


How can I translate my android app help and keep it up to date?

My Android application is almost done and I spend much time creating a set of very precise help pages in HTML that I display using WebViews. I am now ready for the next step, which is _i18n_. Translating my app is no problem, the strings.xml is not that long and I can easily ask friends to translate it. My problem is about these help pages. When I'll update my app, I'll probably have to update the help pages as well. I saw that it wasn't that simple, even with one language. I need your opinion on how to perform such a massive work (which is not at all my job as a developer). Do I need to:   * Manually update every language help page when I update the app, which means asking all of my translators to provide a new version of their work each time I change anything.   * Provide help only in a default language (probably English, even though the default language is French. French people would still have the French help ;-D).   * Google-translate the help pages, even if it _"not well English is"_. I don't know any way to do it automatically.   * Do something else, which you probably thought of long ago. Thanks for your answers, tips and tricks.


Creating a separate project for JPA entities

Where I work it is a common practice to create a separate for JPA entities and a project for the web application (the WAR). So basically you have (at least) two project for each application - appJPA and appWEB. The people who started this convention are no longer there, so I have been wondering about the benefit of having this separation. The only advantage I could think about is the Eclipse JPA facet which provides various tools for JPA. But if I am not mistaken, this facet can be applied to WAR projects as well. So my question is: is this separation unnecessary?


How can I sell my boss on Python+Django instead of PHP+a different framework?

My boss has tasked me with a re-write of our intranet website. The existing system is very old PHP that doesn't use a framework. My preference is strongly to do the rewrite in Python and Django but my boss does not like Python syntax (he is also a developer). I'm on the opposite end... I don't like developing in PHP and my PHP experience is extremely limited but I've done a lot of work in Python. My boss is aware of my experience but still wants me to sell him on Python. Some of the things he mentioned he does not like about Python:   * indentation is the only marking for the begin/end of a code block (he loves his curly braces)   * documentation issues (I told him python documentation is great)   * IDE support is limited (mentioned PyCharm and Wing IDE, not sure which is better)   * he's had compatibility issues moving between older versions of python He may be the only other pair of eyes on the new code. How can I convince him that Python is a better choice? Is Ruby a potential middle ground?


Assembly instructions execution time

Where can I find the x86 instructions execution time? How to find out which instruction is faster or smaller?


Inserting HTML code with jquery

One of our web applications is a page that takes in a serial number and various information is returned and displayed to the user. The serial is passed via AJAX, and based on the response, one of the following can happen -   * An error message is shown    * A new form replaces the previous form Now, the way I am handling this is to use jQuery to destroy (using $.remove()) the table that displayed the initial serial form, then I'm appending another html table that contains another form. Right now I am including that additional form as part of the html source, and just setting it to display:none, then using jQuery to show it when appropriate. However, I don't like this approach because if someone views source on the page, they can see that table html code that is not being displayed. My next thought would be to use AJAX to read in another HTML file, and append it that way. However, I am trying to keep down the number of files this project uses, and since most pages in our project will use AJAX, I could see a case where there are multiple files containing HTML snippets - and that feels sloppy to me. What is the best way to handle a case where multiple html elements are being shown and removed with jQuery?


What must I take into consideration when designing a UI around a 0..1:1 relationship?

I'm designing the database schema for a new product feature. In my current design I have some related optional data. Rather than have nullable fields I have a separate table with a 0..1:1 relationship to the main table. I chose this design because the queries are simpler* if null data doesn't have to be taken into consideration. The team lead pointed out to me that it will complicate data binding in the UI and suggested that I just use nullable fields. I am wondering what complications the optional table approach will introduce? The obvious thing that comes to mind is the data aware controls can't bind to a closed data set so I'll need to either create a record on the fly when the user attempts to fill in the optional data or create the record at the same time as the main record, negating the purpose of have a separate table. Is there anything else I should be aware of? **Clarification** *Simpler, by which I refer to the dizzying amount of rules and ambiguities concerning null's behavior under different query scenarios in the SQL standard and the fact that no two vendors agree on which of these rules to implement.


What to do when there are no logical user stories but separate development tasks?

We need to generate a release in 3 weeks, and for the planning we are doing today we don't have coherent logical user stories from the backlog tasks. Is valid to match say each development task is equivalent to an user story? Methodologically what is the correct way of handling this?, because anyway we are going to have standup meetings and we are going to control the progress of the project against those development tasks. For example, we have things like: . Adapt ETL to process numeric lists . Adjust licensing component . Remove DTC and so on. So, for the planning poker and iteration planning is valid to use those tasks? if not, what is the alternative?


Choosing the simplest platform version of a source when porting to another platform

The question will sound weird as I'm not very experienced in C, C++ and ASM. Let's say I have a hard time finding a C# managed, safe-code-only solution to solve a problem. Then I find that in 1998, some codes for (e.g.) a codec have been written in C for PPC, x86, arm, etc. This code can have 20000+ lines, and I need to port it. Then I try one platform, and notice a lot of API call, CUDA stuff, inline assembler in most of the code. Etc. Is there a preference, concerning portability, between PPC, PS2, x86, arm, sparc, etc, when porting to another platform that helps reducing the number of platform-specific code occurrence? I know that all these builds exist especially because there are specific features on each processors, but I wonder if some processors have less antennas, third eye, and four legs, and are less simpler (or "limited") than others. I spent the last week porting codes, and had the intuition that focusing on certain aspects helps finding more cross-platform code. I may be wrong, and I - know - that it highly depends on skill. But that doesn't change anything to the fact that, e.g., a 20000 lines Java code may be easier to port to .Net for Windows Phone than a x86 asm code. More specifically, my question is about a good approach when porting Orange to Peach, and avoiding going through several platform specific implementations.


Does Liskov Substitution Principle also apply to classes implementing an interface?

LSP states that classes should be substitutable for their base classes, meaning that derived and base classes should be semantically equivalent. But does LSP also apply to classes implementing an interface? In other words, if an _interface method_ implemented by a class is semantically different from what user expects it to be, would this be considered as a violation of LSP?


What is the "1620's multiplication operation"?

I was stumbling through Wikipedia when I came across the entry for FLOPS, specifically the table in this section. The first entry is for a computer from 1961, the comment on the right reads > The 1620's multiplication operation takes 17.7 ms.[46] What is this operation? I assume it means it can do multiplication in 17.7ms?


Should Developers Perform All Tasks or Should They Specialize?

Disclaimer: The intent of this question isn't to discern what is better for the individual developer, but for the system as a whole. I've worked in environments where small teams managed certain areas. For example, there would be a small team for every one of these functions:   1. UI   2. Framework code   3. Business/application logic   4. Database I've also worked on teams where the developers were responsible for all of these areas and more (QA, analsyt, etc...). My current environment promotes agile development (specifically scrum) and everyone has their hands in every area mentioned above. While there are pros and cons to each approach, I'd be curious to know if there are more pros and cons than I list below, and also what the generally feeling is about which approach is better. **Devs Do It All** **Pros**   1\. Developers may be more well-rounded   2\. Developers know more of the system   **Cons**   1\. Everyone has their hands in all areas, increasing the probability of creating less-than-optimal results in that area   2\. It can take longer to do something with which you are unfamiliar (jack of all trades, master of none) **Devs Specialize** **Pros**   1\. Developers can create policies and procedures for their area of expertise and more easily enforce them   2\. Developers have more of a chance to become deeply knowledgeable about their specific area and make it the best it can be   3\. Other developers don't cross boundaries and degrade another area   **Cons**   1\. As one colleague put it: "Why would you want to pigeon-hole yourself like that?" (Meaning some developers won't get a chance to work in certain areas.) It's easy to say how wonderful agile is, and that we should do it all, but I'm somewhat of a fan of having areas of expertise. Without that expertise, I've seen code degrade, database schemas become difficult to manage, hack UI code, etc... Let's face it, some people make careers out of doing just UI work, or just database work. It's not that easy to just fill in and do as good of a job as an expert in that area.


How do you get into the habit of using a repository (e.g. GitHub)?

Are there some best practices on the repository front, or some common newcomer-traps that I should avoid? I have recently been reading about the benefits of repositories even for single-developer projects and, in addition, I am likely to start working with multiple other engineers in a short while but, how do I go from never having used a repository to setting one up - for multiple people, even! **Background:** I am an electronics engineer before anything else, and while application programming has been part of that, it's never been something I've done a lot of - it has mainly been snippets of C for embedded systems where I was the only person working on it.


Trying to understand the 2N lnN compares for quicksort

I was going through the analysis of quicksort in Sedgewick's Algorithms book. He creates the following recurrence relation for number of compares in quicksort while sorting an array of N distinct items. ![enter image description here](http://i.stack.imgur.com/6g8bm.jpg) I am having a tough time understanding this... I know it takes 1/N probability for any element to become the pivot and that if k becomes the pivot, then the left sub-array will have k-1 elements and right sub-array will have N-k elements. 1.How does the cost of partitioning become N+1 ? Does it take N+1 compares to do the partitioning? 2.Sedgewick says, for each value of k, if you add those up, the probability that the partitioning element is k + the cost for the two sub-arrays you get the above equation.   * Can someone explain this so that those with less math knowledge (me) can understand?   * Specifically how do you get the second term in the equation?    * What exactly does that term stand for?


How to design a composite pattern in Python?

# The concept I'm programming an interface over pygame as a personal project, to make the creation of games easier for me. So far I managed to design an architecture that behaves like this :   * Objects are displayable components that can appear and move on the screen   * Objects can have children objects   * When an object displays itself, it ask all his children to display themselves on the parent's surface.   * Objects have three important elements : a callback system, a graphics system and a physics system to respectively act, display and move. Then, when I want to create a game "scene", I create a "root" object that contains other objects like the player, the mouse, the ground, monsters... Then I just have to ask the root to display itself, and every object appears recursively. I designed this without knowing about the composite pattern at first, only the basics of OOP. My main issue was to make the substitutability property of objects that comes from inheritance to work well with the recursive composition I made. I mean that I have an "abstract" class called "Object" (I put abstract into quotes because Python doesn't really have such concept) that is inherited by classes like "Image" (to be able to display) or "MovingObject" (to be able to move). Here, inheritance is meant to extend my object abilities. But my composite pattern requires that "groups of objects must be considered the same as single objects". So when I call recursively a method from an object, it calls that method from every child of the object, regardless of the fact that some of them may not have that method. # Example For instance, let's use this root element :   * root (Image)      * player (MovingObject)     * cloud (MovingObject)     * background (Image)     * sun (Image) Now let's suppose we want to call the method `move()` on the root element, to make every child move : First, we cannot because root is an Image instance, so it doesn't know the `move()` method. But even if it was the case, the children "background" and "sun" would not know it. So I decided to put an empty method `move()` inside my "abstract" Object class, so every object knows it, even if it doesn't do anything. The issue is that my Object class is now containing empty methods that it doesn't understand nor needs, only to permit the recursive behavior. # Possible solution Then I heard about all the "inheritance vs composition" fuss and one of the solutions that came to my mind was to stop using inheritance for Object abilities and use composition instead. That means I would create, for example, a "Body" class, an "Image" class and a "Callback" class that would represent different actions, and then plug these into an Object instance to "equip" it and give it more power. But then I thought that this will barely change something because I will have to call `move()`, and then the object will check if it has the Body plug-in, and use it. But it still requires the `move()` method to be present inside the Object class. # Questions So I'm turning to you guys to gave me advices about my pattern :   * Did I understand well how the composite pattern works ?   * Is my approach correct ?   * Does the use of "plug-in" classes will help me ?   * Is the recursive behavior a good idea ?   * Is there other patterns that are more fitting to my needs ? I hope you can give me some hints!


Making a business case for a future proof Silverlight application

I have recently started working for a pretty big bank writing internal apps. I am being subcontracted out by the company I work for (who I have also recently started working for). This bank **has recently** upgraded to Windows XP, they previously used Windows 2000. I have been tasked with re-writing a report viewing application, which I am currently doing in MVC4 (Windows XP == Visual Studio 2010). The original app was written in .net 2 with webfoms, and is a bit of a mess. The whole application seems to rely on state, where MVC is all about embracing the stateless nature of the web, as in the data you input to form A, affects the options you see in form B, options you select in form B affect form C etc etc (I love MVC and think that it is an awesome thing in the right context). The whole maintaining models between states thing is starting to get pretty messy, and I can't help but thinking that I am either doing it wrong, or not using the right tool for the job. My thoughts are that WPF would be perfect for this but the Computers are controlled by an external agency and are pretty locked down. We have slightly more control over the servers hosting the applications. The obvious next option is Silverlight(I think, maybe I'm horribly wrong!) A couple of questions. First: Is MVC ASP actually the best option here, or am I doing it wrong? Second: What argument would you present to management if you agreed with me and thought a Silverlight based application was the way to go? Using non MS based technologies is a no go. MVC4 is controversial.


Can I turn off Visual Studio white space at bottom of code files?

In any open file within Visual Studio, there is the ability to scroll all of the code out of sight". In other words, there is heaps of white space below the code lines that one can scroll to. This to me is of no use, and when I pull my mouse wheel down with aggression, my code disappears off the screen. Is there a way to turn this annoyance off? Also, can someone explain to me any logical reason as to why it's even there? ps: I tagged this question as visual-studio since I'm pretty sure it's been in every version of VS that I've ever used... though I'm currently using visual- studio-2010 ![This space is completely useless](http://i.stack.imgur.com/HKsUI.png) ![Now it's even worse because I scrolled to the bottom \(note the line #46\)](http://i.stack.imgur.com/QPfVf.png) ## EDIT Jon Galloway pointed me to another thread stating that it was added by popular request. Still makes no sense why they wouldn't make it a switchable feature on/off


Is database version control practical?

The topic of database version control seems to come up at my work and in social discussion more and more often. But the truth is, I haven't met anyone actually DOING it. The only thing Googling the topic has ever yielded are expensive products/services. Is this really all there is? Does an open source (or at least a _standard_ , and not just "Version control from company x") solution exist for ANY type of database (transactional or otherwise)? I'm in love with the idea, but I don't know where to start looking.


What is (or where can i find) the algorithm to decode FLAC to PCM?

I'm trying to program a very basic FLAC player using 100% C# completely from scratch. My understanding of this type of thing is very limited, so I'm using this project as a way to learn about compression and decompression. I'm a computer science and math major currently in university, so I'm not adverse to learning whatever math may be involved. I've looked up the format specifications on xiph.org and I understand how the headers and all are structured, but I can't seem to find a concise explanation of how the audio compression works. How do I go about converting the frames to pcm? Sadly, my knowledge of C/C++ is extremely limited, as I only have experience with Java and C#. As such, trying to navigate the c++ code already out there is not a great starting point. I looked at FlacBox and learned quite a bit from it, but it's barely commented at all and I am lost trying to figure out how the conversion from flac to pcm works. So what should I read as far as math goes so I can get started with this? Where can I find a basic algorithm for converting the audio frames to wav? Thanks.


How is 'bolt-on' the same or different from add-on, extension, or module?

I hear the term 'bolt-on' used in many contexts, specifically in my organization where PeopleSoft is used extensively. I don't know exactly how it differs from an 'extension' of an existing product, a new module within an application, or an 'add-on' like you would purchase for a product you own. Is there a more formal definition of 'bolt-on' that I'm not familiar with?


How to design this better?

I'm developing a system using .NET which will be used by multiple users. Because of that, I need to identify on the database which data belongs to each user. Explaining with an example, imagine I have the entity `Product`. Then each user has its own products, and so in the database on the table of products we must be able to distinguish between products of each user. Saying that, my solution was to add on the database an extra column for each table for the user id. Now, on my code this was the same as adding on my repositories a parameter to receive the id of the user so that the repository would be able to locate the correct data. The concrete implementation of the repository to deal with relational databases just check those columns. The problem is that to be able to get those columns available on my repository, and on my ORM (in the case EF) I needed to add on each entity one property `UserID`. The problem is that if I think for a while this doesn't seem like a good solution. I'm coupling domain entities with details of how to persist data. More than that, I'm coupling each entity with the way I manage the access to the data and this seems a bad approach. So, concearning this, is there a better way to plan this? A way to make sure we can relate data to users and in the same time avoid those properties on the domain entities?


what is the best solution for this problem

I need help. We have website(PHP site) and it has different software(like shopping cart, chat software, ticketing software, blog,.... ).


Using Django to Create Child Sites

I am creating a series of small sites, I'm using the django framework. The theory goes a user comes to a master site, signs up, then he gets his own child site. Example:   * navigate to example.com   * user creates an account "mysite"   * user then gets his own site: mysite.example.com and he can configure this all he wants My question: * would it be better to have a "gold" version of the site that gets created for each site? for instance: cp ~/goldsite ~/mysite and change the database pointers appropriately ** the downside is if I ever have to do maintenance on a file, I would have to change all subsites. ...or * have one host and configure the database to support multiple sites. The DB might get messy. Any feedback would be great.


Is it ok to start with templates in MVC development?

I'm new to web development and I've started working on a project in my company that uses DJANGO. I feel it flexible to start my development straight first from the templates. I think it will be easier if I visualize things first. So my question: Is it okay to start with a template rather than starting with models first? Will I stumble on to any sort of confusions if I go by this method of development?


Testing a very specific function in a large, complex application

I'm new to testing but wholeheartedly realize how important it is. The main issue is that my company has no top-down support for testing at all. That is we don't have any unit testing and just a bit of human testing (I hope I'm using the right terminologies). I have been trying to get testing started here and have to do it subtly because I'm often asked "when will feature X be done" and therefore can't start the week(s) long project of writing tests for all of our legacy code. Which would need to get rewritten just to provide seams for testing (if I have the concept of 'seams' right). I can, however, sneak a bit of time to test one function. Or at least I think I can. I'm writing code that basically processes quite a bit of data and then renders it using D3. I would like to write a test for one of the most important functions, `binData`. It takes one optional argument (the date to start binning from) and accesses a few properties like `this.rows` and `this.timestamps`. How would I go about doing that? I think I'll need to create a mock object to hold `this.data` and `this.timestamps` (and the other accessed properties). In fact, I imagine several different mock objects which would allow testing of several different datasets. But other than that I'm kinda stuck. In terms of frameworks I've heard of Mocha and Jasmine and Vows but don't know which would be best. I also don't know how to tie into the massive (and complex) class and module hierarchy and to meet each object's dependencies. That is, the function `binData` is in a file called, say, `dataBinner.js` which requires all sort of other functions in other files but doesn't explicitly include anything on it's own. Instead, it itself is included in a "manager" file which includes everything that dataBinner.js and the other modules will need. I suppose I'll need to find a way to instantiate everything necessary to test `binData`. I'm not afraid to do a bit (or a lot) of reading to better understand things. Any help regarding this specific task of writing a test for `binData` or the larger question of how to slowly implement testing in a non-test-friendly place would be much appreciated. CLARIFICATION I'm 100% on board, testing-wise. I know it's important and I know that my company is incorrect by not having testing. You'd expect emails that say "fixed regression caused by fixing bug 1413" would trigger something. Or that things that shouldn't take that long take waaaaaay too long ('cause it's spaghetti legacy code). What I'm asking is _given that_ how do I test my one function which relies on the legacy spaghetti code. That is, how does someone inject a bit of testing into a place without it? I'm guessing that I'll have to write my own testing framework because I'll have to create mocks for the spaghetti legacy code. So that I can instantiate my object and call my function outside of the scope of the application.


To which level Haskell's HDBC is lazy?

The HDBC documentation states: > fetchAllRows :: Statement -> IO [[SqlValue]]Source > > Lazily fetch all rows from an executed Statement. > > You can think of this as hGetContents applied to a database result set. > > The result of this is a lazy list, and each new row will be read, lazily, > from the database as the list is processed. > > When you have exhausted the list, the Statement will be finished. > > Please note that the careless use of this function can lead to some > unpleasant behavior. In particular, if you have not consumed the entire > list, then attempt to finish or re-execute the statement, and then attempt > to consume more elements from the list, the result will almost certainly not > be what you want. > > But then, similar caveats apply with hGetContents. > > Bottom line: this is a very convenient abstraction; use it wisely. > > Use fetchAllRows' if you need something that is strict, without all these > caveats. Then, I wonder, to which level does the laziness extend? Say, I can have                 conn <- connectSqlite3 databaseFilePath       rows <- quickQuery conn ("SELECT * FROM foo") []       mapM_ bar $ take n rows       disconnect conn      Will it actually only fetch `n` rows? Like, from the database point of view, will it be equivalent of `SELECT * FROM foo LIMIT (n)`? Because fetching all rows at the level of database driver and then `take`ing `n` of them seems to be silly and kind of defeats the purpose. If it's lazy up to the database itself, how's it implemented? Is it using cursors? I know there're several drivers for HDBC alone. I'm asking only about principle of implementation.


Using 'new' in a projection?

I wish to project a collection from one type (`Something`) to another type (`SomethingElse`). Yes, this is a very open-eneded question, but which of the two options below do you prefer? **Creating a new instance using`new`:**               var result = query.Select(something => new SomethingElse(something));      **Using a factory:**               var result = query.Select(something => SomethingElse.FromSomething(something));      When I think of a projection, I generally think of it as a _conversion_. Using `new` gives me this idea that I'm creating new objects during a conversion, which doesn't feel right. Semantically, `SomethingElse.FromSomething()` most definitely fits better. Although, the second option does require addition code to setup a factory, which could become unnecessarily compulsive.


Decoupling Server and Client using REST API

I was thinking about how I can decouple a web-application completely into a server-side and a client-side component. I want to decouple the app to the extent that I can host both components on seperate servers. So, for example, I would have:   1. Server 1 (API Server): A server-side component running on `Django` on something like Heroku or EC2.   2. Server 2 (Static Server): A client-side component running on `AngularJS` on a static server like S3 or CloudFront. The communication between these components will take place using a JSON REST API. **Questions:**   1. Is this approach common? advisable? > Does a company like Facebook or Twitter _mostly_ utilise the same API for > the webapp as it does for its mobile apps or its open API?   2. Is it a good idea to use oAuth2 for the login process? > So the user is redirected to a login page on **Server 1** (this is the only > page on Server 1) and then redirected back to **Server 2** with a token if > authentication succeeds. Is this the best approach? It seems like I am kinda > "breaking the flow" if I do this. Is this normal? The motivation for this is for me to be able to use the same API for my web, iOS and Android clients. Thanks!


Managing client-side and server-side validations in one place

I'm 100% on board with the case that one should definitely use both client- side and server-side data validations. However, in the frameworks and environments I've worked in, the approaches I've seen have never been DRY. Most of the time there's no plan or pattern - validations are written in the model spec, and validations are written in the form on the view. (Note: Most of my first-hand experience is with Rails, Sinatra, and PHP w/ jQuery) Mulling it over, it seems like it would not be difficult to create a generator which, given a set of validations (e.g. model name, field(s), condition), could produce both the necessary client-side and server-side material. Alternately, such a tool could take the server-side validations (such as the `validates` code in an ActiveRecord model) and generate client-side validations (such as jQuery plugins, which would then be applied to the form. Obviously, the above is just a "hey I had this idea" musing, and not a formal proposal. This sort of thing is surely more difficult than it seemed when the idea hit me. That brings me to the question: **How would you approach designing a "write once, run on server and client" technique for data validation?** Related subtopics: Do tools like that exist for any particular frameworks or client-server technologies? What are major gotchas or challenges with trying to maintain only one set of validations?


Should my multi-server RDBMS or my Application handle database Referential Integrity?

Should items like Foreign Keys, Constraints, Default Values, and so on be handled by the database management system (in this case, MS SQL 2005) or the application? I have heard opinions from both sides and I'm honestly not sure which way to go. There is a chance we will be spanning multiple servers/databases and I don't think Foreign Keys can be used across linked servers. In addition to that, there are some circular references in the database design which prevents me from using `ON UPDATE CASCADE` on everything. The database is MS SQL 2005 (possibly 2008) and all interactions with it should go through the application.


How to model a system to help my team grasp the project's bigger picture?

According to the software engineering point of view, I should model the system to make it easier for other people to understand well what they work on. To do so, I have used the Dia drawing program. But, after having used Dia for some time, I find that it falls short in helping me to correctly and efficiently model my project. How do you usually tackle this problem (modelling a project in the large) and what tools would you recommend for the job, and why?


Why some consider static analysis a testing and some do not?

Preparing myself also to ISTQB certification, I found they call static analysis actually as a static testing, while some engineering book distinct between static analysis and testing, which is the dynamic activity. I tent to think that static analysis is not a testing in the true sense as it does not test, it checks/verifies. But sure I would love to hear opinion of the true experts here. Thank you


Why does an unsigned int compared with a signed character turn out with an unexpected result?

Why does the following code output **y>x** when clearly 1>-1?               unsigned x=1;     signed char y=-1;          if(x>y){         printf("x>y");     }     else {         printf("y>x");     }      Please explain this result.


Is there a semi-scientific term for this filtering behavior?

I'm looking for the term that applies to a certain kind of filtering behavior. It's often used in webshop-like interfaces, where large amounts of data are filtered based on a selection of filter criteria. The most distinguishing feature is that _it's impossible to pick a filter criterium that leads to no results_ , as the filters that would do so are hidden with real-time updates. To see an example look at this boot finder section on the blue-tomato.com webshop. Is there a term for this kind of filtering?


How to verify the client's view is consistent with the remote model?

i'm designing a client-server system via web broswser and i have this problem: I send the data to the client via JSON, then the javascript view shows the stuff. Then the user takes actions and commands are sent back to the server. Usual stuff, the problem is what if the view's data is corrupted or old? One solution i thought is making a hash via SHA1 or some other algorithm of the full objects in the client's model, but JSON data is not ordered, also this adds delays to the system. How do google docs manages this kind of thing? Also, sending ALL THE DATA, every time the model is updated doesn't make sense, but how do i keep consistency by only sending changes? I think the whole problem is just one.


Paid open-source app

The question that bothers me is whether it is possible/feasible/reasonable to expect for an open-source app to sell well on the mobile market? Should I believe that my users will use my app, rather than build the checked- out version, and, more important, how can I deal with the competition if I make my app available under an OSS license? So far the only link on the subject I've found is http://blog.zachwaugh.com/post/17554643060/selling-open-source-apps however it deals with a Mac OS X app. I should mention my question does not focus on iOS, Android or another OS, it's about mobile applications in general. EDIT: The very reasonable question of whether my users are programmers has been asked.   I do not expect most of my users to be even remotely familiar with programming.


Minima of a convex list using binary search

A list is strictly convex if its elements first decrease then increase. How can I write a function in python that accepts a convex list and returns its minima in time complexity O(log(n)), n being the size of the list. (NO USE OF ANY BUILT IN FUNCTIONS OVER LISTS)


"Ever change the value of 4?" - how did this come into Hayes-Thomas quiz?

In 1989 Felix Lee, John Hayes and Angela Thomas wrote a Hacker's test taking the form of a quiz with many insider jokes, as “Do you eat slime-molds?” I am considering the following series:               0015 Ever change the value of 4?     0016 ... Unintentionally?     0017 ... In a language other than Fortran?      Is there a particular anecdote making the number “4” particular in the series? Did some Fortran implementation allow to modify the value of constants? Was this possible in other languages in common use at that time?


Why should I use reflection?

I am new to Java; through my studies, I read that reflection is used to invoke classes and methods, and to know which methods are implemented or not. When should I use reflection, and what is the difference between using reflection and instantiating objects and calling methods the traditional way?


Telecommuting from Australia - tax arrangements

I live in Australia, and I am currently looking at some of the remote job offerings in countries like US/UK. However I have very little understanding of what needs to be done to report that kind of income - i.e. do I need to get an ABN, pay payroll tax myself etc. If you had any experience in this area I would like you to share that.


Release an upgraded iOS app with a different revenue model

I am starting a new iOS project and initially plan release a simple free version to gather feedback. I don't intend to monetize or market this initial version. However, I believe "Version 2" of this app will be good enough to pay for. I would prefer to release Version 2 as an upgrade from Version 1 rather than release it as a separate app. This way I can reserve a name for the app. It will also be easier to keep everything in a single repository. Are there any downsides of this approach? It's my understanding that I can change the price of an app at any point in time, so it shouldn't be an issue transitioning to a paid app, should it?


Naming conventions for variables

When programming, what naming conventions do you use for your variables? I don't mean when the name of the variable should be obvious; ie. sum, total, first, last. But when you name variables that don't really fit into a category/obvious structure, what sort of names do you use? Is it, myVar1 or test1 or variable1, etc...?


How exactly do Patchers work?

Did a search for Patchers and didn't find anything. But seriously Patchers: How do they work? I've done some googling, and i've gotten mixed results. I mean it seems they probably have some way of going in and changing the files (maybe comparing what is different between the files) but it seems like there is probably more going on than that. Or is it really as simple as running a diff. vs another file....and then applying the changes?


XQuery & XML databases

I decided to learn XML from a professional book instead of reading tutorials online, after some research i decided to read "Beginning XML, 4th Ed" book and it was very interesting book and i recommend it to anyone want to learn XML, my question is: does reading & learning these chapters:   1. XQuery, the XML Query Language   2. XML and Databases really required for someone who is doing mainly: Hibernate/JPA for object/relational persistence? or in other words does learning XQuery & XML databases really required by the current industry standards skills ? Thanks in advance


Java and rest OOP languages - when to use super or this keywords

I have been programming java for like a year or more, and i have always used the `this` and `super` keywords. And yesterday my mate read one source of mine, and told me not to over use it unless you are overriding the method.               class A extends JPanel {          public A {              super.setSize(400, 400);// instead of not using super keyword          }     }      But what he meant on how to use it, is this:               class A extends JPanel {         public A {             super.setSize(4,4);         }              public void setSize(int a, int b) {}     }      So the language will know that your constructor calls the parent method and not local. Should i only use the the keywords in this situation only or use the keywords everywhere for better readibly? I know that `this` keyword is returning the whole local instance including the parent and all of its parents and interfaces. And the `super` keyword returns the instance of the parent class and all of its instances (parents and interfaces). But my question is, should you always use these keywords?


Which websites to use for presenting free open source applications?

After releasing a new free open source application, I would like to present it to as many people as possible. What are web sites (directories) which one should use to present free open source applications? Looking for a list of sites like Freshmeat, Sourceforge, ...


Android: Considering an ORM tool

I am developing an Android app in which I have to add chat functionality. Also, I have to save the chat history. I will accomplish this task using SQlite. But, I am not sure whether should I consider using an ORM like GreenDAO or ORMLite or I should use traditional way of persisting data in SQLite. Actually, I am not clear when should go for using an ORM and how do I get benefit from it.


Best Practices and Etiquette for Setting up Email Notifications

If you were going to set up a Email Alerts for the customers of your website to subscribe to, what rules of etiquette ought to be followed? I can think of a few off the top of my head:   * Users can Opt-Out   * Text Only (Or tasteful Remote Images)   * Not sent out more than once a week   * Clients have fine-grained control over what they receive emails about (Only receive what they are interested in) What other points should I consider? From a programming standpoint, what is the best method for setting up and running email notifications?   * Should I use an ASP.NET Service? A Windows Service? What are the pitfalls to either?   * How should I log emails that are sent? I don't care if they're received, but I do need to be able to prove that I did or did not send an email.


Is HDTV good as a programmer's monitor?

I'm wondering if someone has any experience with programming on an HDTV. I'm trying to decide between dual pc monitor vs one big HDTV, like 32" (or maybe even dual hdtv). The nice thing about hdtv is that they cost alot less than an equivalent sized pc monitor. I will specifically be using this for programming and graphics (photoshop, etc). I'm just wondering if HDTV is bad if I use it as a workstation b/c maybe it's worse for the eyes or not really good for programming (b/c maybe the fonts won't be crisp enough), etc. Any thoughts? Thanks


Is Extreme Programming (XP) the best way of learning from experts?

I have been involved in many development models, and have found XP to be the best for a new programmer from the aspect of learning, as the collaboration between the team members is very high and the opportunities to share knowledge are great. What are the expert opinions on this?


Who can change the View in MVC?

I'm working on a thick client graph displaying and manipulation application. I'm trying to apply the MVC pattern to our 3D visualization component. Here is what I have for the Model, View, and Controller: Model - The graph and it's metadata. This includes vertices, edges, and the attributes of each. It does not contain position information, icons, colors, or anything display related. View - This would commonly be called a scene graph. It includes the 3D display information, texture information, color information, and anything else that is related specifically to the visualization of the model. Controller - The controller takes the view and displays it in a Window using OpenGL (but it could potentially be any 3D graphics package). The application has various "layouts" that change the position of the vertices in the display. For instance, one layout may arrange the vertices in a circle. Is it common for these layouts to access and change the view directly? Should they go through the Controller to access the View? If they go through the Controller, should they just ask for direct access to the View or should each change go through the controller? I realize this is a bit different from the standard MVC example where there a finite number of Views. In this case, the View can change in an infinite number of ways. Perhaps I'm shattering some basic principle of MVC here. Thanks in advance!


Object oriented programming concepts

> Specifically, programming without inheritance is distinctly not object- > oriented; we call it programming with abstract data types. I found this great line from Grady Booch's "Object-Oriented Analysis and Design With Applications" book. So in order for a program to be an OO one, are inheritance, abstraction, encapsulation, and polymorphism(?) must-to-be things? Could anybody please explain me?


Which EXPLAIN SELECT is better -- the one in PostgreSQL or the one in MySQL?

Or are the two basically the same when it comes to figuring out how to build the right indexes?


Putting semicolons after while and if statements in C++

How come in C++ when you put:               while (expression);      the while loop doesn't run no matter if the expression is true or not. However if you put:               if (expression);      the statement runs no matter if the expression is true or not. It seems like they should both behave the same way.


How does this normalized example work?

I had the following DB schema:               Customer   Car     Rental     -------   ----     ------     Name      Name     Car_ID     ID        ID       Customer_ID                        Date      This is said to be non normalized as the date can repeat (multiple customers can rent a car at the same day). So the teacher said it should be like:               Customer  Car Date     ------    --- ----      and linked with foreign keys. Well I do not get that - how can I then simply enter that "John rented a BMW on 2/3/2013"?


How do I efficiently store all OpenStreetMap data in an indexed way?

I have a PBF file that contains the following information about a country:   * Nodes, each with their own longitude, latitude and properties; used to store points in a 2D space.   * Ways, each with their properties, they are connected through nodes; used to store roads, boundaries. While this file is only 80 MB in its compressed form, it's 592 MB when uncompressed and stored in a DB. Yeah, and that's only for one country, Belgium. Imagine storing France, Germany and Italy alongside. * * * Let's take a single highway for example, from Antwerp through Brussels to Charleroi. This would consist of a ton of nodes to store all the turns in the highway, but do I need all these turns? I doubt it. Let me tell you what I want to be able to do:   * I want to view the map at different zooming levels; major cities, minor cities and street level at least.   * I want to be able to get routing information between two points.   * I want to be able to compute the nearest road to my GPS location.   * Search for a location, by means of an index in the database. But most importantly, **the database shouldn't be too big as it will be stored on a mobile device**. * * * So, I thought about a combination of two techniques:   * Image tiles for viewing purposes, to working around storing/processing all the individual nodes.   * Storing the endpoints of roads for routing information, alongside information about the road. The problem with this is that I can't compute the nearest road to my GPS location with only this information; imagine that a bend in a highway, I can't determine that I'm on the highway with just the two endpoints. I was thinking about storing intermediate nodes between endpoints but that would be very costly to generate, I think. Also, determining the endpoints of roads (that are like a T-split) is most likely not even that easy as I need to figure out whether I need to store the midpoint at the top of that T-split or not. So, viewing is easy using image tiles; but I can't find an easy way to do routing and GPS location finding, what kind of storage technique should I be looking into? I find it a bit inconvenient that a `80 MB` file turns into a database of `592 MB`, I want to reduce that size a much as possible... What can I do to do this as efficiently as possible? In terms of disk and CPU. I'm targeting a WP7...


Splitting up a single project into libraries

I am working on a project/application that I feel is not very well organized, and parts of it intertwine in different ways. Everything works, but I can see things are not very modular. _Is it reasonable to split up an application into various libraries, even if they might not be reused by another application?_ Just the mere thought of splitting it up into libraries reveals many problems with the current system. I feel it will encourage better design, and future reuse (There are talks of a new project that seems it could benefit from at least some of these libraries). My concerns are   * How will it affect perfomance?   * How far should I go in splitting things up?   * If three libraries all depend on each other, is there a point in making them libraries? (perhaps it suggests a re-architecture of the modules) My question seems to go against the wisdom of this answer, in that _Dynamic libraries should never be created for a single app_. Then the question becomes- how to ensure modularity in a large application? Thanks! **EDIT:** It seems I have used the term "shared library" too much, so I removed it to imply any kind of library (either static or dynamic). The essence of the question is whether to split stuff up into any type of libraries.


Oracle Enterprise JavaBeans (EJB) Developer Certification

I would like to gain the "Oracle Enterprise JavaBeans (EJB) Developer" certification. According to this page I have to take a number of classes each of which costs up to a couple of thousand GB£. Is this really the only way to obtain the certification? Can I not just buy a certification guide book from amazon and just sit the requisite tests? At the moment I have no Java EE experience and I'm finding it impossible to get interviews for the jobs I'm interested in. I'm hoping this will at least help me get my foot through the door.


SQL-99 specification, is it specified to first order the result and limit it afterwards?

If I wrote this in MySQL               SELECT * FROM foo ORDER BY bar LIMIT 1      it would first order the result and limit it afterwards. I always get the lowest bar. I wonder if this is specified like this in SQL-standards and how to check that? All I found are some BNF's which do not explain how something should work, but only what syntax is valid.


Need to make my code more readable to the other programers in my team

I am working a project in **delphi 7** and I am creating a installer for the application, there are Three main parts.   1. **PostgreSQL** installation/uninstallation   2. **myapplication** ( setup of myapplication is created using nsi) installation/uninstallation.   3. **Creating tables** in Postgres through script(batch files). Every thing runs fine and smoothly, but if something fails I have created a logger which will log every step of the process,   like this               LogBook.Log('[POSTGRESQL INSTALLATION]  :  [ACTION]:Postgres installation started');      The function `LogBook.Log()` This will write the contents to a file. This is working nicely, but the problem is this has messed up the code as in it has become difficult to **read** the code as one ca only see the `LogBook.Log()` function call everywhere in the code an example                if Not FileExists(sOSdrive+'\Mapannotation.txt') then      begin         if CopyFile(PChar(sTxtpath+'Mapannotation.txt'), PChar(sOSdrive+'\Mapannotation.txt'), False) then            LogBook.Log(2,'[POSTGRESQL INSTALLATION] :  [ACTION]:copying Mapannotation.txt to '+sOSdrive+'\ sucessful')            else            LogBook.Log(2,'[POSTGRESQL INSTALLATION] :  [ACTION]:copying Mapannotation.txt to '+sOSdrive+'\ Failed');      end;      if Not FileExists(sOSdrive+'\Mappoint.txt')      then        begin          if CopyFile(PChar(sTxtpath+'Mappoint.txt'), PChar('c:\Mappoint.txt'), False) then            LogBook.Log(2,'[POSTGRESQL INSTALLATION] :  [ACTION]:copying Mappoint.txt to '+sOSdrive+'\ sucessful')        else            LogBook.Log(2,'[POSTGRESQL INSTALLATION] :  [ACTION]:copying Mappoint.txt to '+sOSdrive+'\ Failed');      end;      as you can see there are lots of `LogBook.Log()` calls,   before it was                if Not FileExists(sOSdrive+'\Mapannotation.txt') then         CopyFile(PChar(sTxtpath+'Mapannotation.txt'), PChar(sOSdrive+'\Mapannotation.txt'), False)       if Not FileExists(sOSdrive+'\Mappoint.txt')      then        CopyFile(PChar(sTxtpath+'Mappoint.txt'), PChar('c:\Mappoint.txt'), False)      this is the case in my whole code now.   its difficult to read. can any one suggest me a nice way to unclutter the calls to log? like   1. Indenting the ' LogBook.Log()` call   like this                 if Not FileExists(sOSdrive+'\Mapannotation.txt') then          begin              if CopyFile(PChar(sTxtpath+'Mapannotation.txt'), PChar(sOSdrive+'\Mapannotation.txt'), False) then             {Far away--->>}                   LogBook.Log(2,'[POSTGRESQL INSTALLATION] :  [ACTION]:copying Mapannotation.txt to '+sOSdrive+'\ sucessful')        else             {Far away--->>}                   LogBook.Log(2,'[POSTGRESQL INSTALLATION] :  [ACTION]:copying Mapannotation.txt to '+sOSdrive+'\ Failed');        end;        2. Separate **unit** like `logger`   This unit will have all the log messages in a `switch case` like this               Function LoggingMyMessage(loggMessage : integer)           begin     case  loggMessage of          1         :  LogBook.Log(2,'[POSTGRESQL INSTALLATION] :  [ACTION]:copying Mapannotation.txt to '+sOSdrive+'\ sucessful');     2         :  LogBook.Log(2,'[POSTGRESQL INSTALLATION] :  [ACTION]:copying Mapannotation.txt to '+sOSdrive+'\ Failed');        150        :  LogBook.Log(2,'[somthing] :  [ACTION]: somthing important);          end;      so I can just call the LoggingMyMessage(1) where ever required. Can anyone tell me which is a better and cleaner approach to logging this way?


Managing codebase for basic and pro edition of a project

I have a project which will have basic and professional edition. The professional edition will have all the features of the basic edition. I am using git to manage the project's codebase. I consider that I will fork repo of the basic edition after I completed it. Then, I will start to code the professional edition on the forked repo. My problem is that if there would be a bug in the basic edition in the future, I don't want to fix the bug in the basic edition and professional edition twice. How to handle this situation?


How can we make agile enjoyable for developers that like to personally, independently own large chunks from start to finish

We’re roughly midway through our transition from waterfall to agile using scrum; we’ve changed from large teams in technology/discipline silos to smaller cross-functional teams. As expected, the change to agile doesn’t suit everyone. There are a handful of developers that are having a difficult time adjusting to agile. I really want to keep them engaged and challenged, and ultimately enjoying coming to work each day. These are smart, happy, motivated people that I respect on both a personal and a professional level. The basic issue is this: Some developers are primarily motivated by the joy of taking a piece of difficult work, thinking through a design, thinking through potential issues, then solving the problem piece by piece, with only minimal interaction with others, over an extended period of time. They generally complete work to a high level of quality and in a timely way; their work is maintainable and fits with the overall architecture. Transitioning to a cross- functional team that values interaction and shared responsibility for work, and delivery of working functionality within shorter intervals, the teams evolve such that the entire team knocks that difficult problem over. Many people find this to be a positive change; someone that loves to take a problem and own it independently from start to finish loses the opportunity for work like that. This is not an issue with people being open to change. Certainly we’ve seen a few people that don’t like change, but in the cases I’m concerned about, the individuals are good performers, genuinely open to change, they make an effort, they see how the rest of the team is changing and they want to fit in. It’s not a case of someone being difficult or obstructionist, or wanting to hoard the juiciest work. They just don’t find joy in work like they used to. I’m sure we can’t be the only place that hasn’t bumped up on this. How have others approached this? If you’re a developer that is motivated by personally owning a big chunk of work from end to end, and you’ve adjusted to a different way of working, what did it for you?


How to get into web coding?

I don't know how to get into this area, or more specifically, become a website maker. Here's what I now   * html   * some java script   * C#   * and a little of everything else (php, css, xhtml, ect.) I've been on w3schools.com for a while reading and doing the tutorials and I've become much more knowledgeable about websites since I started. But when I compair what I've learned from w3schools to a website template I downloaded I notice things in this template that w3schools never even mentioned. What I'm wondering is whats the best way to go about becoming a web coder on your own, would it continuing w3schools be good? Or just download template read through them and figure out how the code works? One more question, I noticed these all use SQL, how do I go about learning SQL? and sorry, I lied, one more question, whats the best step process when learning web code? like what order, html then css then php? or html then xhtml then css? that kinda thing. thanks, Robert Edit: A website like this is my goal in this area: geforce.com Do you think making a website like this is difficult from a expert's view?


Should I invest time learning Coffeescript?

I am a freelancer and I earn my bread and butter by helping others write better java-script code. I have good experience with most of the JavaScript frameworks around. I am wondering if it is worth for me to invest time in learning coffeescript. Who should learn it and who need not ?


Implications of crediting a book source in a code file available under an open license

I'm writing some OS software just for funsies, and it's licensed using MS-PL (ie, do pretty much anything you want with it). It's a project from which I'm using many different sources (lots of personal reading/research going into it) and I'm crediting the original book/writer in the comment header(s) of the files as applicable. I'm doing it so that if anyone actually decides to read or use the code, they can refer to the original sources that inspired the work. Of note:   * I own a copy of each source   * All of the sources are able to be purchased by the general public (amazon)   * As far as I can tell, none of the books explicitly state that the code is licensed   * None of the code is copied verbatim. I've translated it all from various languages (mostly C++) to C#, and when appropriate I've added exception handling etc.  I'm just wondering if there are any implications of sourcing these books in a freely open source application/library.


Best practices for retrofitting legacy code with automated tests

I'm about to take on the task of reimplementing an already defined interface (a set of C++ header files) in a relatively large and old code base. Before doing this, I would like to have as complete test coverage as possible, so I can detect reimplementation errors as early and easily as possible. The problem is that the already existing code base was not designed to be easily testable, with (very) large classes and functions, a high degree of coupling, functions with (many) side effects, etc. It would be nice to hear of any previous experience with similar tasks, and some good and concrete tips on how you went about retrofitting automated tests (unit, integrations, regression, etc.) to your legacy code.


Introduce unit testing when codebase is already available

> **Possible Duplicate:**   >  Best practices for retrofitting legacy code with automated tests I've been working on a project in Flex for three years now without unit testing. The simple reason for that is the fact that I just didn't realize the importance of unit testing when being at the beginning of studies at university. Now my attitude towards testing changed completely and therefore I want to introduce it to the existing project (about 20000LOC). In order to do it, there are two approaches to choose from: 1) Discard the existing codebase and start from scratch with TDD   2) Write the tests and try to make them pass by changing the existing code Well, I would appreciate not having to write everything from scratch but I think by doing this, the design would be much better. What would be your approach?


How to unit test large legacy systems?

> **Possible Duplicate:**   >  Best practices for retrofitting legacy code with automated tests When working in large legacy systems (large systems with no unit testing ever) I often come across people saying use unit testing as a tool against possible bugs. I wonder if somebody have tried it on large systems with no unit testing at all. Of course it is easy to say unit testing helps ,but in large systems it can hugely time consuming process. It can take months if not years to fully unit test each part of the application . When you are asked to make a functionality which is modification of existing functionality or adding new functionality to the application, how would you go about it? Of course there will be lots of instances where code in different classes will look similar and you would want to re-factor those classes which without proper unit testing can and most likely will open a can of worms. So how would you go about unit testing large applications? And what other measures would you use to reduce possible bugs from your coding (of course some bugs will probably remain anyway)?


Is Scrum based on 'daily reporting'?

Google translates '早请示晚汇报' as 'Consult early and late reporting' or 'Ask for instructions to report back later'. Bing translates as 'Early and late reporting'. Some translated content: > The politics invaded all aspects of daily life during the **Cultural > Revolution** , as **早请示晚汇报**. Every day at a political activity or ceremony, > everyone, after getting up or reported to work/study, had to " _consult the > great leader Chairman Mao_ ," about that day's work, study. At the end of > the day/before going to bed, everyone had to _confess_ to the "Great Leader > Chairman Mao," that day's work/learning. **Late reporting** is called " > _confessing his/her sin_ ," because a day's work or study certainly would > contain errors, which delayed revolutionary work; hence, the person would > confess, " _I am sorry, great leader_ ", akin to " **confessing his/her > sin**." However, as "confessing one's sin," has a serious religious > undertone to it, so it was not considered appropriate and was renamed to " > **late reporting.** " Anywhere people gathered--schools, army, cadre > schools, community centers that provided three meals per day--everyone > involved had to appear for the **collective report**. Here is another excerpt that sounds beautiful even after machine translation: > Anyway, several times a day for several years removed from the > "instructions", "reporting" so that "life" of this short period of time is > finally free of political control winding all the time, everyone has a sense > of relief. Ref: Lin Zhao, a blog entry, a news paper article I feel compelled to be certain that this practice is definitely the source of 'Scrum' process. Some of these similarities cannot simply be ruled out as coincidences. My question is,   "Is there really a relation? If so, should we read some mission statements before we begin work, and we have stand-ups at the end of the day, before we leave?"


Webserver / DB / Application - Best way to setup the system for performance

I have a turbogears app that I am bringing live that uses a postgresql DB on the back end. From a performance issue am I better off having the DB and app on separate server or on the same server? If on the same server and I better off having the DB on a separate physical drive?


What is one correct architecture when using a DB with multiple clients?

We have a legacy system with data stored in a SQL database. Several clients connects to this database using a web service. The web service expose a lot of "commands" to query the database and to "do" operations. So far, so good. However, new operations need to be added and the web service cannot be extended. We can add a new service that would implement the operations from the old one (somewhat easy) and add our own operations. At the same time we want to enhance the performance of the web service by having multiple requests bundled as one request (the responses would come out as a bundle too). One desirable outcome would be to isolate the application from the web service using programming interfaces and a somewhat generic messaging (or whatever) mechanism. We are contemplating several ways to effectively support multiple clients: enterprise service bus, a request/response service layer, ORM with client/server architecture... Has anyone been confronted to such issues and what did you end up with?


What happens if I do not explicitly state "This program comes with absolutely no warranty"?

And lets say, my application is a simple feed reader. Does my app really have to include the no warranty notice?


Do I need to know servlets and JSP to learn spring or hibernate or any other java web frameworks?

I've been asking a lot of people where to start learning java web development, I already know core java (Threading,Generics,Collections, a little experience with (JDBC)) but I do not know JSPs and servlets. I did my fair share of development with several web based applications using PHP for server-side and HTML,CSS,Javascript,HTML5 for client side. Most people that I asked told me to jump right ahead to Hibernate while some told me that I do not need to learn servlets and jsps and I should immediately study the Spring framework. Is this true? do I not need to learn servlets and JSPs to learn hibernate or Spring? All of their answers confused me and now I am completely lost what to learn or study. I feel that if I skipped learning JSP and servlets I would missed a lot of important concepts that will surely help me in the future. So the question, do I need to have foundation/know servlets and JSP to learn spring or hibernate or any other java web frameworks.?


Project management tool built into visual studio

My friend and I are working on a project together in visual studio, and we are using subversion for source control. We have used php based project management tools before for task and bug tracking, but we find it inconvenient to go to work in visual studio for hours then have to go find the website and log in and report on what we already made commit notes for, especially since sometimes we are working off line and then have to remember to go back and update the trackers. We are wondering if there is a project management tool (or set of tools) that is built into (slash an add-on) Visual Studio that will work with AnkhSvn allowing multiple people to maintain and track tasks.


Which format is best for the first prototype not on paper?

Console app (my favorite), quick & sloppy form, MS Paint (for GUI); what works best most of the time for your standard application? why?


Generating stats from large data set

I would like to do a following: I have a fairly large data set, say billions of rows, each row having multiple binary columns. I would like to generate estimated stats with some certainty about those rows. Stats would have a simple form: how many rows are there with columns 1, 7 and 10 set. Obviously going through entries is not a viable solution. To be honest, I would prefer not touch the data set at all when I have to provide an estimation. I would like to precompute everything and then used precomputed data to answer questions about the data set. Do you know of any algorithms/techniques of solving such problem?


Is it good to keep the bugfix comments within the code?

My team is using clear-case as the version control. The project which I am working is not started 7-8 years back. During the entire life time of the project we had several releases bug-fixes service packs etc. The issues are tracked using the bug tracking system and most of the people who work on the bug-fixes follows a routine of enclosing the comment in START/END block with the date, author, bug-id etc. I feel this is quite irrelevant and making the code cluttered and uneasy to maintain and these are the things which must be part of check-in comments/labels etc, where we can keep additional life cycle information of the work product. What's the best practice to be followed? Some of the reviewers of the code insist to out the comments about the bug and fixes to ease out their life. In my understanding they must review the files by mapping it to a view and get the change log of the branch and review it. It would be helpful if I can get some best practices on submitting the updated code for review.


Importance of algorithms in a telephonic interview

I had taken a telephonic interview and the interviewer has given some problem for which I was supposed to give him the algorithm. Since its was a telephonic interview and I had no paper or pen, so I could not give him the correct solutions. So I got bit demotivated that my problem solving skills are very low (I have a decent exp on developing software). How do you overcome these kind of situations and suggestions to improve algorithm skills especially while facing these kind of tactical interviews.


Protecting an Application with Logins

I am a beginner Java programmer, and have tried searching for a way to set up a login system with my Java application. The application is a game and I do not want people to just upload it to a website so others can down load and play. I want to use something like MySQL to make the user authenticate in order to use the application. Does anyone have a suggestion?


Color schemes generation - theory and algorithms

I will be generating charts and diagrams and I am looking for some theory on color schemes and algorithm examples. Example questions:   * How to generate complementary or analogous colors?   * How to generate pastel, cold and warm colors?   * How to generate any number of random but distinct colors?   * How to translate all that to the hex triplet (web color)? My implementation will be in AS3 but any examples in pseudocode are welcome.


How can Lisp produce an iterative process from a recursive procedure?

I am starting to learn Lisp, using the SICP book. The authors mention that a procedure (i.e. function) can be recursive or iterative. Additionally, the process those procedures will generate will also be recursive or iterative, and that, surprisingly, a recursive procedure can sometimes generate an iterative process. The example given is the factorial procedure, which is a recursive procedure, but which generates an iterative process:               (define factorial n)         (iter 1 1 n))          (define (iter product counter max-count)         (if (> counter max-count)             product             (iter (* counter product)                   (+ counter 1)                   max-count)))      And here's a quotation from the book: > One reason that the distinction between process and procedure may be > confusing is that most implementations of common languages (including Ada, > Pascal, and C) are designed in such a way that the interpretation of any > recursive procedure consumes an amount of memory that grows with the number > of procedure calls, even when the process described is, in principle, > iterative. The implementation of Scheme we shall consider does not share > this defect. It will execute an iterative process in constant space, even if > the iterative process is described by a recursive procedure. **Question** : I understood the principles involved (i.e. the what) but I still don't understand how the Lisp interpreter/compiler will generate an iterative process from a recursive function, being able to calculate it using constant space, and why most other languages are not able to do it.


Is it considered bad practice to have PHP in your JavaScript

So many times on this site I see people trying to do things like this :               <script type="text/javascript">       $(document).ready(function(){               $('<?php echo $divID ?>').click(funtion(){            alert('do something');          });            });     </script>      I don't think that this is some sort of pattern that people naturally fall into. There must be some sort of tutorial or learning material out there that is showing this, otherwise we wouldn't see it so much. What I'm asking is, am I making too big a deal of this or is this a really bad practice? **EDIT :** Was speaking to a friend of mine about this who often puts ruby in his JavaScript and he brought up this point. Is it ok to dynamically place application wide constants in your JavaScript so you don't have to edit two files. for example...               MYAPP.constants = <php echo json_encode($constants) ?>;      also is it OK to directly encode data you plan to use in a library               ChartLibrary.datapoints = <php echo json_encode($chartData) ?>;         or should we make an AJAX call every time?