Naming conventions used for variables and functions in C

While coding a large project in C I came upon a problem. If I keep on writing more code then there will be a time when it will be difficult for me to organize the code. I mean that the naming for functions and variables for different parts of the program may seem to be mixed up. So I was thinking whether there are useful naming conventions that I can use for C variables and functions? Most languages suggest a naming convention. But for C the only thing I have read so far is the names should be descriptive for code readability. EDIT: Examples of some examples of suggested naming conventions:   * Python's PEP 8   * Java Tutorial I read some more naming conventions for java somewhere but couldn't remember where.


How can this all fit into 64kb?

So, I am here at assembly 2011 and there was this demo played: http://www.youtube.com/watch?v=69Xjc7eklxE&feature=player_embedded It's one single file only, it says that in the rules. So I repeat, how have they made this to fit into so small file?


Looking for a large collection of XML files

Hey, I'm writing a program that I need to test with 1000s of XML files - any idea where I can get some?


What is the clause in an employee contract that says they own all your code?

I am looking at my employee contract and I can't seem to figure out where it might say that they own all the code that I write, be it at work or at home. Any examples of what the wording could be like?


stackoverflow induced passivity - how to cope?

After not _really_ working on my pet project for a while, I discovered Stackoverflow and upon perusing it more intensely I was quite amazed.   I'm a bit of a perfectionist, so when I found eye-openers here highlighting many of the mistakes I made, I first wanted to fix everything.   However, it's a **pet** project for a reason: I'm self-taught and I'm studying psychology, so programming skills can never become priority one (though it often helps, even in this field). Issues that stuck out were   * numerous security issues (e.g. CSRF-prevention and bcrypt eluded me)   * not object-oriented (at least the PHP part, the JS-part _mostly_ is)   * no PHP framework used, so many of my DIY takes on commonly-tackled components (auth, ...) are either bad or inefficient   * **really** poor MySQL usage (no prepared statements, mysql extension, heard about setting proper indices two days ago)   * using mootools even though JQuery seems to be _fashionable_ , so there's more probably always going to be better integration with services I'd like to use (like google visualization) So, my SO-induced frenzy turned into **passivity**. I can't do it all (soon) in the rather small amount of spare time I can spend on working on my project.   I can leave some of the issues be in good conscience (speed stuff: an unfinished & unpublished project will never become popular, right?).   No clear conscience without good security though and if I don't use a framework for _auth_ and other complex stuff I'll regret having to do it myself. One obvious answer would probably be going open-source, but I think the project would need to become more impressive before others would commit to it. I can't afford to employ someone either. I do think the project deserves being worked on, though. How should I tackle it **anyway**? What's the best practice for little-practice people? * * * I couldn't edit my question, because it was transferred. I would have emphasised, that I have a working product, but like so many pet projects it will _never be finished_ , so I intended to make things easier for myself in the future too. Some of you mis-guessed my problem as being afraid to get started, but I couldn't react up here, sorry. I'm surprised that no one seems to think that using a framework would be a good way to relieve myself of some responsibilities (such as implementing an authorization module that conforms to these specs.   Or is it just too hard to turn to something like an MVC when you have been working process-oriented before?


Build automation: Is it usual to use QMake for non-Qt projects?

So, I'm planning to write a C++ library and I want it to be cross-platform, and as this library won't deal with UI and I want it to have as little dependencies as possible, I won't be using Qt (actually Qt won't really help me to achieve what I want, all I plan on using is STL and Boost). Now when it comes to build a cross-platform project, I really like QMake as it's extremely easy to use and I have experience with it. I also heard good things about CMake, though I really doubt it's as easy to use as QMake. Anyway, here is my question: Should I stick with build automation tool that I know or is QMake just out of context for a non-Qt project? Should I take this as an opportunity to learn CMake? Or is there a better alternative to these two?


What information should be in the github README.md?

What information would you expect to see in the github README? Should everything go in the README? i.e.   * Introduction   * Installation   * Versions   * User Guide   * Implementation   * Testing   * Related Resources Or should you just put certain things in the README (Introduction, Installation, Versions) and the other information is best placed in the Github wiki?


Cold, neutral attitude to programming languages - sign of a pro developer or not

A profesional developer Zed Shaw says this: > Which programming language you learn and use doesn't matter. Do not get > sucked into the religion surrounding programming languages as that will only > blind you to their true purpose of being your tool for doing interesting > things. So, being neutral to languages is a sign of a good/pro developer? We see worshipping and holywars what language is better. The good coder does not care about tools, he only thinks what software he writes (like writer does not care about pen he uses - he thinks about the BOOK content)   1. should a programmer develop total ignorance to language as tool he uses?   2. **is it a sign of pro developer** , if he does not care what language to use?


How to create a Web app that "interacts" with email?

I have a web host that supports cPanel and email addresses. I'm interested in creating a web app that checks for email messages, reads their contents and then does something with them, like interact with a database. For example, Bob with email bob@gmail.com links his email address to his account on my web app. He sends an email to storethis@webapp.com with subject "Shopping List" and message "Apples, bananas, kiwis, milk", along with an attachment. The web app receives this email, and then parses the email's contents and stores this data into a database. How can I implement this?


How a port "listens", pull or push?

When you write a code to listen from a port, like 80 for example, what happens under the hood? Is the method the OS uses to listen is pull, or push? In other words, does the OS checks that port every x milliseconds for example? I just don't get it. The more I think about it, the more it seems to me that it can't be anything other than pulling. I mean, even if OS set a callback function, still something should understand that new information has arrived to call that callback function. That **something** still should use pull to understand the arrival of the new data. How a port listens?


Why many programming languages have only 2 data-structures: arrays and hashes?

Many programming languages have only those 2 structures, and even some languages that have more structures still only provide special syntax for those 2; usually, `[]` and `{}`. Why is this? Is there anything special about those datatypes that is necessary for the completeness of the language?


Program Structure for Table Cells Representing Objects

So I have a program with "cue" objects and each have their own table cell. The thing is that the table cells have loading bars on them that represent the progress of the cues. This presents the following question: How should I structure the program? Should the objects representing the Cues store pointers to the table cells, allowing them to update the table cells themselves, or would some other program structure work better. Sorry if this question is too general, but I couldn't really find anything at all about this when I searched around on google and the website. I fairly new to iOS development and my programs structure is already getting chaotic. The suggestion I gave was just my initial instinct, but it's probable wrong...


Warning-free Objective C code

I am currently creating my first iPhone app in Objective C and getting a lot of warnings because I've in many places taken advantage of the fact that Objective C is a dynamically typed language. I get a lot of 'class' may not respond to '-message:' warnings. Should I strive to remove all these warnings? If yes, then what's the benefit of having a dynamic language at your disposal?


How can be get sure that we're not implementing micromanagement in the field of software development?

As I got the feedback of developers about scrum methodology in this question, on whether it turns active developers into passive developers or not, I encountered the word **micromanagement**. However, Wikipedia doesn't explain this term in the context of specific and tangible examples, and this, can result in different interpretations of micromanagement. Can anyone point to some well-known micromanagerial issues in the world of development (of course, with reference)? What practices could be regarded as micromanagerial? How can we get sure that we're not implementing micromanagement in our working environment?


Scrum taskboard with QA stage

I've been reading this article by Mike Cohn about Scrum task boards. One query I have is how this fits into a workflow where there is QA stage performed by testers who aren't developers. It seems that many tasks could not easily be QA'd in isolation. A practical alternative could be that the "To Verify" process should be carried out by another developer in the team, and then to have an additional stage after DONE to QA the whole story (probably after deployment to a stage/test environment). Does this seem right?


"A line comment acts like a newline"

I'm reading the Go language specification. The section on comments states: > Line comments start with the character sequence `//` and stop at the end of > the line. A line comment acts like a newline. What is the point of specifying that a line comment acts like a newline? Couldn't line comments simply act like empty strings? Lines (except the last) end in a newline anyway, so any line (except the last) will act like two consecutive newlines. If the last line has a line comment, then it can also safely act like an empty string.


Explain to a non-technical manager that the tool he chose isn't apt

My non-technical manager just paid for a license to use a tool which designed to pick mentions of your brand name at blogs, "social media", comments, etc. and gauge the sentiment (positive, neutral, negative) of the post. What he wants me to do is use it to do a task which can only be achieved with a certain level of natural language processing and hence shows up unrelated results for whatever query you can try. I want to be able to explain to him that this tool is designed for task X and what we are trying to do is task Y. Y cannot be modelled as X. And all the success of the tool he cites as proof is proof of X which is not Y.


In some articles and books that I read, I some time see the term 'Bootstrapping'. For example I see this sentence "Bootstrapping X.JS" in angular js document: http://docs.angularjs.org/tutorial/step_00 > Bootstrapping AngularJS apps automatically using the `ngApp` directive is > very easy and suitable for most cases. In advanced cases, such as when using > script loaders, you can use imperative / manual way to bootstrap the app... What is the meaning of bootstrapping in software development?


Server and MySQL safety for Java / JDBC applications?

I have an external java application which use JDBC as to reach an MySQL database. This will be used by many people and is going to store all the people's data on the same server / MySQL. As I bet people will be able to crack the .jar and see the source, I expect them to be able to cheat the program by editing it and making it get information from other users even when they are not allowed to reach said information. Is there any standard way to protect a server so people should only be able to reach the information their account is connected to even if said people are able to change the source? Cheers, Skarion


Should I use native android junit framework?

Can anybody share a reason (or list of reasons) of not using the native android junit framework but a standalone one like robolectric or something like that? I'm just trying to understand what framework to learn.


Address validation service for a public website

Given the following scenario:   * There is a public website (with about 50-100 visitors a day)   * Visitors register for the services offered by the company who owns the website   * Visitors tend to give wrong information regarding address and phone number that slows down the process of their registration, therefore their transactions and general happiness about the services of the company   * Generaly the address validation adds value to the website I am looking for a service for a reasonable price, that has:   * Up to date postcode and address database    * Easy to integrate API   * Address validation check    * All this with a reasonable price I am looking specifically looking in the UK. What I have found so far are companies having these services for on ridiculously high price. We are also considering buying the PAF database from RoyalMail and implement such a service for ourselves. Any help, suggestion is very much appreciated and thanks very much in advance!


What are the common mistakes when you are a good coder in C and PHP and you start coding in Java ? What are good tips when switching?

What apsects of Java are the most diificult to learn when coming from such a background? What common mistakes do people make ? What are the top timesaving and produtivtity increasing tricks ? If you had a room of C/PHP coders who were about to start development using Java what advise would you give ? This is my list of topics so far (in no particular order):   * Use jodatime instead of the standard library , and also less importantly the guava library.   * Arrays are zero indexed   * I'd also highlight the pass-by-value/reference aspects of Java, and the fact that > >     String s1 = new String("test"); >     String s2 = new String("test"); >     if(s1 == s2) // will be false >     if(s1.equals(s2)) // will be true >     * Introduce the concept of design patterns and give a quick overview.   * Introduce Spring (it will be used) and the concept of dependency injection Is there anything obvious I am missing.


What are the steps in beginning a large project, when all I have is a big idea?

I am computer engineering student. I've been thinking about how I can handle a big project. What should be my first step to reach my goal in a more efficient and effective way? When I come up with a project, I don't know how I should start working on it. Many times, I just ignore it. However, I don't want to ignore my project ideas anymore. Now, I am asking to all of you, can anyone share his/her experiences? How should I start a project when all I have is an idea?


Payment Gateways and RESTful API

I have a RESTful API that offers eCommerce functionality. One area I'm struggling to decide on the correct implementation is how to process payments. Lets say I have the following URI GET .../checkout/{id}/payment. This resource provides details to the client application of what details needs to be submitted to make a payment. The specifics of the information in the resource depends on the implementations below **Implementation 1** The resource contains basic payment fields to be filled in like card number, billing address etc. The data is sent to the API using POST .../checkout/{id}/payment. The API then submits a request to the payment gateway (e.g. paypal), waits for the response, and then sends an appropriate response back to the client application. **Implementation 2** The resource contains details of how to submit a request directly to the payment gateway (e.g. paypal). The client submits the payment to the gateway, waits for a response, and then sends the payment reference (normally always provided by a payment gateway) back to the API using POST .../checkout/{id}/payment. The problem I am having is that both have pros and cons. Implementation 1 I would say is the more fail safe method as everything is contained in one request to the API. The API can then update backend tables once the payment has been processed, and return success or failure status to the client. Since the API is sending a response to the gateway, it knows the response it receives is genuine. Implementation 2 frees the API from having to process the payment which is great, but requires the client to make two requests. One to the payment gateway and one to the API with the reference. Additionally, how can I validate the payment reference on the API without calling the gateway? A dishonest client could send any reference back to the API which then may be incorrectly marked as paid. Just wanted to throw my ideas out there, but if anyone has a really good solution for implementing Payment Gateways and RESTful API web services that would be great. **UPDATE** Just thought of an **Implementation 3**. I could actually create a separate smaller API to handle the payments. It would work in a similar way to implementation 1 except that the client application doesn't post to api.site.com/.... but posts to gateway.site.com/... This give me a degree of security as I control the code on gateway.site.com and ensures that api.site.com isn't being bogged down by waiting for the payment provider to respond. The gateway api then essentially becomes a client of the main API and posts the payment success details to it. Any thoughts on this?


What to watch out for when writing code at an Interview?

I have read that at a lot of companies you have to write code at an interview. On the one hand I see that it makes sense to ask for a work sample. On the other hand: What kind of code do you expect to be written in 5 minutes? And what if they tell me "Write an algorithm that does this and that" but I cannot think of a smart solution or even write code that doesn't semantically work? I am particularly interested in that question because I do not have that much commercial programming experience, 2 years part-time, one year full-time. (But I am interested in programming languages since nearly 15 years though usually I was more concentrated in playing with the language rather than writing large applications...) And actually I consider my debugging and problem solving skills much better than my coding skills. I sometimes see myself not writing the most beautiful code when looking back, but on the other hand I often come up with solutions for hard problems. And I think I am very good at optimizing, fixing, restructuring existing code, but I have problems with writing new applications from scratch. The software design sucks... ;-) Therefore I don't feel comfortable when thinking about this code writing situation at an interview... So what do the interviewers expect? What kind of information about my code writing are they interested in?


Are short identifiers bad?

Are short identifiers bad? How does identifier length correlate with code comprehension? What other factors (besides code comprehension) might be of consideration when it comes to naming identifiers? Just to try to keep the quality of the answers up, please note that there is some research on the subject already! **Edit** Curious that everyone either doesn't think length is relevant or tend to prefer larger identifiers, when both links I provided indicate large identifiers are harmful! **Broken Link** The link below pointed to a research on the subject, but it's now broken, I don't seem to have a copy of the paper with me, and I don't recall what it was. I'm leaving it here in case someone else figure it out.   * http://evergreen.loyola.edu/chm/www/Papers/SCP2009.pdf


Best practices: Ajax and server side scripting with stored procedures

I need to rebuild an old huge website and probably to port everyting to `ASP.NET` and `jQuery` and I would like to ask for some suggestion and tips. Actually the website uses:   * `Ajax (client site with prototype.js)`   * `ASP (vb script server side)`   * `SQL Server 2005`   * `IIS 7 as web server` This website uses hundred of stored procedures and the requests are made by an `ajax call` and **only 1 ASP page** that contain an huge `select case` Shortly an example: JAVASCRIPT + PROTOTYPE:               var data = {         action:     'NEWS',         callback:   'doNews',         param1:     $('text_example').value,         ......:     ..........};     AjaxGet(data); // perform a call using another function + prototype      SERVER SIDE ASP:               <% ......     select case request("Action")     case "NEWS"         With cmmDB             .ActiveConnection = Conn             .CommandText = "sp_NEWS_TO_CALL_for_example"             .CommandType = adCmdStoredProc                   Set par0DB = .CreateParameter("Param1", adVarchar, adParamInput,6)             Set par1DB = .CreateParameter(".....", adInteger, adParamInput)             ' ........ ' can be more parameters                  .Parameters.Append par0DB             .Parameters.Append par1DB                  par0DB.Value = request("Param1")             par1DB.Value = request(".....")                  set rs=cmmDB.execute                  RecodsetToJSON rs, jsa ' create JSON response using a sub         End With     .... %>      So as you can see I have an `ASP` page that has a **lot of CASE** and this page **answers to all the ajax request** in the site. My question are:   1. Instead of having many `CASES` is it possible to create dynamic `vb` code that parses the `ajax` request and creates dynamically the call to the desired SP (also implementing the parameters passed by JS)?   2. What is the best approach to handle situations like this, by using the advantages of `.Net + protoype or jQuery`?   3. How the big sites handle situation like this? Do they do it by creating 1 page for request? Thanks in advance for suggestion, direction and tips.


Alternatives to foreach iterators involving ref and out

I am trying to make a flexible particle system for my XNA game, and I've got these interfaces:               public interface IParticle : IUpdateable     {         bool Alive { get; }         float Percent { get; }     }          public interface IParticleEffect<T>         where T : IParticle     {         void Apply(GameTime time, ref T particle);     }          public interface IParticleEmitter<T> : IUpdateable         where T : IParticle     {     }          public interface IParticleRenderer<T> : IDrawable         where T : IParticle     {     }      The idea behind this system is that the client code only needs to derive from `IParticle`, then make a compatible subclass from `IParticleEmitter` and `IParticleRenderer`, and everything else just automagically works behind the scenes. (I'm actually in the middle of writing everything at the moment, but the latter two would have an abstract base class available.) Anyways, some particle systems like to use mutable structs for optimization purposes, and that's perfectly reasonable. My system only provides the skeleton, and if the client decides that "Hey, structs are the way to go!", then my system should support whatever the client code throws at it. This is why my `IParticleEffect.Apply()` method takes a particle by **ref** \-- it's cheaper to pass a struct by reference than it is to copy it. Unfortunately, it breaks when collections are involved, because the foreach iterator doesn't play nicely with objects passed by **ref** or **out**. Eric Lippert explains why here. So, now I have a design decision to make:   1. Completely disregard structs, and change my constraint to `where T: class, IParticle`. This potentially hurts future optimizations, but makes it much easier to work with collections.   2. Change anything that uses `ICollection<T>` or `IEnumerable<T>` to `IList<T>` so I can manually poll it via an indexer. This makes it potentially more powerful, but at the cost of using a deeper interface (list) to store my objects.   3. Something else I hope this question isn't too "it depends", but I am curious as to what strategies I can apply here to make it work the way I want. * * * **EDIT** : I realized that I could also include a local variable such as:               foreach (var particle in SomeParticleCollection)     {         var p = particle;         SomeEffect.Apply(ref p);     }      However, `p` would still have the net effect of copying it, which is also not ideal.


When is it appropriate to use a bitwise operator in a conditional expression?

First, some background: I am an IT teacher-in-training and I'm trying to introduce the boolean operators of java to my 10th grade class. My teacher- mentor looked over a worksheet I prepared and commented that I could let them use just a single & or | to denote the operators, because they "do the same thing". I am aware of the difference between & and &&.   & is a bitwise operator intended for use between integers, to perform "bit- twiddling".   && is a conditional operator intended for use between boolean values. To prove the point that these operators do not always "do the same thing" I set out to find an example where using the bitwise between boolean values would lead to an error. I found this example               boolean bitwise;     boolean conditional;     int i=10, j=12;     bitwise = (i<j) | ((i=3) > 5); // value of i after oper: 3     System.out.println(bitwise+ " "+ i);     i=10;      conditional = (i<j) || (i=3) > 5 ;  // value of i after oper: 10     System.out.println(conditional+ " "+ i);     i=10;      bitwise = (i>j) & (i=3) > 5;   // value of i after oper: 3     System.out.println(bitwise+ " "+ i);     i=10;      conditional = (i>j) && (i=3) > 5;  // value of i after oper: 10     System.out.println(conditional+ " "+ i);      This example shows that if a value has to be changed by the second half of the expression, this would lead to a difference between the results, since bitwise is an eager operator, while the conditional behaves as a short circuit (does not evaluate the second half, if the first half is false in the case of && and true in the case of ||). I have an issue with this example. Why would you want to change a value at the same time as you do a comparision on it? It doesn't seem like a robust way to code. I've always been averse to doing multiple operations in a single line in my production code. It seems like something a "coding cowboy" with no conscience as to the maintainability of his code would do. I know that in some domains code needs to be as compact as possible, but surely this is a poor practice in general? I can explain my choice of encouraging the use of && and || over & and | because this is an accepted coding convention in software engineering. But could someone please give me a better, even real-world, example of using a bitwise operator in a conditional expression?


Apps being portable

I haven't found much on this, but what I did find doesn't explain it well enough (at least for me). What makes the application I make portable?   Or what defines a portable application?   Is there a specific difference that makes an app portable or not? I always thought if I just made an executable file and some images I could just copy that folder and take it to another computer on a flash drive. But, if you could what is the purpose of having "portable" apps? I know I have asked a range of questions, but I suspect an answer that addresses one of the questions will cover them all.


Random forest ML algorithm suitable for use on cluster based HPC?

I need help in identifying a better algorithm. I have developed a script using pythons scipy package to analyse a rather large model that I wish to solve. The model contains over 12GB of data including over 500 parameters. The problem is that when I run small simulations of about 0.5GB of data with 20 parameters it can take my computer a decent amount of time if I allow a reasonable number of iterations through the random forest classifier. Currently my script is only using one core, so I guess that making the script multi-threaded would be the first step. But I do not believe this will be enough given how complex the model is. I am willing to explore the use of a cluster based HPC solution but I am not sure how to go about this. Are there better algorithms I can use, or is there a cluster based algorithm that would be more appropriate?


How to solve "train wreck" properties problem that violates Law Of Demeter?

I've been reading about law of Demeter and I would like to know how to solve this traversing model properties problem that I see a lot on Objective-C. I know that there is a similar question but in this case I'm not calling a method from the last property that do some calculations, instead, I'm just setting values (Ok, I know that getter are methods but my intention here is just to get the value, not to change the state of some object). For example:               self.priceLabel.text = self.media.ad.price.value;      Should I change that for something like:               self.priceLabel.text = [self.media adPriceValue];      and inside the Media.m               - (NSString *)adPriceValue {         return [self.ad priceValue];     }      and inside the Ad.m               - (NSString *)priceValue {         return [self.price value];     }      Is that a good solution? Or Am I creating unnecessary methods?


Dealing with bad job description and interviewing applicants

My employer has been looking for a new web developer as well as a DBA for a while now with little success. I just saw the job description, and now I can understand why we are getting no interest - they have lumped together three jobs into 1 position: web developer, DBA, and marketing SEO/Analytics expert all under the title of "Webmaster". It's hard enough to find someone who can do any of those individual things well, let alone somebody who can do it all (or wants to be called "Webmaster" these days). Part of their motivation is, no doubt, saving money by hiring 1 person to do three jobs and underpaying that person. But now I have to deal with interviewing people for this position (that is, if we ever get an applicant), and trying to figure out what this person is _really_ going to be doing once hired. Have you had experience with this sort of thing? Either as an applicant or as an interviewer. And how did you deal with it? Assuming that rewriting the job description to something more realistic isn't an option, what would be the best way of handling this (finding the right person, interviewing them effectively, etc.)?


How to better performance

In one of my interviews I was asked a vague question, I'm still not sure of the answer. We have a client and a server they are placed apart. The network that connects them has high latency, which is dominating the performance. How can we improve the performance. Note that we can't change the network's topology. I was thinking of caching, breaking the request to multiple smaller requests and opening multiple connections with the server. Any ideas? Please note that the question description is vague and I wasn't supplied with more information about the situation. **Clarified question:** How should the client-server communication be designed in order to get the best performance on a network that has big latency?


Any Course/Lecture videos on Design Patterns

I am planning to read some design patterns and I took the book on "design patterns in C++' by gang of four. However, I am not really some one who reads book and prefers reading slides/watching course lectures and then apply and read the book. I cannot find any course lecture videos on net(yeah, its not that important a course as algo/OS). Any one know any course website, preferably on C++


Add a unit test for each new bug

In my job all developers that resolve a bug have to add a new unit test that warns about this type of bugs (in the case it occours again). If a unit test is not possible (for example, a webpage design issue), then QA department has to create a test case to manually check it. The idea behind this is that if a defect has not been detected before the product release is because there isn't an appropriate unit test to detect it. So the developer has to add it. The question is: is this common in any software development methodology? This technique has a name? I would like to learn more about it, but I need some information to start with it.


Developing Android apps for someone else

We have developed several apps and published them on Android Market. We are now writing an app that another company will brand and sell through their own publisher account. The other company has no experience with Android Market or with Android development. I'd appreciate any insights from others who have faced similar situations. I'm specifically concerned about the following areas:   1. **Signing the app**   The alternatives we see are: sign with our usual key; create a signing key pair specific to the other company and sign with that; or help the other company install a development system, generate a key pair, and do the signing themselves. The latter would require us sending them the project sources, which presents its own problems. Other than our concern about sending the source, does the choice matter in any way?   2. **Licensing**   Since the license check will be done against their account, the code will need to embed their public key for decrypting the license response. Is there any reason they should be concerned about sharing that key with us? Are there any alternatives to them sharing the key with us?   3. **Publishing**   The other company is responsible for all marketing and sales; we are responsible for the app development. From what we can tell, Android Market is not set up to allow a clean separation of these roles. (It assumes that the developer will also be the publisher.) This makes it difficult to work out a division of responsibilities for the publication process. Our initial thought was to deliver the .apk file to them and let them handle it from there. The licensing issue was the first indication that we were being naive about this. The publishing process itself is rather technical, and we see two alternatives: walk them through all the steps or ask them to give us access to their publisher account and do it ourselves. What do others do?


Source code and project documentation requirements for legal agreement

# Question What kind of documentation and other artifacts would you expect to get in case of taking over existing Java webapp (probably it uses JBoss Seam framework) made _in-house_? I would expect to get:   * Source code in form ready to open in specified IDE.   * All external elements (i.e. DB schema as SQL scripts, installation scripts).   * Configuration files (both for devel, testing and production environments).   * All external libraries needed by project.   * All external tools used in project or at least their description (i.e. make program, version control software).   * Detailed info about:     * How to compile project (IDE, libraries, their versions, compilers, OS),     * How to setup development environment (database version, OS, DB schema),     * How to install and run application -- server specification (OS, database, versions, minimal hardware, configuration both app and DB),  Probably it would be also nice to have:   * Archive of the whole version control system (to make possible checking changes from the past).   * UML diagrams or other form of _big picture_ of application design.   * DB schema. What I miss? # Some background details Friend works as a lawyer for a company which needs legal agreements with people who develop applications for them. Just in case something goes wrong. In general -- the company wants to have source code deposited somewhere. But source code is not enough to maintain or even compile and run webapp, so they also needsome documentation which helps maintain the app. I've never taken someone else's project in a similar case (no access to previous developers), and I am not Java developer, so I expect there are a lot of things to miss. ## More details added after a few answers The bosses of company (named it **A** , small corporation), which ordered and uses the app and company (named it **B** , a few people) which writes the app, are friends. Development is _in-house_. No formal spec, no written specification. All features are discussed over mail or on meetings. Everything, including hosting the app, is managed by **B**. Friend (who is also one of heavy users of the app -- let's say she is _product owner_ ) doesn't trust developers from **B** at all. Friend also doesn't believe in **B** competencies (believe me -- she should not). So to protect **A** business friend wants written legal agreement with **B** in case **B** would go away with **A** data and app... As MSalters wrote -- don't laugh -- it happens :(. **A** already made **B** to make and provides backups.


Resolving merge conflicts due to refactoring

I got involved in a discussion recently on how to handle refactoring in general (which is an interesting topic in itself). Eventually the following question was brought up: **How does one handle merge conflicts that occured due to that someone did a refactoring of a part of the code, while someone else was working on a feature for the same piece of code?** Basically, I have no idea how to deal with this in an efficient manner. Are there any best practices that one should follow regarding this? Is there any difference on how one should handle this for a system with tons of legacy code?


Can we replace XML with JSON entirely?

I'm sure lots of developers are familiar with XML and JSON, and they've used both of them. Thus no point in explaining what they are, and what is their purpose, even in brief. If we try to map their concepts, we can say (correct me if I'm wrong):   1. XML tags are equivalent to JSON `{}`   2. XML attributes are equivalent to JSON properties   3. XML tag collection is equivalent to JSON `[]` The only thing I can think of, which doesn't exist in JSON, is XML Namespaces. The question is, considering this mapping, and considering that JSON is highly lighter in this mapping, can we see a world in future (or at least theoretically think of a world) without XML, but with JSON doing everything XML does? Can we use JSON everywhere XML is used? PS: Please note that I've seen this question. It's something entirely different from what I'm asking here. Thus please don't mention **duplicate**.


Dependency Injection and method signatures

I've been using YADIF (yet another dependency injection framework) in a PHP/Zend app I'm working on to handle dependencies. This has achieved some notable benefits in terms of testing and decoupling classes. However,one thing that strikes me is that despite the sleight of hand performed when using this technique, the method names impart a degree of coupling. Probably not the best example -but these methods are distinct from ... say the PEAR Mailer. The method names themselves are a (subtle) form of coupling               //example     public function __construct($dic){         $this->dic = $dic;     }          public function example(){         //this line in itself indicates the YADIF origin of the DIC         $Mail= $dic->getComponent('mail');                 $Mail->setBodyText($body);         $Mail->setFrom($from);                 $Mail->setSubject($subject);     }      I could write a series of proxies/wrappers to hide these methods and thus promote decoupling from , but this seems a bit excessive. You have to balance purity with pragmatism... How far would you go to hide the dependencies in your classes?


What "jobs" benefit by having someone with a programming background perform them?

What non-programming jobs should someone look for who doesn't have the passion for programming? There are a percentage of people who make it through a computer science type of degree but do not have the passion for programming. I have worked with many people who have a programming background but became a project manager or tester and it has made my job as a programmer easier... and our products better. This is not a failure of the system or person... they are just finding where they fit. So, I wonder what non-programming jobs benefit from having someone in them that is a programmer and why does it make that person a stronger or weaker candidate for that job? For instance: Programmers make good project managers because they may be able to express requirements in a detailed fashion that makes sense to the programmers that will work on those requirements. But they may be to accustom to talking about things in a technical way that the customers may not understand and they may have a tendency to try to communicate a design for a solution instead of presenting the problem in a raw fashion.


Namespaces just seem to be making things more complicated. Am I missing something?

Now that I am using namespaces in my php files which match the file's path, I have to append a namespace to pretty much every class instantiation. The namespaces definitely help my autoloader find files, but the code is becomming harder to read/write. aren't namespaces supposed to simplify my code? why is it making things more complicated? Am I using it wrong? Not sure I see how using a namespace is much better than having super long class names... example: file: /root_path/init.php               <?php         namespace root_path;         $foo = new \sub_path\bar();     ?>      file: /root_path/sub_path/bar.php               <?php         namespace root_path\sub_path;         class bar {              }     ?>


Are Design Patterns SuperSet of OOP or SubSet?

Initially I started learning OOP and later started grasping concepts of Design Patterns. I wonder whether it is the Design Pattern which is the SuperSet of OOP or it is the OOP itself.


Which language and GUI toolkit would you use for a prototype program?

Suppose, I have an idea and I have to put it into code quickly. And then I am presenting it to someone who is not so computer savvy. Which language should I use for quick and dirty coding? And which GUI toolkit should I use so that the the computer semi-literate find it easy to use (read shiny-eye-candy). It is a desktop application.


How to use GPL v3 with Apache License 2.0?

Based on this page, I can see that only Apache License 2.0 is compatible with GPL v3. Now my question is, in layman's term, how do I make those two work together? My current situation is that I am developing an application that is made from a GPL v3 licensed programming language. I want to put some form of security on the application and figured I can achieve that via a web service. However, I don't want to expose my web service's code as GPL v3 since it is part of a larger system that I am working on which will be closed source. Is there any way to use the Apache License 2.0 in this scenario? EDIT: For clarity's sake, the programming language I am going to use is LiveCode.


Unit testing C++: What to test?

**TL;DR** Writing good, useful tests is hard, and has a high cost in C++. Can you experienced developers share your rationale on what and when to test? **Long story** I used to do test-driven development, my whole team in fact, but it didn't work well for us. We have many tests, but they never seem to cover the cases where we have actual bugs and regressions - which usually occur when units are interacting, not from their isolated behaviour. This is often so hard to test on the unit level that we stopped doing TDD (except for components where it really speeds up development), and instead invested more time increasing the integration test coverage. While the small unit tests never caught any real bugs and were basically just maintenance overhead, the integration tests have really been worth the effort. Now I've inherited a new project, and am wondering how to go about testing it. It's a native C++/OpenGL application, so integration tests are not really an option. But unit testing in C++ is a bit harder than in Java (you have to explicitely make stuff `virtual`), and the program isn't heavily object oriented, so I can't mock/stub some stuff away. I don't want to rip apart and OO-ize the whole thing just to write some tests for the sake of writing tests. So I'm asking you: What is it I should write tests for? e.g.:   * Functions/Classes that I expect to change frequently?   * Functions/Classes that are more difficult to test manually?   * Functions/Classes that are easy to test already? I began to investigate some respectful C++ code bases to see how they go about testing. Right now I'm looking into the Chromium source code, but I'm finding it hard to extract their testing rationale from the code. If anyone has a good example or post on how popular C++ users (guys from the committee, book authors, Google, Facebook, Microsoft, ...) approach this, that'd be extra helpful. **Update** I have searched my way around this site and the web since writing this. Found some good stuff:   * When is it appropriate to not unit test?   * http://stackoverflow.com/questions/109432/what-not-to-test-when-it-comes-to-unit-testing   * http://junit.sourceforge.net/doc/faq/faq.htm#best Sadly, all of these are rather Java/C# centric. Writing lots of tests in Java/C# is not a big problem, so the benefit usually outweights the costs. But as I wrote above, it's more difficult in C++. Especially if your code base is not-so-OO, you have to severely mess things up to get a good unit test coverage. For instance: The application I inherited has a `Graphics` name space that is a thin layer above OpenGL. In order to test any of the entities - which all use its functions directly - I'd have to turn this into an interface and a class and inject it in all the entities. That's just one example. So when answering this question, please keep in mind that I have to make a rather big investment for writing tests.


Does syntax really matter in a programming language?

One of my professors says "the syntax is the UI of a programming language", languages like Ruby have great readability and it's growing, but we see a lot of programmers productive with C\C++, so as programmers does it really matter that the syntax should be acceptable? I would love to know your opinion on that. Disclaimer: I'm not trying to start an argument. I thought this is a good topic of discussion. Update: This turns out to be a good topic. I'm glad you are all participating in it.


What is the exact semantic of reduce in clojure?

The Clojure docs regarding `(reduce f val coll)` state: > If val is supplied, returns the result of applying f to val and the first > item in coll, then applying f to that result and the 2nd item, etc. So I tried:               (reduce str ["s1" "s2"] "s3")      Which leads to:               "[\"s1\" \"s2\"]s3"      However, when I try               (apply str ["s1" "s2"])      I get:               "s1s2"      So why does the vector get converted into its string representation?


Why do some websites showing 0 bytes in Chrome's developer tools

I am doing a page speed optimization for my website and studying how other websites do it. I noticed that some websites such as as Facebook or Ringgitplus show 0 bytes for some of their resources in Chrome's developer tools, Network tab, while the real content size is several kilobytes. ![The screenshot of Network tab showing 0 bytes for some resources](http://i.stack.imgur.com/asvBh.png) I read some articles that says that _size_ is the amount being fetched and _content_ is the actual size of the response. So when size is 0 bytes, it means it served from cache. But the same thing happened when I open the page using Incognito or clearing all my cache. How is this possible and how can I achieve the same thing for my websites?


Need help with deciding elements for icon creating application

I'm trying to practice programing by creating a simple application which, I think, I can manage to do in .Net C# in VisualStudio 2010. I'm working on simple application which will let me to create small pictures (icons) in sizes such as 8x8, 16x16, 32x32 (ect) pixels. I will be creating a grid representing each size by scaling to amount of pixels. Each pixel will be represented in a small square which will be able to click to change color ect. So here's my question regarding what elements such app should have:   * What VS tool would let me to create a grid for my project? Keeping in mind that each small square should be generated automatically by using X/Y size provided by user and boxes should be clickable. Also, I probably should be able to be able to click one pixel and drag mouse to select other pixels.   * What simple functions should such small app have? Ex. choosing colors.   * What minimal functions should I have? I hope this is place for such question. I'm trying to get the general idea of how to make such small app work and what user might expect when opening small, icon creating, application.


What's the best way to cache a growing database table for html generation?

I've got a database table which will grow in size by about 5000 rows a hour. For a key that I would be querying by, the query will grow in size by about 1 row every hour. I would like a web page to show the latest rows for a key, 50 at a time (this is configurable). I would like to try and implement memcache to keep database activity low for reads. If I run a query and create a cache result for each page of 50 results, that would work until a new entry is added. At that time, the page of latest results gets new result and the oldest results drops off. This cascades down the list of cached pages causing me to update every cache result. It seems like a poor design. I could build the cache pages backwards, then for each page requested I should get the latest 2 pages and truncate to the proper length of 50. I'm not sure if this is good or bad? Ideally, the mechanism I use to insert a new row would also know how to invalidate the proper cache results. Has someone already solved this problem in a widely acceptable way? What's the best method of doing this? EDIT: If my understanding of the MYSQL query cache is correct, it has table level granularity in invalidation. Given the fact that I have about 5000 updates before a query on a key should need to be invalidated, it seems that the database query cache would not be used. MS SQL caches execution plans and frequently accessed data pages, so it may do better in this scenario. My query is not against a single table with TOP N. One version has joins to several tables and another has sub-selects. Also, since I want to cache the html generated table, I'm wondering if a cache at the web server level would be appropriate? Is there really no benefit to any type of caching? Is the best advice really to just allow a website site query to go through all the layers and hit the database every request?


What steps should be taken to ensure that an open source database gets ready for production?

I am considering using GridSQL in a production environment. However, I do have some indications that it is not ready. One is that it got excluded by the offering of EnterpriseDB a while ago, and the forums seem to report a few wrong results and relatively severe bugs. The alternatives to GridSQL, however cost around 100.000$ to buy, so I was thinking to utilize some of this money to ensure that GridSQL gets ready for production. At the same time, I could risk spending 50.000$ and months of work on the development of GridSQL, just to discover that the design was flawed and that a complete rewrite is needed. Then I would have to buy the commercial alternatives to GridSQL and the existence of my startup would be at risk. **Question** What steps would you take to ensure that there is as little risk as possible that the worst case scenario described above would happen? It is unrealistic that I could do much testing nor code review/coding myself (I am also not the best developer), so please describe where to find the guys that would need to do the work.


Hiring "off-platform" - what are the indicators for successful candidates?

When looking for candidates you often want to have people with direct experience with the technologies and platforms you are using today. However, that may not always be a possibility. The particular requirements may involve niche tech, outdated tech, or your team has already drained the local area of everyone with that particular tech (not everyone works in Silicon Valley, some of us work and live in some smaller metro area for reasons unrelated to the profession). So often that can leave you with hiring people who are "off-platform" like Dot-Net people for a Java project, or Cobol programmers for an iPhone app (or vice versa). Or even just a language switch, from Visual Basic to Scala or JavaScript to C. My question is what qualities, attributes, and experience would you look for as in interviewer to indicate that the candidate can successfully switch platforms or languages, and what are the indicators as to the level of success and timeframe. Also, decent "war stories" related to this would get a solid upvote from me.


How should I approach developing a Java based client-server application?

I have been asked to develop a client-server application (requires database) for a company. I am very handy with java so would like to go with it. Its up to me how I develop the application. It may be an JSP web application or Java Swing GUI based application. I have following queries/doubts. So if I go on to develop a web application, I have to teach the company personnel     1. How to install Tomcat   2. How to load the web application Tomcat   3. How to start the server to start the application. If I go on to develop a Java Swing GUI based application,   1. It should start when the computer starts up. i.e it should be auto added into the service start-up of the OS on installation   2. Have application shortcut in quick launch, tray bar on installation. On Database Part: I would like to have MS-access like DB but free one. This is because,   1. No need to worry about installation of DB engine (like we have to take care in-case of MySQL).   2. DB would maintained in some Drive (like .mdb file in case of MS-Acess) unharmed even if their OS crashes. Please guide me how should I approach in developing the software.


What are the (or some) tenets of software security?

When developing security, what tenets should you keep in mind and follow in order to practice due diligence?


Writing a game engine using javascript

..by this I mean a logic handler for a chess game. Basically validating a move and checking if somebody has won. Now ignore the complexity of the game(if you can..) I'd like some sort of psuedo code on how it would look using callbacks in javascript. For arguments sake imagine once a move is completed in the browser it sends a JSON object of the piece that has been moved and to which space it has been moved to. On the server we have access to a JSON object which contains data for the complete board. With this information I expect to pass it in to my engine and determine from the output if the move is valid..and if so is it a winning move? I'm not looking for any specific logic on how to determine a move in chess -> just a kind of psuedo example/template of the flow of the game using the above paragraph as a guide to what must be done. The reason for this is I would like to understand how callbacks can be used to produce something of this nature as opposed to synchronous code.


Best practice or design patterns for retrieval of data for reporting and dashboards in a domain-rich application

First, I want to say this seems to be a neglected question/area, so if this question needs improvement, help me make this a great question that can benefit others! In my experience, there are two sides of an application - the "task" side (where the users interact with the application and it's objects where the domain model lives) and the reporting side, where users get data based on what happens on the task side. On the task side, it's clear that an application with a rich domain model should have business logic in the domain model and the database should be used mostly for persistence. Separation of concerns, every book is written about it, we know what to do, awesome. What about the reporting side? Are data warehouses acceptable, or are they bad design because they incorporate business logic in the database and the very data itself? In order to aggregate the data from the database into data warehouse data, you must have applied business logic and rules to the data, and that logic and rules didn't come from your domain model, it came from your data aggregating processes. Is that wrong? I work on large financial and project management applications where the business logic is extensive. When reporting on this data, I will often have a LOT of aggregations to do to pull the information required for the report/dashboard, and the aggregations have a lot of business logic in them. For performance sake, I have been doing it with highly aggregated tables and stored procedures. As an example, let's say a report/dashboard is needed to show a list of active projects (imagine 10,000 projects). Each project will need a set of metrics shown with it, for example:   1. total budget   2. effort to date   3. burn rate   4. budget exhaustion date at current burn rate   5. etc. Each of these involves a lot of business logic. And I'm not just talking about multiplying numbers or some simple logic. I'm talking about in order to get the budget, you have to apply a rate sheet with 500 different rates, one for each employee's time (on some projects, other's have a multiplier), applying expenses and any appropriate markup, etc. The logic is extensive. It took a lot of aggregating and query tuning to get this data in a reasonable amount of time for the client. Should this be run through the domain first? What about performance? Even with straight SQL queries, I'm barely getting this data fast enough for the client to display in a reasonable amount of time. I can't imagine trying to get this data to the client fast enough if I am rehydrating all these domain objects, and mixing and matching and aggregating their data in the application layer, or trying to aggregate the data in the application. It seems in these cases that SQL is good at crunching data, and why not use it? But then you have business logic outside your domain model. Any change to the business logic will have to be changed in your domain model and your reporting aggregation schemes. I'm really at a loss for how to design the reporting/dashboard part of any application with respect to domain driven design and good practices. I added the MVC tag because MVC is the design flavor du jour and I am using it in my current design, but can't figure out how the reporting data fits into this type of application. I'm looking for any help in this area - books, design patterns, key words to google, articles, anything. I can't find any information on this topic.


How to tackle complex business rule and logic?

I have a domain expert to work with, but he would throws a lot of details to me verbally. The business logics are complex, business rules change often, the business process is long and multi-ending / intermediate wait-state. There are a lot of cases to deal with (because there are many states for the account, product and subscription). What's the best way to deal with it? BPMN diagram isn't even low level enough to explain. Written documentations are time consuming to write and read. UML state diagram can become crazily complex very soon. Any advice would be appreciated.


Using a progress dialog and multi threading

My .NET Windows desktop application creates an HTML report, and has 3 main phases. It may create multiple reports. I show a progress bar so the user knows (estimates) how long it will take (as well as reassure the system didn't crash by an updating GUI). So, if I needed to generate 3 reports, there would be a total of 9 phases (3 phases * 3 reports). The issue I now have, is the process is taking too long. As such, I need to use threads so I can start on phase 1, then open a new thread which completes phase 2 and 3. Whilst phase 2 and 3 are in progress, the next item on the list begins with phase 1 and the process continues. I'm hoping this makes sense. So I'm now thinking what to do with the progress bar since multiple phases will be being run at once. At the moment, the only logical thing I can think of is               Report 1. Start phase 1. New thread -> Phase 2 and 3          Check to see if Report 2 is last report. It isn't, so, during Report 2 phase 2, start Report 2 phase 1. New thread -> Phase 2 and 3          Check to see if Report 3 is last report. It is. So, during report 2 phase 2, start Report 3 phase 1, then continue on the same thread with phase 2 and 3      The above will mean I update the Progress Dialog during phase 2 and 3 of the last Report (and I guess I need to add some checks to ensure the other phases are actually finished). I can't imagine I'm doing any thing new or different to what has been before and as such, I was wondering if there is already a pattern for dealing with type of situation?


Am I bound by the license of a library that is used in my project but is not distributed with it?

I want to publish a small open source project on GitHub. I'd like to release it with either MIT or Apache license. The project has unit tests that use JUnit library. JUnit is released with the Eclipse Public License v1.0. JUnit is not distributed in the project - it is downloaded and used at build time by Maven, the build tool. Am I bound by the license of a library that is used in the project but is not distributed with it? If I am, can I use a library released with the Eclipse Public License in MIT or Apache licensed projects? **My own thoughts (the most pessimistic scenario)** As the unit tests use JUnit, the project is a derivative work of JUnit, even though JUnit is not distributed with it. Distributing the project automatically means distributing JUnit. The Eclipse Public License (the JUnit's license) says: > A Contributor may choose to distribute the Program in object code form under > its own license agreement, provided that … its license agreement: There is a list of four requirements here that sound trivial but which, perhaps, are not fully addressed in the MIT and Apache licenses (disclaiming all warranties, excluding any liability, a statement about additional provisions, a statement about availability of the source code). So, the Eclipse Public License may not be compatible with the MIT and Apache licenses, and I may not be able to use JUnit.


Checked vs Unchecked vs No Exception... A best practice of contrary beliefs

There are many requirements needed for a system to properly convey and handle exceptions. There are also many options for a language to choose from to implement the concept. Requirements for exceptions (in no particular order):   1. **Documentation** : A language should have a mean to document exceptions an API can throw. Ideally this documentation medium should be machine usable to allow compilers and IDEs to provide support to the programmer.   2. **Transmit Exceptional Situations** : This one is obvious, to allow a function to convey situations that prevent the called functionality from performing the expected action. In my opinion there are three big categories of such situations : 2.1 Bugs in the code that cause some data to be invalid. 2.2 Problems in configuration or other external resources. 2.3 Resources that are inherently unreliable (network, file systems, databases, end-users etc). These are a bit of a corner case since their unreliable nature should have us expect their sporadic failures. In this case are these situations to be considered exceptional ?   3. **Provide enough information for code to handle it** : The exceptions should provide sufficient information to the callee so that it can react and possibly handle the situation. the information should also be sufficient so that when logged this exceptions would provide enough context to a programmer to identify and isolate the offending statements and provide a solution.   4. **Provide confidence to the programmer about the current status of his code's execution state** : The exception handling capabilities of a software system should be present enough to provide the needed safeguards while staying out of the way of the programmer so he can stay focused on the task at hand. To cover these the following methods were implemented in various languages:   1. **Checked Exceptions** Provide a great way to document exceptions, and theoretically when implemented correctly should provide ample reassurance that all is good. However the cost is such that many feel it more productive to simply bypass either by swallowing exceptions or re-throw them as unchecked exceptions. When used inappropriately checked exceptions pretty much looses all it's usefulness. Also, checked exceptions make it difficult to create a API that is stable in time. Implementations of a generic system within a specific domain will bring it's load of exceptional situation that would become hard to maintain using solely checked exceptions.   2. **Unchecked Exceptions** \- much more versatile than checked exception they fail to properly document the possible exceptional situations of a given implementation. They rely on ad-hoc documentation if at all. This creates situations where the unreliable nature of a medium is masked by an API that gives the appearance of reliability. Also when thrown these exceptions loose their meaning as they move back up through the abstraction layers. Since they are poorly documented a programmer cannot target them specifically and often needs to cast a much wider net than necessary to ensure that secondary systems, should they fail, do not bring down the whole system. Which brings us right back to the swallowing problem checked exceptions provided.   3. **Multistate return types** Here it is to rely on a disjoint set, tupple, or other similar concept to return either the expected result or an object representing the exception. Here no stack unwinding, no cutting through code, everything executes normally but the return value must be validated for error prior to continuing. I have not really worked with this yet so cannot comment from experience I acknowledge it resolves some problems exceptions bypassing the normal flow but still it will suffer from much the same problems as the checked exceptions as being tiresome and constantly "in your face". So the question is : What is your experience in this matter and what, according to you is the best candidate to make a good exception handling system for a language to have ? * * * EDIT: Few minutes after writing this question I came across this post, spooky !


redimension multidimensional arrays in Excel VBA

Take a look at the following code. What my problem is is that I can't figure out how to redimension the n integer and the b integer. What I'm doing is the array sent1 is already working and it is populated with about 4 sentences. I need to go through each sentence and work on it but I'm having trouble. ` dim sent1() dim sent2() dim n as integer, b as integer, x as integer dim temp_sent as string b = 0 For n = 1 to ubound(sent1) temp_sent = sent1(n) for x = 1 to len(temp_sent1)               code               if a then     b = b + 1      **THIS IS THE PART OF THE CODE THAT IS NOT WORKING**               redim preserve sent2(1 to ubound(sent1), b)     sent2(n,b) = [code]          next      next `


Service Registry - is it needed?

Suppose you develop a system that has multiple services (implemented by different teams, in different countries, using different technologies including java, php, c#, c++ and more). Let's assume that despite using different technologies, somehow you have agreed to integrate using RESTful APIs. Does such a system need a Service Registry? I understand that basically it's not mandatory, since each service may have its own configuration where the service it uses are located. However, creating a central location makes the life of operations easier: they don't need to configure the same service multiple times. But creating a Service Registry may be complex. It's another system in the solution and it requires resources and even more important ownership. Who will owner it? I can think about more pros and cons of a Service Registry. So what do you think?


POST/Redirect/GET with invalid form submission?

In the field of web development, is it good practice to do a POST/Redirect/GET when fields in a form submission are invalid, as well? Typically, no sensitive transaction would have taken place, in this event. However, can an argument be made that, nonetheless, it is still good practice to utilize the POST/Redirect/GET pattern?


Copying (forking) an open source project to your own repository

I'm currently using an open source project called CodeFirstMembership for one of my projects. There's a critical issue that I need to get past, and the more I use it, the more I find things I need to modify. It's extremely useful, except it doesn't look like the developer has much time to update it (totally cool, we've all been there). I'm wondering about the etiquette and legality and general "hey, you stole my code you jerk" responses I'd get if I copied the source, moved it to github and made my own fork. On Github, we do this all the time, forking projects, but it FEELs less jerk- ish because there's a connection to the original. Is there anything wrong with me doing this, whether legal or otherwise since there's no copyright notice or license associated with this library?


is it okay to remove copyright info from a free, open source API even if you are explicitly told not to do so?

Just wondering if text such as the following, which appears inside the source files of a free, open source API, means anything in a court of law                   // Permission is hereby granted, free of charge, to any person obtaining a copy         // of this software and associated documentation files (the "Software"), to deal         // in the Software without restriction, including without limitation the rights         // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell         // copies of the Software, and to permit persons to whom the Software is         // furnished to do so, subject to the following conditions:         //         // The above copyright notice and this permission notice shall be included in         // all copies or substantial portions of the Software.         //         // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR         // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,         // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE         // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER         // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,         // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN         // THE SOFTWARE.


Splitting an image into many pieces to improve perceived performance? Good or Bad?

Time to time, I have to work on a website that involves a huge background in size and resolution (1920 x 1080 in resolution, over 2mb in size). I've been using preloaders and it worked very well, except that users have to wait a little bit. I noticed that google map splits a big image into many pieces. I researched about it and found out that it actually increases perceived performance. Is this true?


What is the difference between an Array and a Stack?

According to Wikipedia, a stack: > is a last in, first out (LIFO) abstract data type and linear data structure. While an array: > is a data structure consisting of a collection of elements (values or > variables), each identified by at least one array index or key. As far as I understand, they are fairly similar. So, what are the main differences? If they are not the same, what can an array do that a stack can't and vice-versa?


Do I suffer from encapsulation overuse?

I have noticed something in my code in various projects that seems like code smell to me and something bad to do, but I can't deal with it. While trying to write "clean code" I tend to over-use private methods in order to make my code easier to read. The problem is that the code is indeed cleaner but it's also more difficult to test (yeah I know I can test private methods...) and in general it seems a bad habit to me. Here's an example of a class that reads some data from a .csv file and returns a group of customers (another object with various fields and attributes).               public class GroupOfCustomersImporter {     //... Call fields ....     public GroupOfCustomersImporter(String filePath) {              this.filePath = filePath;              customers = new HashSet<Customer>();              createCSVReader();              read();              constructTTRP_Instance();          }          private void createCSVReader() {         //....     }          private void read() {         //.... Reades the file and initializes the class attributes     }          private void readFirstLine(String[] inputLine) {         //.... Method used by the read() method     }          private void readSecondLine(String[] inputLine) {         //.... Method used by the read() method     }          private void readCustomerLine(String[] inputLine) {          //.... Method used by the read() method     }          private void constructGroupOfCustomers() {         //this.groupOfCustomers = new GroupOfCustomers(**attributes of the class**);     }          public GroupOfCustomers getConstructedGroupOfCustomers() {         return this.GroupOfCustomers;     }      } As you can see the class has only a constructor which calls some private methods to get the job done, I know that's not a good practice not a good practice in general but I prefer to encapsulate all the functionality in the class instead of making the methods public in which case a client should work this way:               GroupOfCustomersImporter importer = new GroupOfCustomersImporter(filepath)     importer.createCSVReader();     read();     GroupOfCustomer group = constructGoupOfCustomerInstance();      I prefer this because I don't want to put useless lines of code in the client's side code bothering the client class with implementation details. So, Is this actually a bad habit? If yes, how can I avoid it? Please note that the above is just a simple example. Imagine the same situation happening in something a little bit more complex.


When is it acceptable to NOT fix broken windows?

In reference to broken windows, are there times when refactoring is best left for a future activity? For example, if a project to add some new features to an existing internal system is assigned to a team that has not worked with the system until now, and is given a short timeline in which to work with - can it be ever be justifiable to defer major refactorings to existing code for the sake of making the deadline in this scenario?


What are linkers and loaders? How do they work?

I am trying to understand things like linkers and loaders better. What area of computer science do they belong to? Compiler, Operating System, Computer Architecture? Where do linkers and loaders come into play during development?


Constructs for wrapping a hardware state machine

I am using a piece of hardware with a well defined C API. The hardware is stateful, with the relevant API calls needing to be in the correct order for the hardware to work properly. The API calls themselves will always return, passing back a flag that advises whether the call was successful, or if not, why not. The hardware will not be left in some ill defined state. In effect, the API calls advise indirectly of the current state of the hardware if the state is not correct to perform a given operation. It seems to be a pretty common hardware API style. My question is this: Is there a well established design pattern for wrapping such a hardware state machine in a high level language, such that consistency is maintained? My development is in Python. I ideally wish the hardware state machine to be abstracted to a much simpler state machine and wrapped in an object that represents the hardware. I'm not sure what should happen if an attempt is made to create multiple objects representing the same piece of hardware. I apologies for the slight vagueness, I'm not very knowledgeable in this area and so am fishing for assistance of the description as well!


How can I work on different projects without losing focus?

I'm doing a full-time job (developer) and at the end of the day, I work on my part-time job (developer). How do you work, with different projects, without loosing focus? Often, my focus on the full-time job still remains at my head when working on my part- time job or the other way around.


How to do MVC the right way

I've been doing MVC for a few months now using the CodeIgniter framework in PHP but I still don't know if I'm really doing things right. What I currently do is: **Model** \- this is where I put database queries (select, insert, update, delete). Here's a sample from one of the models that I have:               function register_user($user_login, $user_profile, $department, $role) {              $department_id = $this->get_department_id($department);         $role_id = $this->get_role_id($role);              array_push($user_login, $department_id, $role_id);              $this->db->query("INSERT INTO tbl_users SET username=?, hashed_password=?, salt=?, department_id=?, role_id=?", $user_login);         $user_id = $this->db->insert_id();                  array_push($user_profile, $user_id);              $this->db->query("                 INSERT INTO tbl_userprofile SET firstname=?,                  midname=?, lastname=?, user_id=?             ", $user_profile);     }      **Controller** \- talks to the model, calls up the methods in the model which queries the database, supplies the data which the views will display(success alerts, error alerts, data from database), inherits a parent controller which checks if user is logged in. Here's a sample:               function create_user(){         $this->load->helper('encryption/Bcrypt');         $bcrypt = new Bcrypt(15);               $user_data = array(             'username' => 'Username', 'firstname' => 'Firstname',             'middlename' => 'Middlename', 'lastname' => 'Lastname',                 'password' => 'Password', 'department' => 'Department',                  'role' => 'Role'         );              foreach ($user_data as $key => $value) {             $this->form_validation->set_rules($key, $value, 'required|trim');         }              if ($this->form_validation->run() == FALSE) {             $departments = $this->user_model->list_departments();             $it_roles = $this->user_model->list_roles(1);             $tc_roles = $this->user_model->list_roles(2);             $assessor_roles = $this->user_model->list_roles(3);                  $data['data'] = array('departments' => $departments, 'it_roles' => $it_roles, 'tc_roles' => $tc_roles, 'assessor_roles' => $assessor_roles);                  $data['content'] = 'admin/create_user';                      parent::error_alert();                 $this->load->view($this->_at, $data);                  } else {             $username = $this->input->post('username');             $salt = $bcrypt->getSalt();             $hashed_password = $bcrypt->hash($this->input->post('password'), $salt);             $fname = $this->input->post('firstname');             $mname = $this->input->post('middlename');             $lname = $this->input->post('lastname');             $department = $this->input->post('department');             $role = $this->input->post('role');                      $user_login     = array($username, $hashed_password, $salt);                 $user_profile   = array($fname, $mname, $lname);             $this->user_model->register_user($user_login, $user_profile, $department, $role);                  $data['content'] = 'admin/view_user';                      parent::success_alert(4, 'User Sucessfully Registered!', 'You may now login using your account');                       $data['data'] = array('username' => $username, 'fname' => $fname, 'mname' => $mname, 'lname' => $lname, 'department' => $department, 'role' => $role);             $this->load->view($this->_at, $data);         }          }      **Views** \- this is where I put html, css, and JavaScript code (form validation code for the current form, looping through the data supplied by controller, a few if statements to hide and show things depending on the data supplied by the controller).                    <form class="well min-form" method="post">

User Registration

              Username         <input type="text" id="username" name="username" class="span3" autofocus>              Password         <input type="password" id="password" name="password" class="span3">              First name         <input type="text" id="firstname" name="firstname" class="span3">              Middle name         <input type="text" id="middlename" name="middlename" class="span3">              Last name         <input type="text" id="lastname" name="lastname" class="span3">              Department         <input type="text" id="department" name="department" class="span3" list="list_departments">              <datalist id="list_departments">             <?php foreach ($data['departments'] as $row) { ?>                 <option data-id="<?php echo $row['department_id']; ?>" value="<?php echo $row['department']; ?>"><?php echo $row['department']; ?></option>             <?php } ?>         </datalist>              Role         <input type="text" id="role" name="role" class="span3" list="">              <datalist id="list_it">             <?php foreach ($data['it_roles'] as $row) { ?>                 <option data-id="<?php echo $row['role_id']; ?>" value="<?php echo $row['role']; ?>"><?php echo $row['role']; ?></option>             <?php } ?>         </datalist>              <datalist id="list_collection">             <?php foreach ($data['tc_roles'] as $row) { ?>                 <option data-id="<?php echo $row['role_id']; ?>" value="<?php echo $row['role']; ?>"><?php echo $row['role']; ?></option>             <?php } ?>           </datalist>              <datalist id="list_assessor">             <?php foreach ($data['assessor_roles'] as $row) { ?>                 <option data-id="<?php echo $row['role_id']; ?>" value="<?php echo $row['role']; ?>"><?php echo $row['role']; ?></option>             <?php } ?>           </datalist>
             <button type="submit" class="btn btn-success">Create User</button>
     </form>                The codes above are actually code from the application that I'm currently working on. I'm working on it alone so I don't really have someone to review my code for me and point out the wrong things in it so I'm posting it here in hopes that someone could point out the wrong things that I've done in here. I'm also looking for some guidelines in writing MVC code like what are the things that should be and shouldn't be included in views, models and controllers. How else can I improve the current code that I have right now. I've written some really terrible code before(duplication of logic, etc.) that's why I want to improve my code so that I can easily maintain it in the future. Thanks!


How safe & trustworthy are hosting sites such as sourceforge, github or bitbucket for closed-source projects?

I am considering using sourceforge, bitbucket or github for managing source control for my business. I have open projects and I participate in open projects such as gcc. But I also have a business where I develop closed-source software for my living. How trustworthy are sourceforge, github or bitbucket in terms of keeping software secure from prying eyes? How stable is the hosting in terms of data loss prevention? Has anyone out there based their business logic with such an outfit? Has anyone out there surveyed several of the hosting solutions? Thank you


Do I really want a dynamic Enum, or something else? Better caching? A Struct?

This question is asked on SO and this site often it looks like. "How do I do a dynamic enum?" Answers range from you shouldn't to possible compile time solutions. Now my question is do I want a dynamic enum that is generated from look up tables in the DB, or do I want something else that is similar? I have a solution using T4 at build time to generate enums from DB tables, that works fine. But now some of the look up tables have an 'active' flag on them. Does this mean they are not look up tables anymore? If that is changed I want to somehow regenerate my code without having to redeploy. These tables will not change often. Currently the app when it wants to populate a dropdown or something will query the DB. But if the values mostly remain static, why go to the DB every time, hence the use of enums. It also has the added benefit of getting rid of magic strings and numbers. Would static structs be better? Some sort of caching for the look up tables? Any advise welcome.


Can you recommend good quality online master's programs?

I've been looking at online master's degree programs in software engineering. Have you completed a master's program online? If so, where? Did you like it? Was it relevant or out of date?


Better to use error monad with validation in your monadic functions, or implement your own monad with validation directly in your bind?

I'm wondering what's better design wise for usability/maintainability, and what's better as far as fitting with the community. Given the data model:               type Name = String          data Amount = Out | Some | Enough | Plenty deriving (Show, Eq)     data Container = Container Name deriving (Show, Eq)     data Category = Category Name deriving (Show, Eq)     data Store = Store Name [Category] deriving (Show, Eq)     data Item = Item Name Container Category Amount Store deriving Show     instance Eq (Item) where       (==) i1 i2 = (getItemName i1) == (getItemName i2)          data User = User Name [Container] [Category] [Store] [Item] deriving Show     instance Eq (User) where       (==) u1 u2 = (getName u1) == (getName u2)      I can implement monadic functions to transform the User for instance by adding items or stores etc, but I may end up with an invalid user so those monadic functions would need to validate the user they get and or create. So, should I just:   * wrap it in an error monad and make the monadic functions execute the validation   * wrap it in an error monad and make the consumer bind a monadic validation function in the sequence that throws the appropriate error response (so they can choose not to validate and carry around an invalid user object)   * actually build it into a bind instance on User effectively creating my own kind of error monad that executes validation with every bind automatically I can see positives and negatives to each of the 3 approaches but want to know what is more commonly done for this scenario by the community. So in code terms something like, option 1:               addStore s (User n1 c1 c2 s1 i1) = validate $ User n1 c1 c2 (s:s1) i1     updateUsersTable $ someUser >>= addStore $ Store "yay" ["category that doesnt exist, invalid argh"]      option 2:               addStore s (User n1 c1 c2 s1 i1) = Right $ User n1 c1 c2 (s:s1) i1     updateUsersTable $ Right someUser >>= addStore $ Store "yay" ["category that doesnt exist, invalid argh"] >>= validate     -- in this choice, the validation could be pushed off to last possible moment (like inside updateUsersTable before db gets updated)      option 3:               data ValidUser u = ValidUser u | InvalidUser u     instance Monad ValidUser where         (>>=) (ValidUser u) f = case return u of (ValidUser x) -> return f x; (InvalidUser y) -> return y         (>>=) (InvalidUser u) f = InvalidUser u         return u = validate u          addStore (Store s, User u, ValidUser vu) => s -> u -> vu     addStore s (User n1 c1 c2 s1 i1) = return $ User n1 c1 c2 (s:s1) i1     updateUsersTable $ someValidUser >>= addStore $ Store "yay" ["category that doesnt exist, invalid argh"]


Attended (CEH or other) course but have no certification

Last summer I attended course for "Certified Ethical Hacker" led by Mr. Wayne Burke. The course was great. Mr. Burke was awesome, flashing with energy all the time, he would stay hours late just to share another piece of his experience with us. I learned a lot of new things, took lot of notes (to which I keep returning), and most importantly, it pushed my way of thinking in a direction. However, due to unfortunate circumstances, I did not attend the actual certification exam, therefore I do not hold the certificate. Now I'm looking for a job (in QA, not necessarily security-related) and while updating my CV, I ask myself: Should I mention the course in the CV? I'm thinking about two possible final effects:   * positive, since I _have_ been there, seen it, understood most of it---better than nothing, well?   * negative, as it could be perceived as failure, so why remind it? Plus, I definitely don't want to look like someone who is boasting with CEH and then turns out he did not make it Is there a recommended rule of thumb on these situations? Does anyone have similar experience? Note: Frankly (aside from what should be considered rational in context of career market), personally I _do_ feel strongly enlightened by the course, and I _do_ believe it helped me a lot in my growth. I don't even consider the missing cert as a personal failure: compared to the actual course, the (preview) questions were a bunch of numbers and tool names to cram up my head. **Update:** Finally I decided to list the course, in spirit as @tdammers wrote about. Anyway, in of interview I've been to, I was not given questions about C|EH-- neither technical ones nor "where is your ~~homework~~ certificate", which is not surprising since as I have pointed out, I wasn't looking for particularly security-centered position. Now I have a new job--just as exciting as I hoped for.


What are some games involving recursion?

I need to introduce a group of 5-15 people to recursion and I would like to do so by using a physical game/dance/activity they can play to get a feeling for recursion. The class is not so much focused on CS than general concepts so anything computer or programming related is out (but programmers are still the best people I could think of to bombard with such as question). I was thinking about using some kind of clap game such as teenie girls like to play that includes recursion but couldn't come up with one yet. The game/dance might well be ridiculous, it should just be interactive and get them some intuitive feeling for what recursion is and how omnipresent it is in our surroundings. Looking forward to your suggestions!


Is version history really sacred or is it better to rebase?

I've always agreed with Mercurial's mantra 1, however, now that Mercurial comes bundled with the rebase extension and it is a popular practice in git, I'm wondering if it could really be regarded as a "bad practice", or at least bad enough to avoid using. In any case, I'm aware of rebasing being dangerous after pushing. OTOH, I see the point of trying to package 5 commits in a single one to make it look niftier (specially at in a production branch), however, personally I think would be better to be able to see partial commits to a feature where some experimentation is done, even if it is not as nifty, but seeing something like "Tried to do it way X but it is not as optimal as Y after all, doing it Z taking Y as base" would IMHO have good value to those studying the codebase and follow the developers train of thought. My very opinionated (as in dumb, visceral, biased) point of view is that programmers like rebase to hide mistakes... and I don't think this is good for the project at all. So my question is: have you really found valuable to have such "organic commits" (i.e. untampered history) in practice?, or conversely, do you prefer to run into nifty well-packed commits and disregard the programmers' experimentation process?; whichever one you chose, **why does that work for you?** (having other team members to keep history, or alternatively, rebasing it). * * * 1 per Google DVCS analysis, in Mercurial "History is Sacred".


When should we clean up old, no longer used GIT branches?

We have several bugfix branches that are starting to pile up. They have been merged into master, and deployed to production. Is there a good benchmark for when these branches should be cleaned up? Should they ever be cleaned up, or is it good to have the historical data?


Why does git allow you to "change history"?

> **Possible Duplicate:**   >  When should the VCS history of a project be deleted? I am experienced using svn and recently started learning git. I was quite shocked to learn that git has features that allow you to "rewrite history". Coming from svn, I had accepted as sacrosanct the source control principle that once a change is committed, there is no way to "undo" the commit itself... the most one can do is execute a later commit that effectively "reverses" the changes made in the earlier commit, but one can always reproduce the state of any commit that had been done in the past. What is the rationale for changing this "principle"? Is there something different about git that makes this OK, or does the design of git reflect a different "philosophy" of source control that differs with the "philosophy" of svn?


Syntax Memorization

> **Possible Duplicate:**   >  Programmers forgetting syntax   >  Do programmers need a good memory? I'm a new web developer. I began learning HTML/CSS around June of this year. I picked them up easily, now I'm moving on to Javascript. My problem is this. I understand the concepts that the training material are teaching but I find myself coming up short when it's time to apply those lessons. Mainly it's due in part to the syntax. I memorize a function, apply it, test it, move on then forget it a few days later (the syntax, not the concept). My question is this. Should I be spinning my wheels trying to remember everything, or is knowing the concept enough. I know this has been addressed before but I couldn't find any real definitive real world answers. Feel free to discuss what methods worked for you when you started out.


Do programmers need a good memory?

It seems one has to remember all sorts of syntax to be able to program. If one don't have a good memory for remembering names, will it be more difficult to learn to program?


Is it a good idea to do UI 100% in Javascript and provide data through an API?

My primary day job is making HTML applications. With that I mean internally used CRUD-type applications with lots of editable gridviews, textboxes, dropdowns, etc. We're currently using ASP.NET webforms, which do get the job done, but the performance is mostly dismal, and quite often you have to jump through hoops to get what you need. Hoops which are hung from the ceiling and set aflame. So I'm wondering if it perhaps would be a good idea to move all UI to the JavaScript side. Develop a strong set of reusable controls which are tailored specifically to our needs, and only exchange data with the server. Yes, I like the "control" (aka "widget") paradigm, its quite well suited to such applications. So on the server side we would still have a basic layout simliar to our current ASPX markup, but that then would get sent to the client only once, and the Javascript part would take care of all the subsequent UI updates. The problem is I've never done this before, and I've never seen anyone doing this either, so I don't know what the problems would be. In particular, I'm worried about:   * **Performance** still. Benchmarking shows that currently the main delay is on the client side, when the browser tries to re-render most of the page after an AJAX update. ASP.NET webforms generated markup gives a new meaning to the word "web", and the rich Devexpress controls add their own layer of Javascript complexity on top of that. But would it be faster to recalculate all the necessary changes on Javascript side and then update only what needs to be updated? Note that I'm talking about forms that have several editable gridviews, lots of textboxes, many dropdowns each with half-a-zillion filterable items in them, etc.   * **Ease of development**. There would be a lot more Javascript now, and it would probably mix with the HTML markup of the page. That or some kind of new view engine would have to be produced. Intellisense for Javascript is also a lot worse than for C# code, and due to the dynamic nature of Javascript it can't be expected to get a lot better. Coding practices can improve it a bit, but not by much. Also, most of our developers are primarily C# developers so there will be some learning curve and initial mistakes.   * **Security**. A lot of security checks will have to be done twice (server-side and UI-side), and the data-processing server side will have to include a lot more of them. Currently, if you set a textbox to be read-only on server side, you can depend on its value not changing through the client roundtrip. The framework already has enough code to ensure that (through viewstate encryption). With the data-only approach, it gets harder, because you have to manually check everything. On the other hand, maybe security holes will be easier to spot, because you will have only data to worry about. All in all, will this solve our problems, or make them worse? Has anyone ever attempted this, and what were the results? Are there any frameworks out there that help in this sort of endeavor (jQuery and moral equivalents aside)?