Am I supposed to remember code from the book I'm using to learn?

I'm currently using a great book to learn what I need to know about making app's for the iPhone using cocos2d. So far, I am doing great, I read all the code and most of the time, It fits and I understand it. Sometimes, I go through it a couple of more times, over and over just so I fully understand something. My question is.. am I supposed to remember this code? Because while I do understand every block of code and why it exists, I can remember the code as well, but is that necessary ? What am I supposed to remember? The order? I already understand 99% of the syntax (so far everything is clear) .. I hope I'm making sense here. Do I move on after I read the block of code and understand it? Or do I move to the next block of code only if I remember what was in the previous code block? Because I can understand it, write out the code, learn why it's there, etc and then I move on, but is remembering it all what I'm supposed to do?


City exploration algorithm

The purpose of the algorithm is to create `n` routes on a geographical map, where `n` is being given, whereas all routes take no longer than `t` time units by foot and end where they start, while trying to have as little overlap as possible, meaning the user walking the routes walks on as few streets twice or more often as possible. The software is to calculate closed routes (starting point = ending point) while the length of the routes should equal the time `t`. Another restriction is that each street should be walked along as few times as possible to always explore new areas while walking for the same time period. Example: You are in New York City (google maps for an example map)   * You want to walk for 40 minutes.   * You want to be on new roads or paths as often as possible. Picture having a thread. The thread has a length of `velocity_walking * t` in a smaller scale. Now you glue the end and start to a starting point on your map, `lat` and `lon`. Then you move the thread so it is only on streets/walking paths, without being on the same street twice. Now you take another thread and glue the end and start to a starting point on your map, `lat` and `lon`. Now you do the same thing as above, trying to not put it over the other thread. You repeat this `n` times, all in all, so given the first two threads, you repeat it `n-2` times. So the steps are   1. Enter `n`   2. Enter `t`   3. Enter the starting point in `lat` and `lon`   4. Create `n` routes that take `t` time units to walk by foot, start and end in `lat`,`lon` and if possible don't contain the same streets or parts of streets twice. My idea: Having a circle of radius equaling `walking_velocity * t / 2`. Plan routes from start to point on circle to start. Disadvantages:   * Same streets to the circle's circumference and back.    * Many streets are omitted. What is the better algorithm to do this? Language does not matter, algorithm matters.


am I simply too old to try and get work as a programmer?

Just wanted to ask all you programming pro's these Q's. I am no spring chicken I am 36. I have been learning python and visual basic for about 2 years now and enjoy it a lot. I never got into programming before and regret not doing so as I find I enjoy it a lot. I know if I had found out how much I liked it and took to it years ago I certainly would have pursued it a lot earlier. I have never worked in programming or even IT before I have always worked in manual laboring jobs and am wondering if I could try and get work as a programmer once my programming knowledge is better in 1 or 2 years which will put me in my late 30's. Would this be too old to try and get work in the field? I am really only after anything I can get and know I won't be working for EA Games or something. I hope I could be a 'junior' somewhere despite the embarassement at my age. Starting so late in the field with no experience has me very worried that I would not be taken seriously. My programmer friend says you can start any age as long as you know what you doing, but I have heard different again. As much as I want to work as a programmer I really don't want to spend more time learning more programming only to find myself not even considered by employers because I'm too old and inexperienced and not some young University hotshot. What should I do? others say there is online opportunities which could potentially be used as experience, but is there? please help me out.


Ideal Operating System

Okay. So I'm currently trying to design an operating system, but I need ideas. Nevermind the feasibility right now, it's just in the design phase. If you had an OS that did whatever you wanted, what would you want it to do? Please be specific, and no "emulate unix or DOS" answers. Thank you.


UML representation of type being passed as a parameter

I want to draw a UML diagram of my program. Class `Barney` has a method `Yabadaba(Doo d)` which takes a parameter of type `Doo`. How do I represent that class `Doo` is used in class `Barney` in my UML diagram?


Software solution from the 2000's, should I attempt to patch or remake the whole thing?

I was sent out to discuss a system that a certain company is currently using and what should be done with it. The company manufactures various carton displays. This system was developed to keep track of clients, orders and prices. Lots have happened since the system was created and the system is now, as the manager described it, " _locked up_ " and " _problematic_ ", which I translate as "not dynamic" and "unstable". Some info about the system   * It was developed around the year 2000   * Fairly small system, 2-5 users, 6 forms, ~8 tables with average quantities of data   * Built on early Visual Basic, forms created with the drag and drop design. Interface is basically just a window with a menu and some forms   * Uses MSSQL database (SQL2005 server) to store data and ODBC driver to query, data was migrated from excel before this system, and before excel it was handled, calculated and written by hand and paper   * Users work in Microsoft XP environment (and up) Their main problem is that they can't adjust and calculate prices, can't add new carton types etc, correctly anymore because they can't (or rather, they don't know how to) touch the data on the server. I suggested 3 possible solutions   1. Attempt to patch the current system   2. Create a fresh new interface (preferably similar environment, VB.net or VB based)   3. Bring it back to an Excel solution, considering it is such a small system There might be more options, but these are the ones I could think of. My questions are   * What should I recommend and why?   * What is or could be the pros and cons of these alternatives?   * Are there other (possibly better) alternatives?


When creating an open source project, is coding in VB.net a bad idea?

I am planning on creating an open source project, however, I was wondering if developers tend to steer away from projects that are coded in VB.net, even if they know VB.net. From what I have read, more professionals use C++/C# and don't like VB.net, but beginners tend to like VB.net more. I am trying to make my project as beginner friendly, however, I still want some more experienced programmers so I don't have to carry the bulk of the load of the harder stuff. **Will I have much more contributions (to code, not money) when I chose either C++ or C#? Will more developers "play around" with my code?** I'm not worried about people who don't bother looking at the code, I just want to know would my project be more likely to prosper if I use a more popular language, or if I have a good idea, it will succeed no matter what language I use? By the way, no matter the language I chose, I will use the .net framework for ease of use. **If I do chose to use some form of C, do you recommend C# or C++? I have some experience with C (Arduino) and I plan on getting a book at the library if I use it for my project, so that is not a problem, but I really don't want my project to become abandon-ware. In fact, I hope someday, if I can, have it not dependent on me at all. (Not saying I won't contribute, but I don't have to spend all my time working on it.) * * * **EDIT:** So far, almost everybody thinks I should use either C# or C++. **Which one is more popular? Is there a benefit of one over the other?** * * * **EDIT 2:** ## **Please provide your answers with facts (like number of open source projects that use __ language, etc. so it can show trends).**


extensible effects in purescript

In Purescript, IO an other effects are managed with the Eff monad, and extensible effects, which are declared like this:               main :: Eff (trace :: Trace, random :: Random) {}      So if I understand well, this `main` declaration only allows to log to console, and generate random numbers. The `trace :: Trace, random :: Random` is a row of effect, ie an unordered labeled collection of effects. Now I get that `Trace` is an effect, and `trace` is its label. But why do we need both? It makes sense for records such as `{ foo::String, bar::String }` but I cannot understand why I would need to manage two `Random` effect with different labels. ie I would write the following:               main :: Eff (Trace, Random) {} -- no redundant labels      Are effect labels useful in purescript? If yes what for?


How to allow innovation in an Agile Methodology

It is one thing to say that agile methodologies are good in settings where requirements are poorly understood, or that significant novelty is involved. But should it be applied where outright innovation is required? If yes, how? If what you are contemplating is unknown in the industry, or even thought to be impossible, it may be difficult to conceive of the user stories and related tasks. For example, would it have benefitted Albert Einstein (or a hypothetical employer he reports to) to have devised the theory of general relativity by breaking it down into epics, sprints, and tasks? If the answer is "yes," then what special accomodations should have been incorporated to help an agile approach work best with Einstein's way of achieving revolutionary insight? To give a specific software example, imagine the year is 2008 and you would like to use WCF to provide COMET or "long-polling" type capabilities. All your research of "prior work" turns up nothing, and you even read an MSDN blogger say it isn't possible. Again, what adjustments or "flavor" could be brought into the user stories and tasks to accomodate the inventiveness (or audacity?) of this endeaver? Or would it indeed be better to conclude the effort is so innovative (in 2008), it is best left as an undirected think-tank exercise? The innovator who is operating under two-week sprints certainly does not want to be shot-down every time he abandons a dead-end task and starts working on a newly discovered task that was not envisioned when the sprint was defined. Likewise, when the sprint ends and no working code or working approaches are delivered, the innovator should not be shot down by management. There needs to be a way to label the effort as "success" even in these circumstances. In perhaps one or three more sprints of this kind of "dead end" pursuits, the innovator might finally hit on something that works. How does agile allow management know that each sprint was "ok" despite the innovative set-backs? How is this managed so that the burn-down chart does not look preposterous?


How would you transfer data between your data structures and databases?

I'm learning programming in school and I have this question that's bugging me about data structures and transferring the information stored inside them to databases. We're doing just small systems - registration for an event, point of sale for a local restaurant, sales and inventory, etc Let's say someone registers himself, should it be passed into a data structure and then into the database, or should it just be transferred directly to the database?


Is the Mercury Programming Language used in the field?

I've strong interests in Functional and Logic programming and Mercury seems like a good blend of the two. Is it used in industry at all? I'm one to learn a language just for the fun of it but it would nice to have practical, employable avenues for it. I could not find much in the way of examples of use in industry on the language website.


Is Haskell worth learning?

I am looking at this question primarily from a career point of view, so I hope you answer it accordingly. I am fairly proficient with Python, can write C++ and I am a final year student of computer science engineering I am looking to learn Haskell because I have heard a lot about it. My question is: apart from learning it because of all the good I have heard about it, is it any good for my career? Is it used in the industry? I am curious to learn it but unless it helps me somehow in my career, I am not willing to make that change at this stage. Looking for some personal experiences here. Thanks!


Can non-IT people handle a wiki?

My company is looking to improve their market research data management. **Current data management style:**   * "Hey Jimbo, where's that picture of our WhatZit 2.0?   * "yeah I remember that email about that company from that guy, gimme a few minutes to search my Outlook"   * "who has the newest copy of the Important Competitor's product catalogue? Mine is from 2009." ... "Colleen does, and she's on maternity leave. You'll have to call her to get her workstation password..." **Desired data management style:**   * data organized neatly by topic (legal, economic, industrial, competitor)   * for each topic, multiple media types stored together (company product images, press releases, contact info) but still neatly sorted by type   * data editing histories   * communal access (no data silos) I was thinking about setting up a department wiki for all users to access. It seems to satisfy the four criteria above, but I'm a little concerned about how user-friendly (read: decipherable to non-technical people) it is for the more advanced features like image galleries, article formatting, and the like. Has anyone here setup a wiki for non-IT people and had it not catch on fire, become a ghost town, or look like Geocities? Bonus question: can you see any obvious drawbacks to my choice of MediaWiki (or any other wiki) for solving this problem? (I'm hoping that some of you will have encountered this issue before and can offer some insights...)


How do I justify upgrading to Windows Server 2008?

We're just about to start a new greenfield project - it's a highly functional web application using ASP.NET MVC3, SQL Server etc. We're also going to be using Windows Workflow Foundation for the first time. Our client only wants to use his existing Windows Server 2003 web servers. My main issue (other than it is 8 years old) is that we don't much experierence of WWF development, but understand that using AppFabric (Server 2008 only) will improve WWF development. It's a significant cost to the client, as we need fail-over servers and a UAT environment as well. Am I correct in my understanding, and what methodologies can I use to justify the cost of upgrading?


How do you write a code analysis & refactoring tool to interface with Visual Studio?

Recently while working on a project of mine and doing some refactoring I got an idea to write a custom tool to help me analyze my code in a very specific context and perform some very custom refactoring. What I wish to do is to interface with Visual Studio somehow and use its powers to analyze my code and do some refactoring. There is a class view which displays the logical structure of a project with its classes, methods and variables so I assume the high-level information about the code is available. The question is, does it get exposed to the user? Is there some API for me to use? Basically I want the following:   1. A way to run some simple code analysis code blocks with the complexity of unit tests, nothing really fancy. Like getting the list of the classes matching a certain name pattern, iterate through their methods, filter the ones with certain attributes, look inside if there are calls to certain methods if so assert those calls having specific parameters. Then throw the analysis result into the output window, so that when I double-click there a location in the respective code file is opened in the workspace.   2. A possibility to command Visual Studio to perform surgical refactoring like renaming a specified variable and then applying its built-in renaming refactoring project-wide. These basic refactoring operations are available for the user in manual mode, can they be invoked from code?   3. Nothing that would damage the code style. Like the built-in refactoring which leaves the code style intact.   4. Not a static plugin for Visual Studio but solution-dependent code, so that it travels with the solution. Without installation. Perhaps like a separate analysis project in a solution, which I can set as active, uncomment the desired analysis methods and let them run.   5. Something very basic, without a GUI. A configuration file and the analysis code files will do.   6. Possibly without using any third-party tool, don't wish to introduce an extra dependency If it is at all possible, can you please give me some clues to the names, keywords, what to google for? I'm interested in any information you can provide to the subject - outline the scope of my options, known issues, difficulties, problems? Anything to make the big picture clear. And a million dollar question: provided it's possible, can something like that be quickly hacked together in a few hours?


Why is it considered a best practice to package the program code and the graphical interface code in different classes?

So my teacher tells me that it is very important to not encapsulate the program code and the graphical interface code in the same classes, But to keep them completely independent. Im currently writing an iphone game with a grid in it. to me it makes much more sense to Create both the graphical grid and the technical code in the same "Grid" class. Will other programmer frown upon this? Is it indeed very important to keep the graphical interface and code independent. What problems will arise if I don't? Thank you! EDIT: thanks guys! Would it be ok for me to write up the project first and then copy code around to form the separation of concerns design. I know that this may totally defeat the purpose, but just as practice...So that next time I can apply this design pattern from the start?


Application layer vs domain layer?

I am reading Domain-Driven Design by Evans and I am at the part discussing the layered architecture. I just realized that application and domain layers are different and should be separate. In the project I am working on, they are kind of blended and I can't tell the difference until I read the book (and I can't say it's very clear to me now), really. My questions, since both of them concerns the logic of the application and are supposed to be clean of technical and presentation aspects, what are the advantages of drawing a boundary these two?


Calculate Pi to N number of places

I am trying to work out how to calculate Pi to N decimal places, I think the default DP's for a float/double is 5 and then you have setprecision() however these are obviously inadequate, I need infinite number of places. Also would anyone have any idea of how to code something like y-cruncher?


Using Metro style in my web applications

I love the Metro UI (Modern UI/Windows 8 style UI, whatever) and would like to have the "tile" design on my site as well. Something like this or this. Am I allowed to do this or do I have to contact MS first about this? There is already one question but in this one the posted and accepted answer covered more the pivot control than the tileish UI.


Does it ever make sense to license source code as a learning resource under GPL?

I recently came across a series of articles walking through how to make a scheme interpreter. I was browsing through the code when I realized that it was AGPL. For the most part, the code itself is the teaching tool. Basically, the code as-is is what I need, however, I did want to understand how it all fits together as well. I realized though that if I copy and paste a single line of code, my project would become AGPL. Possibly by even more trivial actions? Anyway, is this a standard practice at all? Am I just being over-paranoid? Also, what benefits are there to this licensing scheme?


How To Start Programming

I have taken a programming course 2 years ago but I haven't worked in programming since then. I recently found a programmer job, but there is no programming team so for me to gain valuable experience from. I am Programming by myself and making changes on a program already made by my Ex-colleague. I need to know what should I do to be on the right track for becoming a professional programmer without a team to take experience from. What are the good practices to improve and what are the bad ones? I'm using VB.Net, ASP.Net and SQL.


What is the proper way to write a setter?

I am am trying to learn JAVA on my own. In one book I am reading the author says there is no convention for writing a correct setter. His example would go something like this:               public void setUnitCost(double inUnitCost) {          unitCost = inUnitCost;     }      However, when using Eclipse, and tell it to create getters and setters it does this:               public void setUnitCost (double unitCost){          this.unitCost = unitCost;     }      My question is which way is better? Does it make a difference in the programming world? What exactly is the difference between the two?


Handling Difficult Distributed Version Control System Merges With Pair Programming

A common problem in my very small team workflow is handling merges from trunk/stable repositories up to feature branches which are ahead of the trunk or stable versions, but which need to track the changes in the trunk and stable versions. We are using mercurial, but any DVCS would perhaps have a similar workflow, including Git, or others. Originally we had a workflow where a senior developer (me) did most of the merging, as that was the model I had experienced at a previous workplace, but similar to the previous place where we worked like that, this put a lot of burden on one developer to take the results of a large number of commits, and clean up the resulting mess. If you were merging one change, with one commit message, maybe you could do this cleanly, but what often happens to me, is that I get a little behind, and a week of changes needs to be merged. What I'm wondering is, when you DO get into a situation where a large merge is necessary, using Mercurial or DVCS, what is the process that you use, and does it involve collaboration between multiple developers on the team, and does your team use pair programming to solve this complex programming problem of How Do I Sort Out and Land the Changes from TRUNK that need to get to FEATUREXYZ branch. ![enter image description here](http://i.stack.imgur.com/SOli1.jpg) The workflow or standard-practice I am envisioning looks like this:   * when a merge up to a feature branch looks easy and only involves my own changes I do it on my own   * when a merge up to a feature branch also pulls in someone else's changes that are not trivial, I involve that person in the merge. Common sense? I think so. But I suspect that others have been down this road and can offer a more clearly elaborated, and "tried and true" approach for this general situation.


It takes me hours to completely understand solutions to 1000-pt problems on TopCoder. Should I get discouraged?

Sometimes this applies to the 500-pt ones too. I sometimes start feeling I will never improve enough to code them with ease like the others. Should I just quit? If not, why? It is extremely annoying, saddening and makes me feel immensely unable and dumb.


About Open source program license

I am developing an open source program which for my school project. I have done some research on it, but there are still few questions. It is a school project, it is not any advance application and I am willing to share my work.   1. Is that mean if I release my program with license, people will afraid to change my code because it may result in law sue?   2. Can I claim my product as "open source" if I don't have license, I can define some rule of it (but without law protection)?   3. Do i have to apply for those license (e.g. GNU), I have to submit my product code or only fulfill in a form?


Doing two internships simultaneously?

I need advice and I would appreciate your help. I recently got accepted for two internships, both require me to work 20 hours a week, and am wondering, is it wise to accept both and work 40 hours a week as an intern for both companies, is that even possible? I am interested in both to be honest and its hard for me to choose between them, yet I am afraid that doing both will be too much for me to handle. On the other hand, if I work for both I can be in a more stable state (money wise) and it would help me a lot in paying my college funds (among other stuff). I need some advice please?


Verfication vs validation again, does testing belong to verification? If so, which?

I have asked before and created a lot of controversy so I tried to collect some data and ask similar question again. E.g. V&V where all testing is only validation: http://www.buzzle.com/editorials/4-5-2005-68117.asp According to ISO 12207, testing is done in validation:   1. •Prepare Test Requirements,Cases and Specifications   2. •Conduct the Tests In verification, it mentiones. > The code implements proper event sequence, consistent interfaces, correct > data and control flow, completeness, appropriate allocation timing and > sizing budgets, and error definition, isolation, and recovery. and The > software components and units of each software item have been completely and > correctly integrated into the software item Not sure how to verify without testing but it is not there as a technique. From IEEE: > Verification: The process of evaluating software to determine whether the > products of a given development phase satisfy the conditions imposed at the > start of that phase. [IEEE-STD-610].   >  Validation: The process of evaluating software during or at the end of the > development process to determine whether it satisfies specified > requirements. [IEEE-STD-610] At the end of development phase? That would mean UAT.. So the question is, what testing (unit, integration, system, uat) will be considered verification or validation? I do not understand why some say dynamic verification is testing, while others that only validation. **An example: I am testing an application. System requirements say there are two fields with max. lenght of 64 characters and Save button. Use case say: User will fill in first and last name and save. When checking the fields and Save button presence, I would say its verification. When I follow the use case, its validation. So its both together, done on the system as a whole.**


What design would you propose to log reporting data so that the capture of, say, an additional form field can implemented easier?

Why is there an emphasis to log reporting information through an application to a separate database? I have seen designs where a logging manager is available to every business layer class whether it needs it or not. This in itself can create overhead? I was thinking that reporting information logging should be done as a separate service if it needs (at all) to consumed within another application. Nonetheless, much of the data (especially where data is stored as schemaless xml) just wastes database space. Why are there so many bad designs such that it becomes difficult to respond to reporting requirements without changing, say three, different software layers? What design would you proposed to log reporting data so that a change in reporting requirements can be done with ease? Typically, a change in report requiremnets would involve a request to the capture of an addition field on a form.


Use of past tense (passive voice) to connote immutability? (E.g. Array.Transposed vs. Array.Transpose)

_[Note: The below is a bit C# heavy in its syntax and conventions, such as citing FxCop rules, because this is my background, but the intent of this discussion is to be language-agnostic and the code examples used should generally be regarded as pseudo-code. -- Mike]_ I think we would all agree that classes should generally be designed so that their object instances are immutable wherever practical, and the results of calling class members should be free of side effects, as much as possible. Historical naming conventions, however, tend to use the active voice: 'GetSomething', 'DoSomehing', etc. and this is good because it states clearly what action that the class member is going to take. I am now beginning to think, however, that members might sometimes (or possibly often) benefit by being named in the past tense to connote that a value is returned without affecting the referenced object. For example, for a method that transposes an array, current naming styles would probably have it called 'Array.Transpose', but if this member returns a _new_ array, without transposing the referenced object, then I think that calling it 'Array.Transposed' would be more accurate and makes it clearer to the programmer. When working with an 'Array.Transpose()' method one might accidentally try to use code such as the following:               Array myArray = new Array();      myArray.Transpose();      But if the 'Transpose' method returns a new array without affecting the referenced object, then this code does nothing -- that is, 'myArray' would quietly _not_ be transposed. (I suppose that if 'Transpose' were a property, then the compiler would catch that the above is not legal, but FxCop guidelines state that a member that performs a conversion should be a method.) But if the method were named in the past tense as 'Array.Transposed', it would be clearer to the user that the following syntax is required:               Array myArray = new Array();      Array transposedArray = myArray.Transposed();      Other names that I think would fit into this category would be members named 'Resized' vs. 'Resize', 'Shifted' vs. 'Shift', etc. The present tense would be used for members that affected the referenced object, while the past tense would be used for members that returned a new value without affecting the referenced object. Another approach that is more common currently is to prefix each name with "Get" or "To", but I think that this adds unnecessary weight, while changing to past tense communicates the meaning effectively. Does this make sense to other programmers here, or does this past tense idea sound too awkward when reading it? **Edit:** Great discussions below, I thank everyone a lot. A few points I'd like to summarize based on your comments and my own revised thinking on this follows below. _Method Chaining "Fluent" Syntaxes_ Based on the discussions below, the use of the past tense is probably of some value when used on a mutable class in order to make it clear which members do, or do not, affect the internal state of the referenced object. However, for immutable classes, which should be the majority of the cases (one would hope), I think that the use of the past tense can make the syntax unnecessarily awkward. For example, with "fluent syntaxes" such as those created by method chaining, the use of past tense would make the code less readable. E.g., when using LINQ via C#, a typical method chain could look as follows:               dataSource.Sort().Take(10).Select(x => x.ToString);      If changed to the past tense, this would become awkward:               dataSource.Sorted().Taken(10).Selected(x => x.ToString);      Mind you, dataSource.Sorted() is actually clearer in meaning than dataSource.Sort(), because LINQ expressions always create a new enumeration without affecting the source. However, since we are fully aware of this when using this paradigm, the use of past tense is redundant and makes the "fluency" of reading it awkward for no real gain. _Use of Properties vs. Methods_ A key issue that was brought up below regards the FxCop guidelines for the use of "Get" methods vs. read-only properties. E.g., FxCop rule CA1024. Although not explicitly mentioned in that FxCop rule, the use of "To" methods would seem to apply to this rationale as well, since ToXXXXXX() methods are conversion methods. And in the case of ToArray(), the method is both a conversion method and is a method that returns an array. _Use of Past Tense for Boolean Properties_ Some suggested that the past tense can connote a boolean value, e.g. a 'Succeeded' or 'Connected' property. I believe that the retorts below emphasizing the use of an 'Is', 'Has', or 'Are' for Boolean properties and fields are correct. Past tense can help in this regard too, but not nearly as much as using an 'Is' prefix. Feel free to use the past tense for Boolean properties and fields, it does help, but I think that it's even more important to prefix the name with 'Is', 'Has', or 'Are'. _Overall Conclusions?_ For the issue of Tranpose() vs. Transposed(), I think that 'skizzy' got it right, suggesting that it should be Transpose() for a mutating action vs. GetTransposed() for a non-mutating result. This makes it 100% clear. But, again, I think that this might only apply for a mutuable class, such as an array. For immutable classes, especially where a fluent method-chaining syntax might be used, then I think that this syntax would become unnecessarily awkward. For example, compare:               var v = myObject.Transpose().Resize(3,5).Shift(2);      to:               var v = myObject.GetTransposed().GetResized(3,5).GetShifted(2);      Hmmm... actually, even here it seems to make it 100% clear that the result does not affect the source, but I'm not sure. I guess for a paradigm like LINQ where it is well known, the use of "Get" and/or the past tense is not necessary, but for a new API, it might have some value -- at first! If the API contains only immutable objects, once the user understands this, the use of "Get" and/or the past tense only reduces the readability. So I think there are no easy answers here. I guess one needs to think about the entirety of your API and choose carefully! \-- Mike


Understanding Loose / Tight Coupling in the "Real World"

I wont say what "community" because I want a non-biased explanation, but let's say you're building a reusable _module_ and that module requires 3+ dependent modules and removing 1 of them causes a breaking error not only in your app as a whole which uses this module, but the module itself. From my understanding (which must be wrong) a loosely coupled modular system will not break by simply removing one module. The app should still run but without that "feature" / module and the module itself shouldn't causes everything to not run simply because a dependent module doesn't exist. Is this wrong? If so, if modules are still dependent to the point of everything not working whats the difference between tight/loose coupling?


how to follow python polymorphism standards with math functions

So I am reading up on python in Mark Lutz's wonderful LEARNING PYTHON book. Mark makes a big deal about how part of the python development philosophy is polymorphism and that functions and code should rely on polymorphism and not do much type checking. However, I do a lot of math type programming and so the idea of polymorphism does not really seem to apply--I don't want to try and run a regression on a string or something. So I was wondering if there is something I am missing here. What are the applications of polymorphism when I am writing functions for math--or is type checking philosophically okay in this case.


Sending email notifications to users

What is the preferable way to send email notifications to users? I can do it both ways but what is better?   1. have some c# code that calls stored procedure in the database. Stored procedure based on some logic pulls all the emails data and sends email using database mail   2. or c# code calls stored procedure, gets all the nesessary data back and sends email itself using smtp server etc. I just wonder what is the preferable way in the sense of performance etc... C# code is a library that would be a part of the web application. So it's where it's better to put the load, on the application server or the database server? System will not be crazy busy, it's not like Amazon or something. But still it would be nice to create something that makes sense.


Need to learn powershell for sharepoint configuration

I need to be familiar with at least the basics of using powershell to configure sharepoint solutions and their user accounts over the next couple of weeks. Would general powershell learning resources differ much from those more sharepoint-specific? Or is powershell powershell? i.e. is the syntax pretty similar whether it's for configuring sharepoint or used for other purposes? Also, does anybody have links to recommended pdfs for such reading? (I'll be looking myself now anyway, but it's worth asking in case any of you have an ebook that has helped you personally.)


Stats on the average percentage of time required to create "usable" documentation

UPDATE: I've gotten a lot of feedback, but no info on what percent of time people spend on docs. To keep it simple, say the docs are for developers and peer reviewed; meaning the peer understands how to do it, and the comments are more for the what is being done, not how to do it from scratch; which in my case is the request, just don't think the request is common. Been working a project for 2 months, and it's done. When the project started, documentation was not a requirement; focus was "get it done." So, all the sudden there's an interest in creating documentation for the project... that's 100% turn-key, meaning that someone with no understanding of anything, would be able to do everything required to duplicate the work done. In case it matters, the project was a data profiling, extraction, transformation, and loading themed. Meaning I was given sets of data, a final state of the data -- and figured out all the issues/solutions to make that happen. Just wondering if anyone has seen stats on the average percentage of time take to write docs. (Have questions/feedback, just comment -- thanks.)


Handling SMS/email convergence: how does a good business app do it?

I'm writing a school administration software package, but it strikes me that many developers will face this same issue: when communicating with users, should you use email or SMS or both, and should you treat them as fundamentally equivalent channels such that any message can get sent using any media, (with long and short forms of the message template obviously) or should different business functions be specifically tailored to each of the 3? This question got kicked off "StackOverflow" for being overly general, so I'm hoping it's not too general for this site - the answers will no doubt be subjective but "you don't need to write a whole book to answer the question". I'm particularly interested in people who have direct experience of having written comparable business applications. Sub-questions:   1. Do I treat SMS as "moderately secure" and email as less secure? (I'm thinking about booking tokens for parent/teacher nights, permission slips for excursions, absence explanation notes - so high security is not a requirement for us, although medium security is)   2. Is it annoying for users to receive the same message on multiple channels?   3. Should we have a unified framework that reports on delivery or lack thereof of emails and SMS's?


Is it correct to ask contributers to rebase their pull requests on github

I maintain a relatively popular github repo. When a pull request is good to merge I usually ask the author to rebase it to a single commit before I merge it (especially when there have been multiple small edits). Is this good git practice? Is this acceptable/standard GitHub etiquette? So some benefits:   * I get a nice clean commit history in the commit logs   * I don't need to alter the commit myself   * It delegates some of the work Some possible drawbacks:   * I'm not sure if this is good etiquette   * I'm not sure if this is a good git practice   * I've usually already asked for a few other changes - this is one more and I don't want to discourage contributors.


Getting started with C# and Databases

I want to start using Databases in my C# Applications, unfortunately there appears to be lots of different ways of going about this. Which is the 'best' way from a learning perspective? (IE: What is likely to be used in a business setup)? If I want to download mySQL/Postgres and connect to that from C#, is that ok?


Must source code released under GPL be human-readable?

In a response to another question, a poster suggested that under the GPL: > ...you need to provide the human readable [code], not a whitespace stripped > version... Readability would seem to me to be subjective and unlikely to be explicitly required by the GPL. Is it?


Is there a chart for helping me decide between open-source licenses?

The Open Source Initiative lists 9 different licenses in their list of "License that are popular and widely used or with strong communities". I want to license my project as open-source. Unfortunately, I do not speak legalese. Is there some chart I could consult that will help me make the right choice, or at least point me in the right direction? For example a table summarizing the differences between the licenses, or perhaps a flow-graph using my requirements to guide me into the correct license for me? I also intend to meet a lawyer, but any information to start with will help.


Android apps and GPLv2 classpath exception

My Android app needs javax.activation and javax.mail (both GPLv2 licensed). However, I don't want to make my app GPL-licensed. What are the possibilities to not break the license requirements regarding the classpath exception? Currently, I use maven-dependency-plugin to pull those packages' source code and merge the compiled stuff with my own into one apk. Is that ok? If not, what is?


How to support mixed grammars?

I am currently writing a grammar for a programming language (PowerBuilder) and I am also collecting documentation about parsing and compilers creation. Now I would like to add in my grammar (that looks roughly like Visual Basic) the possibility to handle embedded SQL statements that are supported inline by the language (with the usage of binding variables like `select foo into :ls_bar from baz where col=:ls_criteria;`). As the embedded SQL is regular SQL syntax, I would not complexify my existing grammar but instead adapt an existing SQL-92 grammar to my needs and use it on these SQL blocks. The parser generator that I am mainly using (AntLR) has some possibilities to support mixed or "island" grammars as described in that article or another. I would like to compare these techniques with AntLR with others tools like Lex/Yacc, Flex, JFlex, that I used while playing with several simple language designs described in different CS courses available online. Could you point me to examples of implementations of parsers that support mixed grammars?


OpenSource license with commerial-use exemptions for the owner

I'm looking for an **open source** license which grants me additional privileges. Features:   * Anyone can freely modify, fork, use the code, as long as they make their source changes publicly available. They can use it in other open source projects, but not in closed-source projects. (similar to, say, GPL v3, with strong emphasis on contributing back)   * Only I and entities I specifically designate can use the code as part of a closed-source application. I am also exempt from the duty to publish the source code changes. (exemption from GPL duties).   * In return for my work, I do want the freedom to benefit from other's contributions (by using the project in my closed-source work), even if they fork the code. I'm not trying to forbid the commercial use, just to allow myself more flexibility to use the code, while still contributing to open source. I don't want to burn myself by being legally forbidden from using the libraries I wrote in my commercial projects. Large companies use such dual licenses to maintain an open source project, while also selling the premium version. Which licenses of this type are available? What caveats or obstacles exist? Is there any read-made license for this situation? Consulting lawyers is not an acceptable option at this point in development.


is down-casting always bad?

At my company, we have many different "services" that work in parallel and send messages to each other using a common messaging system. All message objects are derived from a common generic object we defined for messaging. When any service receives a message, the first thing it must do is downcast the object to the derived type so that it can extract the data needed. I have read all over the internet that you should not have to downcast a base object pointer to a derived object pointer and that having to do this is often a sign of bad design. I agree with this sentiment for most cases. And I can imagine different designs for the generic message object that wouldn't necessitate down-casting. But I don't see any big reason to handle this situation differently. So my overall question is: Is down-casting always a bad thing? Are there situations in which down-casting is necessary or acceptable?


What arguments exist against ever using the keyword substitution feature in many version control systems?

Are there any arguments out there against using the keyword substitution (i.e. replacing `$Revision$` with `$Revision: 5$`) feature in many version control systems? Are there any overall bad practices that using the feature encourages? Are the any pervasive and hard-to-solve problems that it causes when you do use it? Here an argument against using it:   * Keyword Substition: Why You Don't Need It It's succinct, and I think the argument about the problems it causes for binary files is cogent, but I don't find it compelling.


Basic hardware for iPhone development

I am new to Mac. If I want to start a iPhone development, what is the basic hardware I require? Would Mac Mini be good enough?


Good use of wrapper functions?

What do you consider good use of wrapper functions? When are they useful abstractions and in what cases harmful and unnecessary complexity?


In MVC where do you put action methods for views in the shared directory?

I have a website built using a **MVC.NET framework with C#** that uses some shared views and partial views. In order to display the views properly there is a bit of code that must reside in the controller. Currently I have that logic duplicated between controllers. An example would be an view that takes in an error id and then pulls down the record from the database and formats the view differently based on the error type. There is a small amount of work that needs to be done to the data in the controller before it can be displayed. **If the view is in the Shared directory where would the controller for it go? Or, is it better design to create a new controller just for it?** I am trying to choose a design that will prevent the "controller creep" that we had in a prior project. Update: I am currently learning about MVC using Razor and learned about the HTML.Action extension method. If I were going to go back and rewrite this project I would put the method into a "Shared" controller and use HTML.Action to format the data to display it on what ever screen I needed it.


What proportion of programming is done for embedded systems? More generally, please share any interesting statistics on programmers by domain, e.g. real- time/business/UI/gaming/… How you define the domain boundaries (e.g. what is an embedded system) is up to you, but please give a few words to explain your definition.


Better Understand the 'Strategy' Design Pattern

I have been interested in design patterns for a while and started reading "Head First Design Patterns". I started with the first pattern called the 'Strategy' pattern. I went through the problem outlined in the images below and first tried to propose a solution myself so I could really grasp the importance of the pattern. So my question is that why is my solution to the problem below not good enough. What are the good / bad points of my solution vs the pattern? What makes the pattern clearly the only viable solution? **MY SOLUTION** **Parent Class: DUCK**               <?php     class Duck     {      public  $swimmable;      public  $quackable;      public  $flyable;           function display()      {       echo "A Duck Looks Like This
";      }           function  quack()      {       if($this->quackable==1)       {        echo("Quack
");       }      }           function swim()      {       if($this->swimmable==1)       {        echo("Swim
");       }      }           function  fly()      {       if($this->flyable==1)       {        echo("Fly
");       }      }               }     ?>      **INHERITING CLASS: MallardDuck**               <?php     class MallardDuck extends Duck     {      function MallardDuck()      {       $this->quackable = 1;       $this->swimmable = 1;      }           function display()      {       echo "A Mallard Duck Looks Like This
";      }     }     ?>      **INHERITING CLASS: WoddenDecoyDuck**               <?php     class WoddenDecoyDuck extends Duck     {      function woddendecoyduck()      {       $this->quackable = 0;       $this->swimmable = 0;      }           function display()      {       echo "A Wooden Decoy Duck Looks Like This
";      }     }


Successful technical communities except for open-source?

Have you ever seen a successful technical community -- e.g. user group, industry organization? Am I asking about a group of software engineers who get together F2F (or maybe online) and discuss technical and industry issues with deep zeal and interest -- a place where meaningful connections are made. Here are the only examples I have ever seen:   * Open source   * Maybe the Silicon Valley Java Users' Group   * Homebrew Computing Club in the '70's This sort of thing does exist in academia. Also, business people do it all the time -- but networking is part of their job. Of course, there are lots of conferences and attempts at user's groups. However, almost all committed, serious software engineers, when asked about this, say "I don't have the time", which means that the organizations are not worthwhile to the best in our profession. Has anyone seen any organizations with an ongoing spirit of enthusiasm from top software engineers?


What are the real benefits of participating in ACM student group?

Are there any ACM students here? What are the real benefites of participating in this program? And is it truth that it's not free?


How to encourage creative user interface design?

When I picture a really well functioning software team in my mind, one of the visions I have is of a developer showing off to a small group of devs some cool, clever UI that they just came up with based on something that they were just playing with. I'm afraid that while we're doing great at being creative writing expressive, well architected, high quality code - we aren't pushing any creative boundaries when it comes to effective user interface. What's an effective strategy for encouraging developers to push their boundaries with user interface? Edit: I'm looking for something "lab oriented", like for instance pair programming sessions focused on some problem or other.


Where to host open source mini-projects like jQuery plugins

I've written few jQuery plugins (as well as some other stuff) and I publish all the code on my blog (http://erraticdev.blogspot.com). I update them as people tell me about any issues they came across by leaving comments on blog posts. Then I update the code and republish my original post. Worked so far as expected. But this seems like a bad way of code hosting. It does work I admit but it's not really version controlled. Only latest version (which should be used anyway) is accessible. I've use Google Code hosting for few of my other non-jQuery projects which seems fine because I can centrally track all my web content (blog an those projects) in Google Analytics. The bad side is it takes some time to set up new projects with writing project page description. Version control seems the main benefit although some projects may not be updated at all... So what's the point then? My plugins are therefore available as is. No minified versions or similar. I guess I could also upload full + minified version on my Google Docs and link them on my blog if I wanted to, couldn't I? ## Question What would you suggest where (or how) should I make my public code available to public? Should I change code hosting at all apart from having it freely available on my blog?


I need to know the reasons why learning Linux Shell Scripting (BASH) benefits me as a PHP developer

I have been developing web sites/applications using the LAMP stack for almost 5 years. Currently I am interested to dig more into Linux OS, specifically BASH **but from a web developer perspective, not from sys admin perspective.** I am not intending to administrate Linux Servers. Only, I want to know, does learning shell scripting benefit me as a PHP developer? Does it make me a better, more skilled developer, or just its something irrelevant? Reasons, and examples are highly appreciated. Thanks in advance.


What is the best practice for verify if a client has already dowloaded information from server?

I need to verify what data wasn't downloaded yet. For example, how does Twitter or Facebook verify if a specific client has already dowloaded a piece of information? When a mobile app like twitter make a request to twitter.com will receive only new data but not data that it has already downloaded in old requests.


How to improve concepts for interview

I had an interview and interviewer told me to improve on the concepts. E.G.:   * He asked me types of arrays are there and I answered that there was two types of array: A simple array and an associative array.   * He also asked me why we use PDO and I answered we can use any database, E.G. Oracle and MySQL and it helps with SQL injection. He then asked me how it helps with SQL injection and I was told I didn't give the correct answer.   * He asked me about persistent connections and told him I just used `mysql_pconnect`. I don't know where it will be used and how. Is there is any standard way I can follow to help me improve upon these concepts?


What does an MSDN subscription offer?

I'm curious because I notice that the Ultimate subscription costs $12,000... for one year (after that, it's $3,800 to renew). Looking at the subscription chart, you do get quite a bit of software that is normally expensive by itself. Is the package meant for 1 person or is it meant for like a business-type bundle of some sort? If it's the latter, I can _kind of_ understand that, but I can't fathom where anybody is going to have 12 grand to plop down on something that only lasts 12 months. Anyway, yeah, my question is, is this a good deal to anyone at all? Maybe it's just me not having any industry experience and this is actually a steal and millions of companies should be buying it right now, but I just can't personally picture this being worth the money.


Building and Debugging an IDE using the same IDE

This may be a question more suited some Programming Meta Discussions. I was trying to delve deeper into the inner plugin management feature for QT Creator 2.x IDE provided by Digia Inc. So I effectively downloaded the source code for QT Creator and built it to debug how this functionality is implemented. Hence I used an IDE to debug the same IDE. So my question is are there any pit-falls while doing so? Is it recommended that in such a scenario it's better to use two different IDEs (e.g. using Visual Studio to build QT Creator).


When do you get your best ideas?

Are there certain activities that provide inspiration at unexpected times? One that I've noticed is when I'm mowing the lawn or shoveling snow - living in Minnesota it seems I'm always doing one or the other. The physical activity gives my brain a chance to wander and ponder either the most pressing problem on my mind or some random thought of the day.


Do I really need a unit test framework?

Currently at my job, we have a large suite of unit tests for our C++ application. However we don't use a unit test framework. They simply utilize a C macro that basically wraps an assert and a cout. Something like:               VERIFY(cond) if (!(cond)) {std::cout << "unit test failed at " << __FILE__ << "," << __LINE__; asserst(false)}      Then we simply create functions for each of our tests like               void CheckBehaviorYWhenXHappens()     {         // a bunch of code to run the test         //         VERIFY(blah != blah2);         // more VERIFY's as needed     }      Our CI server picks up "unit test failed" and fails the build, emailing the message to the developers. And if we have duplicate setup code, we simply refactor it like we would any other duplicated code we'd have in production. We wrap it behind helper functions, make some test classes wrap setting up frequently used scenarios. I know there's frameworks out there like CppUnit and boost unit test. I'm wondering what value do these add? Am I missing what these bring to the table? Is there something useful I could gain from them? I'm hesitant to add a dependency unless it adds real value especially since it seems what we have is dead simple and works well.


Triggering custom events in AJAX callbacks

I'm pretty new to JavaScript, but one of the things that's been frustrating is that our AJAX callbacks have been getting packed with different functionality, making it difficult to keep everything separated and organized. I'm really new to programming, I have a feeling learning MVC a bit more would help me, but for now using custom events seems like it could help me keep my code a lot cleaner and prevent some problems. Here's what I'm talking about:               function myAjaxFunctionThatGetsTestData(){         $.post('ajax/test.html', function(data) {             $(document).trigger('testDataLoaded',data);         });     }          function myOtherFunctionThatsDependentUponAjax(){         getSomeTestData(); //start process of retrieving the data from ajax         //then let me know when data has been retrieved         $(document).one('testDataLoaded', function(data){             alert (data);         }     }          function getSomeTestData(){         //maybe data was already retrieved by a different module, so check first         if (data){             $(document).trigger('testDataLoaded',data);          }         else{             myAjaxFunctionThatGetsTestData();          }     }      I also don't know if it's ok that I'm triggering document or not... Are there any patterns that look like this that I can read more about? What are the potential problems with this?


Using NSpec at various architectural layers

Having read the quick start at nspec.org, I realized that NSpec might be a useful tool in a scenario which was becoming a bit cumbersome with NUnit alone. I'm adding an OAuth (or, DotNetOpenAuth) to a website and quickly made a mess of writing test methods such as               [Test]     public void UserIsLoggedInLocallyPriorToInvokingExternalLoginAndExternalLoginSucceedsAndExternalProviderIdIsNotAlreadyAssociatedWithUserAccount()     {     ...     }      ... and I wound up with maybe a dozen permutations of this theme, for the user already being logged in locally and not locally, the external login succeeding or failing, etc. Not only were the method names unwieldy, but every test needed a setup that contained parts in common with a different set of other tests. I realized that NSpec's incremental setup capabilities would work great for this, and for a while I was trucking a long wonderfully, with code like                 act = () => { actionResult = controller.ExternalLoginCallback(returnUrl); };                      context["The user is already logged in"] = () =>                 {                     before = () => identity.Setup(x => x.IsAuthenticated).Returns(true);                     context["The external login succeeds"] = () =>                     {                         before = () => oauth.Setup(x => x.VerifyAuthentication(It.IsAny<string>())).Returns(new AuthenticationResult(true, providerName, "provideruserid", "username", new Dictionary<string, string>()));                         context["External login already exists for current user"] = () =>                         {                             before = () => authService.Setup(x => x.ExternalLoginExistsForUser(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(true);                             it["Should add 'login sucessful' alert"] = () =>                             {                                 var alerts = (IList<Alert>)controller.TempData[TempDataKeys.AlertCollection];                                 alerts[0].Message.should_be_same("Login successful");                                 alerts[0].AlertType.should_be(AlertType.Success);                             };                             it["Should return a redirect result"] = () => actionResult.should_cast_to<RedirectToRouteResult>();                         };                         context["External login already exists for another user"] = () =>                         {                             before = () => authService.Setup(x => x.ExternalLoginExistsForAnyOtherUser(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(true);                             it["Adds an error alert"] = () =>                             {                                 var alerts = (IList<Alert>)controller.TempData[TempDataKeys.AlertCollection];                                 alerts[0].Message.should_be_same("The external login you requested is already associated with a different user account");                                 alerts[0].AlertType.should_be(AlertType.Error);                             };                             it["Should return a redirect result"] = () => actionResult.should_cast_to<RedirectToRouteResult>();                         };      This approach seemed to work magnificently until I prepared to write test code for my ApplicationServices layer, to which I delegate viewmodel manipulation from my MVC controllers, and which coordinates the operations of the lower data repository layer:               public void CreateUserAccountFromExternalLogin(RegisterExternalLoginModel model)     {         throw new NotImplementedException();     }          public void AssociateExternalLoginWithUser(string userName, string provider, string providerUserId)     {         throw new NotImplementedException();     }          public string GetLocalUserName(string provider, string providerUserId)     {         throw new NotImplementedException();     }      I have no idea what in the world to name the test class, the test methods, or even if I should perhaps include the testing for this layer into the test class from my large code snippet above, so that a single feature or user action could be tested without regard to architectural layering. I can't find any tutorials or blog posts which cover more than simple examples, so I would appreciate any recommendations or pointing in the right direction. I would even welcome "your question is invalid"-type answers as long as some explanation is provided.


Is deprecating a real commitment?

If you deprecate something, are you guaranteeing you will get rid of it in the next major release? Is it reasonable to take two or three releases before you get rid of it completely? Update: Thanks for the answers. Java is a good standard for how to do this - any others? Any examples from Microsoft's APIs? Update2: It seems like in "Microsoft-ese," deprecation means "it's going away in the next release." Which was part of my confusion; others don't endow the word with this meaning.


Using EC2 instance as main development platform

**My problem** I am working as a consultant for various companies. Each company provides me with a laptop with their software on and I also have my own, where I have my development environment. I tend to buy a new laptop every second year and find myself spending lots of time configuring and installing software. I also spend a lot of time waiting for my laptop to process things. To solve all these issues, I am now considering using EC2 (running windows instances) as my main development platform and just access this from any PC I happen to be at. I calculated that running the Large instance (cheapest 64-bit) for 8 hours a day for a year costs me 960$ per year, which is acceptable. I imagine that when I approach the workplace each day, I will make a single tap on my phone to fire up the instance, so it is ready when I get to work. I should have different icons on my phone to fire up the various instance types. The same software should of course automatically be loaded on the various hardware (sometimes I would even need their instance with 68.4 GB of memory). Another advantage is that if I am having a specific problem with my instance, I could fire up another instance and have someone look into the problem and update the image. **My question:** Does anyone have experience with such a setup on EC2? What kind of problems do you foresee?


In general how do Event Handlers work?

This is a general topic, **How do Event Handlers work?** This means behind the scenes - what happens when they are created. I have a rough idea - but would like to have it confirmed.


How to calculate the worst-case runtime of this search-algorithm

I've written a special `indexOf` function for a list of unsorted unique values. I can search for one or multiple (unsorted) values, passed as array/list, and the function will return me an array/list of indices (possibly empty). Based on the following circumstances:   * I know that the values i'm searching for are in the list   * I don't care about the order in which the indices are returned   * Uniqueness I'm doing the following:   1. Walk through the list (of size n)   2. Compare the values with all values in the search-list   3. If there's a match break, add to results, break out of the loop and remove the found value from the search-list (so it's smaller on the next item)   4. If there are no more values left to search for, break out of the list-traversal. I'd like to know how to analyse this algorithm, and specifically what the worst-case runtime is. (I guess if I'm searching for all values contained in the list.) Source in JavaScript:               function multipleIndexOf(search, arr) {              var searchArr = search.slice(0);         var result = [];              /* loop through array */         for (var i = 0, l = arr.length; i < l; i++) {                  /* loop through search values */             for (var i2 = 0, l2 = searchArr.length; i2 < l2; i2++) {                      /* if a search value matches... */                 if (arr[i] == searchArr[i2]) {                     /* add to result */                     result.push(i);                          /* remove from array */                     searchArr.splice(i2, 1);                          /* continue search with next */                     break;                 }             }                  if (searchArr.length == 0) {                 break;             }         }              return result;     }


Where can I find a quick overview of Enterprise Java Beans?

I'm a fresh graduate, and I'm about to interview in two days and things are tight. I am well versed with Java EE Servlet and JSP technology, but never really used EJBs. Is learning about EJBs really important to effectively use the Java EE framework? Is it even necessary to have an idea about the technology for the interview? If yes, where can I find something that will be just an overview on the topic - a simple "hello world" tutorial that states what else is possible? I tried the terse roseindia tutorial and the very detailed Oracle tutorial, but I'd need _some_ time in order to complete it. As something unrelated, in the interview, can I mention of my knowledge about Django despite knowing that the company does not pretty much employ Django?


Should we write a unit test for class that call another class that have code written

Suppose that there are two class 'A' and 'B' 'A' has a lot of nested conditions that have all unit test covered. 'B' has a property that will call class 'A' and return value according to the result of class 'A' On class 'B', when i want to write unit test. Should i just mock class A and verify on class B that it has been called a specific class 'A' method.


Qt plugin for Eclipse/PyDev

I have installed PyDev and want to start with GUI apps. Heard about Qt but how to integrate it with PyDev? Is there any Python IDE that comes bundled with Qt or other GUI frameworks and also Visual Studio like ToolBox to add controls on the Form? I don't want to go with IronPython.


Algorithm to calculate estimated future usage of a defined value

I am looking for the name of a computer algorithm. I'm fairly sure that one should exist which will help me, but I can't for the life of me figure out what to search for. If you have implementations of the algorithm, that'd be awesome - but I'm really just researching this because I'd like to figure out how to build it myself. Basically, I'm looking for an algorithm that can calculate future usage of some set of data based on my previous usage. For example, my electricity supplier knows how much power I've used for the previous 20 days of a 30 day month, so they can extrapolate that out and predict how quickly I will run out of money on my power account. I'd like to know if there's an algorithm out there that can tell me in how long I'm likely to run out. What I'm looking for is something that given the following inputs:   1. A range (e.g. 30 days)   2. A period of time through that range (e.g. 4, never smaller than zero, never greater than the max of the range)   3. Some values for previous time periods - either the previous days, or the same days from previous months)   4. A total value for this range (e.g. 300) Can give me a date range in which I'm likely to run out of the total value (300). What I'd like at the other end would be something simple - e.g. "Based on previous usage, you're going to run out in 2 days." I've done the usual Google searches, but haven't come up with anything particular that even looks close - yet as far as I can see it's a reasonably common algorithm used all over the place.


What design do I follow to convert my classic ASP pages to a Java Enterprise Web Application?

There are so many Java technologies that it is difficult for me to know where to start. I understand JSP and Servlets. I know what http servers to use. Real basic stuff. What I don't understand is what I do after that? I don't want to create a bunch of jsp and servlets. That's not very different than what I have. I need to query various databases. Some are direct hits. Some have webservices I need to consume. I will have to create a login system that hits active directly. Aren't I supposed to do more to make a "big java" enterprise application?


How to document program flow so the outcome looks professional?

I have designed a simple website on paper. Now I want to produce a professional-looking document for my customer to approve. How can I do this? I've tried Visio, but it seems horribly overcomplicated and unsuitable for my purpose. I could describe what I've written in words in a Word document but that'd be much harder to read and understand. ![enter image description here](http://i.stack.imgur.com/1rTG3.jpg)


ASP.NET tags best practices

I'm working on my first ASP.NET project and I'm torn between using asp tags (`<asp:SomeElement`) everywhere or use some regular HTML for simple things that need no code behind, like fixed divs, static text, etc. I think it would be best to use ASP tags only for code behind and other dynamic stuff, whereas static elements can be in vanilla HTML, but that's assuming I won't ever need to turn them into ASP.NET in the future. Is there a best practice/recommended approach for this?


What is a good C or Obj-C framework for manipulating Git Repositories?

What Obj-C/C libraries have you used for manipulating git repos in your Mac apps? I am working on a Mac app that I would like to be able to clone and modify git repos. Using git directly is not an option as it is GPL and I'd like to sell my app commercially without opening the source. I've seen libgit2, which I could link, but I'm not sure how to do that properly, and it doesn't appear to implement any of the things necessary for pushing/pulling repos over the git protocol.


When to use python function nesting?

I am writing a program that creates backup of directories. Which of the following approach is better for code organization? Create separate class for Backup and Zip logic -               class BackupUtil:         def backup(self):            None          class ZipUtil:         def archive_dir(self):            None      Or use function nesting like this -               class BackupUtil:         def backup(self):             def archive_dir():                 None              None


delegate classes for UI events

When designing a delegate to represent the state of a UI (java swing) what is cleaner: to manipulate the delegate directly from the custom event handlers defined in the UI code, or to register the delegate as a change listener on the UI elements? (expunging basically all logic from UI code) I'm more for the second design, but I'd like some feedback before churning out a load of (bad) code.


Building an organization-specific XML editor in HTML

I'm building a user friendly XML editor in HTML/JS. Looking for some general advice on how to build the editor UI and which approach you'd recommend on mapping the data to the UI. **Details about the problem:** Basically I'll fetch a single object as XML from a sever. The XML objects in question will be a small set of organization-specific XML which can only be structured in a few different ways. (Overall there are only about 15 different types of nodes available.) So I'll know all kinds of nodes that can appear, so I know which kind of UI to create for each type of node. Basically, all classes have the same root node ( _Item_ ). The 1st child node of that class can be a single _List_ , _Table_ , _Person_ or _Building_ node. After that, there are usually about 4 levels of multiple child-nodes, of varying structures. For example:   * A _Person_ containing a _List_ of _Addresses_ , where each Address node has two properties; an _id_ and a _type="personal address"_. Anywhere inside the text of each Address there can also be a reference, a kind of internal link to an id in the system.   * A _Table_ consists of _Header_ , _Footer_ and a _Body_ with and an optional number of _rows_ and _cells_ The use case is the following: The user will always start by loading an existing XML item into the editor. The user is allowed to edit existing values, remove them, and add new values. (Since all items have the same kind of root node, the user will have access to add pretty much any kind of node they want.) When they are done they hit 'Save' and the editor closes, and a view mode (already completed) shows the saved item. * * * I have 2 ideas for the editor UI:   * A sort of Markup-editor in the style of StackExchange (a single text field with simple markup tags)   * A HTML form where you render each node as one or more input fields, and use buttons to move/add/delete the fields. I'd render _Tables_ as HTML tables, and _Lists_ as an unordered list with every list item containing multiple input fields (one input field for each _Address_ and one dropdown for the _type_ , and stash the id in a _data-id_ parameter). **Which of these UI approaches would you recommend?** (Feel free to ask more questions about the XML.) **How would you recommend mapping the data to the UI?** Would you keep all the data inside the HTML during editing and then parsing it back to XML when the user saves his work. Or store the data as a JavaScript object, work directly with the JS object and just update the UI based on the JS object? Perhaps using some MV* framework with 2-way-binding? (I suppose that method would only be considered if I built the UI as a Form.) Or would it always be easier to traverse the XML node-by-node and generate UI elements based on that?


How do I maintain consistency between hard-coded values in different files?

I have a C source file and another (non-code) file in a project which contain the same hard-coded value. Ideally, the value would be specified in only one location and be copied to the other location automatically during the build process. It's not hard to think of hackish ways to accomplish this task, but I want to know if there is a common way of doing it. What standard method or approach should I use to guarantee that the two values remain consistent? In other words, how should I maintain consistency in a non- hackish way?


How to organize repositories for a split library?

I have two libraries that implement a protocol: one provides tools for establishing a channel between two parts, and the other provides classes and tools for building and parsing the binary protocol messages. These two libraries can be used independently, they don't depend on each other, and each has its own build setup. However, they do share a common set of examples (using both libraries) and documentation (tutorials). * * * I have two alternatives in mind for organizing this in Git repositories: # Alternative 1 Make each library be in its own repository. A central repository would keep the common documentation, examples and tools for cloning both repositories and bootstraping them. Users would use this main repository, and developers would work on the dedicated repositories. I don't want to use Git submodules since they are hard to manage this way (versioning becomes much harder to do when the libraries constantly change). # Alternative 2 Place it all together: both libraries, documentation and examples. Versioning would be applied to both libraries, since they would be treated as a single (though separated) entity. This is how we are doing it now. It makes things simpler but I feel it could be improved. * * * So... what are the best practices for organizing it all using Git? I'm open to other alternatives too. Even though we're not using it right now, it's possible that we will be using continuous integration tools, automated testing and builds, etc.


Good technique for search text tokenization

We are looking for a way to tokenize some text in the same or similar way as a search engine would do it. The reason we are doing this is so that we can run some statistical analysis on the tokens. The language we are using is python, so would prefer a technique that works in that language, but could probably set something up to use another language if necessary. # Example **Original token:**               We have some great burritos! **More simplified:** (remove plurals and punctuation)               We have some great burrito **Even more simplified:** (remove superfluous words)               great burrito **Best:** (recognize positive and negative meaning):               burrito -positive-


How do I make a domain model that doesn't violate OOP?

My game reads a number of JSON files, deserializes them, and hands the resulting objects off to the classes that need them. These deserialized objects, which can be thought of as the domain model, are normally very simple:               public class Settings     {         public bool FullScreen = false;         public int WindowWidth = 800;         public int WindowHeight = 600;     }      But one of these objects is not so simple:               public class Sprite     {         [JsonProperty]         private readonly string assetName;              [JsonProperty]         private Vector2 position;              // other properties...              public Sprite( string assetName, Vector2 position )         {             this.assetName = assetName;             this.position = position;         }              public void Move( Vector2 direction )         {             // do move         }              // other methods...     }      The properties of the Sprite class are private because I want to have good encapsulation. This means it has a constructor that accepts many arguments and several other methods for setting its properties. Also, each property needs an attribute so it can be read by the JSON parser. It looks like a POCO, but I read that POCOs should be persistance ignorant. I could create a simpler domain model that acts more like a DTO to satisfy this:               public class Sprite     {         public string AssetName = "default.png";         public Vector2 Position = Vector2.Zero;     }      Now my Sprite class is nice and ignorant. I can write another class to handle business logic type of stuff:               public class SpriteWhatever     {         private Sprite sprite;              public SpriteWhatever( Sprite sprite )         {             this.sprite = sprite;         }              public void Move( Vector2 direction )         {             // do move         }              // other methods...     }      But then I'm worried that my domain model is anemic. In order to avoid _that_ , I could just make all the properties of the Sprite class public, and keep all the business logic in it, but then I have no encapsulation. What should I do?


Forked a project, where do my version numbers start?

I have forked a project and have changed lots of it. This fork isn't just a small feature change here and a buried bug fix there, its a pretty substantial change. Only most of the core code is shared. I forked this project at v2.5.0. For a while I've started versioning my fork at v3.0 . However I'm not sure if this is the right way, mainly because when that project hits v3.0, things get confusing. But I don't want to start over at v1.0 or v0.1 because that implies infancy, instability, and non-refindness of a project. This isn't true, as most of the core code is very refined and stable. I'm really lost on what to do, so I ask here: Whats the standard way to deal with this kind of situation? Do most forks start over again, bump up version numbers, or do something else that I'm not aware of.


Public Speaking in software development

Greetings my fellow cubicle dwellers. I've found my role gradually change from "feature-maintainer" to "feature- developer". While much of the former would consist of fixing and/or updating an existing feature (and quietly grumbling about it's implementation with complete naiveté), in this new role I find:   * Have to communicate with immediate management to define the development requirements to turnaround the new feature   * Have to communicate with design to determine the user requirements of the new feature   * Have to communicate with QA to determine test sets for the new feature, as well as it's current state during development.   * Have to communicate with producers/project-managers to define remaining turnaround time as well as updates in development requirements.   * and finally, have to occasionally communicate with upper-management to defend the new feature and demonstrate it's minimized risk to the upcoming release. The last item is key here, and this took me a couple occasions to completely realize. In all, though, it becomes very apparent that communication skills ARE important, even or especially as such for developers who feel they 'own' the feature they're working on. All of this said, I recognize it's importance and would like to improve my skills in this area further. I enjoy one-on-one communication but find I tend to stutter a bit when speaking to any group larger than a few people I know well. Where can I find good resources to improve my own communication skills?


Does the Composite design pattern implement recursive behavior?

The Composite design pattern allows us to call an `operation()` on a 'composite' node in a tree structure, and this `operation()` will be called on all of the children, subchildren and so on. When an element's `operation()` is invoked, it is it's responsibility to call `operation()` on all of it's children, and so on. Each child responsible to invoke the operation on it's own direct children. I understand why this has a **_recursive nature_**. When we learn of this design, the word 'recursion' is inside our heads all the time. **But can this be considered 'recursive behavior' in the strict sense of the word?** I always thought that recursion simply means a process where **'a function calls itself'.** ('function' or 'method' or 'procedure' etc). However, in the Composite design pattern, **no method calls itself.** A method calls the identically-named method in the objects composed with it (serving as it's 'children') - but it never calls itself (aka `void operation(){ this.operation(); }` never happens). So, does the Composite design pattern create **recursive behavior**? Or does it create behavior **resembling the nature of recursion**? Is my definition of recursion wrong because it's too strict? If so, **how would you define recursion?**


Which are the topics in Mathematics that a developer should absolutely know?

I've studied mathematics and found the subject very interesting, but after getting into programming and coding stuff, I feel like I've forgotten most of the advanced stuff that I've studied. I know some of you might find this outrageous, but in my case its the truth. Now I want to repent and make up for that mistake by re-learning, but theres just one problem I don't know where to start. List of Topics based on answers to the current question and this Math Classes   1. Discrete mathematics   2. Calculus    3. Elementary Algebra   4. Modular Arithmetic   5. computational number theory


Free cloud web service development

I am looking for a free (as in beer) combination of services, for **learning** "cloud SW development" and very small scale private use (say, a private streamlined web shopping&todo list with simple auth). The combination should include the full set of needed services:   * DVCS service (like github)   * A cloud service to run the backend code   * A suitable data storage service (preferably not SQL), accessed by the backend (if not included in the backend service)   * A web service, serving the web pages seen by user, to access the backend functionality   * A "cloud IDE" (ideally one, two is ok too) for both backend and HTML/javascript coding   * If (backend) deployment uses some CI, then that Other points:   * Backend programming language can be anything, except VB or PHP   * Everything has to be in the cloud, nothing permanent on a local PC (graphics is not part of the question)   * Looking for ready-to-use service combination, not a virtual server where I can set anything up myself   * I don't care if service insists on displaying ads in the user web UI   * "Cheap" and "free trial" are ok too, if "free" does not exist   * As per example use case, storage, CPU and bandwidth quota requirements are negligible Google finds several services of course, all requiring at least registration before testing, so I'm looking for a known-good _combination_ , so ideal answer starts with "I use this service combo: ...", contains links to services and brief description and personal experiences.


Viable method of sharing our PHP project

We are two developers that have no previous experience in sharing one PHP project. In particular, cakePHP. We both use NetBeans and we have set the project up as a "PHP application from a remote server". For the project we also use git + bitbucket for version control as well. Now the problem is that whenever one of us makes any changes to the code and saves it, it gets updated on the server, but not in the other developer's environment. Is this the right path we are taking for sharing the project? How to make the code updates and how to avoid overriding other code?


What should be the workflow with a git repository?

I work on several git repositories though on most not more than 2 people work. Mostly me and my boss. Very often when we work in parallel it happens that "git log" doesn't look so nice because of the merge commits. My boss always complains about that. I really hate that fact because this makes me effectively serialize my work. To prevent these merge commits I must always rebase to the most recent version and go to the other office to make sure that my boss doesn't forget to process the merge requests before committing stuff himself. Even worse he told me that since one week or so he doesn't get email notification for merge request, though I have problems to believe that. Even more worse he now does himself merge request for peer reviewing, elevating the problem more. (The best part is he thinks I always forget to rebase and update on time...) On several occasions I already tried to explain to him that I do everything the way he suggests but he doesn't believe me because he has more experience with git, at least in non-teamwork- environments. I work at this place since 3 months, though I actually do teamwork since a few weeks. I really wished we would use svn because with this workflow in git I waste a lot of my time and I get a headache. In particular we have about 40 repos with modules which are in most cases not longer than 3000 LOC. So when I change something intimate in Repo A I might have to change something in Repo B. If I was deciding, I would put all that stuff into one repo, at least the modules which belong to one group of software. Of course as a new employee you cannot critisize your boss too much or influence him too much. So what is the best way to deal with this problem?


Collection vs data structure vs aggregate

I know three terms that have to do with storing objects or data. I'm not sure I understand the exact differences between the terms. Please confirm if what I'm about to write is accurate. **A data structure** is a group of data types or objects of the same type, grouped together in some formation. **A collection** is the same as a data structure (I don't mean a Java Collection, I mean a collection in the more general meaning). **An aggregate** is an object containing a collection or data structure, providing an interface to communicate with the inner data structure. For example, the object `someContainer`, which contains an inner `ArrayList`, is an aggregate because it contains a data structure, encapsulates it, and provides an interface to manipulate it. Is all of this accurate?


Should we be using git branches or separate repositories?

So I have talked my employer into finally jumping on version control...up until now my experience with git has been for personal projects and freelance work where everything is on one server, or small scripts...so, this is a bit above my knowledge. We are going to have 3 web-servers… test, staging, production. We are going to use beanstalk (like github) which will store our repositories remotely and beanstalk will deploy to our servers via sftp (or ssh or whatever we decide). Inside our htdocs folder we have a drupal multi-site install, and we have a bunch of stuff outside of drupal (landing pages, etc...). We would like to have all of our htdocs (except images, file folders, etc...) inside of version control. Should we use one repository with multiple branches? Or 3 separate repositories, each with one branch since they will be deploying to 3 separate servers?


Storing a looong lookup table

## Background The product i am working on has a _very_ long lookup-table. the table contains static data and cannot be auto generated. there are about 500 rows and 10 columns. columns have mostly integers and strings. to complicate the matters, there are actually two such tables. every row in table-1 maps to zero-or-more rows in table-2. we use an SQLite database with two tables. the product installer places the SQLite file in the installation directory. the application is written in dot- net and we use ADO to load the data once on startup. **now,**   1. the lookup table grows. in each release a month, we add about 10 new entries   2. existing entries are adjusted. every release we fine tune existing entries. ## The problem a team of (10) developers work on the lookup table. Code goes in the SVN, but the little devil the SQLite does not. this prevents multiple developers to work on it. we do take regular backups of the file, but proper versioning is not possible. we never know who did the breaking change. the worse thing is we dont know if there is any change at all. diff'ing databases is tedious if not impossible. the tables are expected to grow quite large in years to come and we would need developers to work in parallel on it. the data is business critical. we need to be able to audit changes made to it. ## Question What would be a solution for the problems outlines above? one idea was to transform the whole thing to XML and treat it like just another source file. that way SVN can do the versioning and we can work in parallel. but the data shows relational behavior. with XML we loose the unique and foreign-key constraints. also we cant query it with sql like ease. any help here will be appreciated.


What should I know moving from a startup to a corporate role?

I recently took a position with a fairly large company. So far, I've worked with small companies (just a few employees) and startups so I've gotten used to a certain style of working. I'm a bit nervous about what to expect and what to prepare for: what should I keep in mind as I transition into a larger corporate workplace?


Shared source file between two parts of project

I have the following sort of directory structure:               part1         build         src     part2         build         src      Now I have a header file that I would like to include in both parts of these projects, it will contain constants and some macro definitions as well as some utility functions, and I want these to be synchronized between the two parts. What would be the generally acceptable way to format my directory structure? Something like so?               part1         build         src     part2         build         src     share         src      and set up my make files in the `build` directories to also look in `../../share/src` Or is there a more "correct" way of doing this?


Should one always know what an API is doing just by looking at the code?

Recently I have been developing my own API and with that invested interest in API design I have been keenly interested how I can improve my API design. One aspect that has come up a couple times is (not by users of my API but in my observing discussion about the topic): _one should know just by looking at the code calling the API what it is doing_. For example see this discussion on GitHub for the discourse repo, it goes something like:               foo.update_pinned(true, true);      Just by looking at the code (without knowing the parameter names, documentation etc.) one cannot guess what it is going to do - what does the 2nd argument mean? The suggested improvement is to have something like:               foo.pin()     foo.unpin()     foo.pin_globally()      And that clears things up (the 2nd arg was whether to pin foo globally, I am guessing), and I agree in this case the later would certainly be an improvement. However I believe there can be instances where methods to set different but logically related state would be better exposed as one method call rather than separate ones, _even though you would not know what it is doing just by looking at the code_. (So you would have to resort to looking at the parameter names and documentation to find out - which personally I would always do no matter what if I am unfamiliar with an API). For example I expose one method `SetVisibility(bool, string, bool)` on a FalconPeer and I acknowledge just looking at the line:               falconPeer.SetVisibility(true, "aerw3", true);      You would have no idea what it is doing. It is setting 3 different values that control the "visibility" of the `falconPeer` in the logical sense: accept join requests, only with password and reply to discovery requests. _Splitting this out into 3 method calls could lead to a user of the API to set one aspect of "visibility" forgetting to set others that I force them to think about by only exposing the one method to set all aspects of "visibility"_. Furthermore when the user wants to change one aspect they almost always will want to change another aspect and can now do so in one call.


Detect a new tweet with any framework or language (desktop or web-based)

I hope this doesnt get perceived as ambiguous or too vague, but i'm attempting to make a service that monitors twitter and archives tweets. Apart from PHP cron jobs i cant think of any way to detect if there has been a new tweet posted? I'm not too fussed about what programming language i have to write it in, or what framework i have to work in. Also whether its desktop or web based. What route would everyone go down for this? Thanks