What data structure should I use for this caching strategy?

I am working on a .NET 4.0 application, that performs a rather expensive calculation on two doubles returning a double. This calculation is performed for each one of several thousand _items_. These calculations are performed in a `Task` on a threadpool thread. Some preliminary tests have shown that the same calculations are performed over and over again, so I would like to cache _n_ results. When the cache is full, I would like to throw out the least- ~~often~~ recently used item. ( **Edit:** I realized least-often doesn't make sense, because when the cache is full and I would replace a result with a newly calculated one, that one would be least often used and immediately replaced the next time a new result is calculated and added to the cache) In order to implement this, I was thinking of using a `Dictionary<Input, double>` (where `Input` would be a mini-class storing the two input double values) to store the inputs and the cached results. However, I would also need to keep track of when a result was used the last time. For this I think I would need a second collection storing the information I would need to remove a result from the dictonary when the cache was getting full. I am concerned that constantly keeping this list sorted would negatively impact performance. Is there a better (i.e. more performant) way to do this, or maybe even a common data structure that I am unaware of? What kinds of things should I be profiling/measuring to determine the optimality of my solution?


Programming knowledge vs. programming logic

Is there any difference between the two topics? I have seen companies asking for _Good Programming knowledge_ some _Good Programming logic_. I have seen this in Job profiles for a developer – for e.g. "good Programming logic", "strong Programming knowledge". I believe that Programming knowledge is related to knowledge about the language in consideration and Programming logic is problem solving logic using programming (in general).   Please correct me if I am wrong. Also what is more important? **Edit:** Do selection of components for application, designing interfaces validating user inputs fall under programming knowledge or Programming logic?   Does programming logic simply imply problem solving, or is there anything else which it should comprise of?


What is the best way to maintain software tool chains?

**Short Question**   What is the best way to create, maintain, and distribute software development tool chains? **Background**   I am trying to develop a workflow / process to create an isolated environment in install and deploy software tool chains for embedded targets. Each tool chain typically would contain an IDE, compiler, and a small set of common tools. I have looked into two solutions but the both have their limitations and I hope to find a solution that has the best of both implementations. The rational behind a stand alone tool chain is so that all developers would be able to build the exact same code (matching CRC etc..). As well as be able to rebuild the same code after X number of years to support legacy code. A third option would be to use a central build server, which we plan on doing for nightly builds, but we still need to be able to build 'on the fly' when working on a test bench or remotely. So only using a build server will not suffice. **Ideal Goals for Deployed tool chain**   * Work on Windows XP, Vista, and 7 (excluding drivers)    * Contain all required information to run use the tool chain (excluding drivers)  **\------------------ Possible Options ------------------** **Option 1: Full Stand alone Virtual Machine**   _Pros_   * Open Source packaging via Virtual Box   * 100% isolation    * Guarantees the tools can interact with one another  _Cons_   * Licensing multiple copies of windows   * At best only one developer could **legally** use a Windows VM at a time.    * Running the same VM on **physically** different lap tops (Macbook Pro, Dell 830, Dell E6500, etc...). Typically when Windows see's a new CPU or motherboard it will force a re-activation.    * _Very_ large files to maintain **Option 2: Virtualized Application**   _Pros_   * Through packagers like Cameyo, applications can run on nearly all versions of Windows. (Note that Cameyo is also free)   * Little to no licensing issues for most tools / IDEs. Purchased compilers might have additional restrictions, all of our current compilers do support this type of usage.    * Smaller files to maintain via a SCM, such as SVN or GIT.  _Cons_   * Difficult, if even possible, to get a single file that contains the entire tool chain    * Difficult, if even possible, to get the tools to see / work with one another. I have seen this very issue with Cameyo.  **Closing Thoughts**   There may not be a solution that meets all of my design goals, but I would like to find out if anyone else been successful in this type of deployment.


Is it better to team up with a designer, or to piece out design work to a contractor?

I am clueless when it comes to design but I am proficient in programming. If you are a programmer who lacks visual design skills, what has worked best for you -- to pair up with a graphic designer or to do all the programming and then piece out specific work? I have done some piecing out of work but I am not completely satisfied because I see too much of my influence come out in the design. I guess this happens since I have to be explicit in what I want with contractors, and they are limited in creativity by the architecture I have created. It feels like having a partner would allow for greater collaboration, but I have read plenty of entrepreneur books that warn against partnerships.


Favoring Immutability in Database Design

One of the items in Joshua Bloch's Effective Java is the notion that classes should allow mutation of instances as little as possible, and preferably not at all. Oftentimes, the data of an object is persisted to a database of some form. This has led me to thinking about the idea of immutability within a database, especially for those tables that represent a single entity within a larger system. Something I have been experimenting with recently is the idea of trying to minimize the updates I do to table rows representing these objects, and trying to perform inserts instead as much as I can. A concrete example of something I was experimenting with recently. If I know I might append a record with additional data later on, I'll create another table to represent that, sort of like the following two table definitions:               create table myObj (id integer, ...other_data... not null);     create table myObjSuppliment (id integer, myObjId integer, ...more_data... not null);      It is hopefully obvious that these names are not verbatim, but just to demonstrate the idea. Is this a reasonable approach to data persistence modeling? Is it worth trying to limit updates performed on a table, especially for filling in nulls for data that might not exist when the record is originally created? Are there times when an approach like this might cause severe pain later on?


What is the value of the Cloudera Hadoop Certification for people new to the IT industry?

I am a software developer with 8 months of experience in the IT industry, currently working on the development of tools for BIG DATA analytics. I have learned Hadoop basics on my own and I am pretty comfortable with writing MapReduce Jobs, PIG, HIVE, Flume and other related projects. I am thinking of taking the exam for the Cloudera Hadoop Certification. Will this certification add value, considering that I have less than 1 year of experience? Many of the jobs I've seen relating to Hadoop require at least 3 years of experience. Should I invest more time in learning Hadoop and improving my skills to take this certification?


Is all industry experience equal (for the most part)?

I graduated not too long ago with a degree in computer science. I've been working for a software company for a couple of months, but the work that I'm doing doesn't seem to fall into any defined category (at least the categories that exist in my mind - developer, tester, project manager). My job will occasionally require me to do a bug fix in Java (5%), but the majority of it seems to consist of either querying a client's database and adding/editing/deleting information (60%), or troubleshooting and then giving the response, "You forgot to do such and such before you submitted the form, and that's why you got an error" (35%). My worry is that down the road if I try and apply to some other company for a more senior developer/tester/PM position, they'll look at my work experience and say, "You seemed to have dealt more with database management / technical support than the actual software development cycle". Is this a valid concern on my part? **EDIT** Since the consensus seems to be that it's low-end/support, I have another question. I've been here a relatively short amount of time, and I've had offers for interviews at a couple of other companies (residual contacts from posting my resume online) where I would be doing development (which is what I'd prefer to be doing). I took this position because they were the first to make an offer (the pay is pretty decent) and I'm hoping to go to graduate school in the next year or so, so I wanted to start saving money. Would it be worth it to pursue these other interview offers (who are going off my resume of me coming straight from university), and just act like these last couple of months didn't happen (resume wise).


Is testable code actually more stable?

A google scholar search turns up numerous papers on testability, including models for computing testability, recommendations for how ones code can be more testable, etc. They all come with the assertion that more testable code is more stable, however I can't find any studies which actually demonstrate this. I tried looking for studies evaluating the effect of testable code vs. quality, however the closest I can find is Improving the Testability of Object Oriented Systems, which discusses the relationship between design flaws and testability. Is testable code is actually more stable? And more importantly, how strong is this relationship? Please back up your answers with references or evidence to back up your claim. For example, there is a lot of study regarding the relationship of cyclomatic complexity and defect rate. Troster finds a correlation of `r = .48` There are metrics for "testability", such as code coupling. I'm looking for research conclusions relating these to defect rate. Ideally I would love a graph plotting some measure of testability vs. defect rate.


How to provide a solid explanation that no two software should have same version number?

We are an outsourcing company. We develop firmware and software for our client. They have a hardware engineer team with whom we, firmware developers, work. Our client has a **strictly defined process** to release a firmware. A change in firmware version number has a big impact in that process. When we release a firmware to them for testing, the hardware engineers test it first. Then another SQA test it. Finally, the product is released to customers. Sometimes, when the change is minor in a new release, our client insist to keep the version number same as the last one. Say, latest release from developers (not released to the customers) had version number 10. Then we found a place for optimization. Or may be slightly change in behavior of the firmware in a very special case which may or may not be visible from outside. When we propose them that we found these places for minor improvements, they insist us to do the changes but keep the version number 10. We insist that every firmware we release must have distinct version number. We pointed out several common pitfalls if we don't change the firmware version number with every release. They say that they understand why it is necessary. Yet they force us to keep the version number same. Keeping the version number same will help their **strictly defined process** of releasing firmware to customer end. We manage the code in our own repository (SVN). We strictly tie a given version number to a given revision number. The version number is stored in the EEPROM of the product our client release. There is defined 2 bytes where the version number is stored. The PC software that reads version number always reads the 2 bytes and display the version number in PC monitor. There is no other way to define version number. They won't change the software that read version number and they won't allocate more memory to introduce another version number that developers can only use. I'm about to change a firmware and release with the modifications today. I've got another request to keep version number same as previous one. I want to email several unbeatable arguments again what problems we might face if we keep the version number same as previous release. How can I convince my client not to use same version number?


How do I find which line connected two squares?

In the Permissive Field of View algorithm, a destination square is _visible_ from a source square if any unobstructed line can be drawn from the source square to the destination square. The algorithm works by defining a series of view fields (essentially, triangles) and checking if the destination square exists inside of a view field. Unfortunately, the algorithm does not make available the actual line that it found between the source square and the destination square; it only tells you whether such a line is guaranteed to exist. How can I find the line, presuming it is guaranteed to exist? I've tried plotting lines between the edges of the source square to the edges of the destination square, but this apparently is just an approximation (it can fail to find the line).


Multi sourced search in WPF app

If I’m using the MVVM pattern – this one for my WPF application And my project requires a search function on different sources – say clients, accountants, cases. What would be the best way to go about it so that I only have one search view and the search results shown in the ListView are ‘dynamic’ in that they could be result for clients or accountants or cases Should I have a base search view model and specific view models for clients, accountants, cases that then somehow set as the datacontext for the search view Or try to build the grid dynamically in a code behind for the search and then somehow get the data back into the view model without the search view knowing about the view model. **For clarification** The searches are separate and will not need to be combined, I would only every return results for clients or accountants or cases.


Customer wants to modify the .properties files packaged in our WAR file

I have a customer who wants the ability to modify the .properties files packaged in the web applications WAR file so that they have the control to modify environments at settings. They will be hosting this site on their own servers so I can't say I blame them but I am a little unsure what the best course is. I would think that any adminstrator of a Java EE application server should know how to drill into the WAR package with a zip tool and find and modify the properties files themselves. I am unsure if this is common knowledge or not. I have typically always packaged my build artifacts with the property files appropriate for a given environment, but this is kind of an oddball case where WE build the WAR and hand it off to the customer. I might try to keep the property files external from the WAR but then it gets messy because of classloader issues (JBoss classloader, Tomcat classloader, etc...) I am thinking that as a convenience we maintain properties files for THEIR environments and change and build these on their requests. My manager likes this idea because it keeps us in control but the customer doesn't like this. What would you do?


Translate soap input of one web service into input of another

We need to support a legacy web service using a new web service implementation. At a given time the old input as well as new input should work. So here is what we need to achieve > Old SOAP input -> translate -> New SOAP input -> New WS -> New WS output -> > translate -> Old SOAP output. For now, I have created xslt for translating input and output But looks like that has little use if I implement a webservice to handle old input Given that we know the input and output XSD for all formats involved, how to implement a web service that will take old soap input, translate it (using XSLT) and call the new service? What tools (spring ws,cxf ..) are most suited?


Will they release a Wrox Box 4?

does anyone know if there will be a Wrox Box 4? I would love to get something like that, but the latest collection of Wrox books seems to be the release for 3.5. I really need to get up to date with the latest version of .NET. I'm not sure if there will be a Wrox Box 4 though, because it looks like Wiley is now publishing Wrox books under Wiley, and not Wrox anymore. So it looks like I'm going to have to go with Professional ASP.NET 4 in C# Instead of the Wrox Box 3.5


Anyone using Intel Performance Primitives library (IPP) with Delphi?

I'm considering purchasing the Intel Integrated Performance Primitives (IPP) library for use with my Delphi applications. I'm interested in the signal processing functions. Mainly for re-sampling and FFT. Has anyone used IPP with Delphi? How did it go? I'm wondering how easy it will be to begin using the library. I don't have any experience using non-Delphi code/libraries with Delphi.


How do open source projects deal with complex setup and deployment?

At most of my corporate clients they have very complex systems with multiple entities to be deployed and tested. (e.g. client software, user database, system, database, identity manager application, etc). They usually don't have an easy way to deploy all this. Neither in production nor for development. I wonder how open source projects/applications deal with this? Do open source projects tend to be smaller in scope therefore less complex to setup? Do they manage to avoid complexity as no-one pays for their time wasted in setup? I wonder what complex open source projects are there in terms of complexity. I thought about a couple of examples. Neither of them perfect for my purpose. **Wordpress** \- The .com site is probably quite complex in terms of deployment but AFAIK the version that can be downloaded from .org is quite simple. It cannot be distributed to multiple servers. **Wikipedia** ? Most of the software it is using is open source but it is not itself a downloadable open source project so it does not really fit. Details of their system can be found on Wikipedia **Diaspora** \- the Facebook replacement is not working yet but it might become such project. **Dreamwidth** is originally a LiveJournal fork. Dreamwidth is mostly open source. Its wiki page has information with some production notes. I got some input from them in IRC that I posted on their forum to get further clarifications. So I am interested in further examples of open source applications/system that are complex in terms of deployment and testing.


Performance considerations when using Go for my project

I'm looking at using Go (aka golang) for a project (a SQL database, but that mostly doesn't matter here) where performance is critical, but under low load the primary bottleneck will be I/O to disk. In this case, I think Go would be great! Under high load or while hitting cache a lot, CPU and memory utilization will increasingly become bottlenecks, and I'm worried that Go could make the high- end of the performance spectrum significantly lower than what C/C++/D might provide. Can anyone with experience working in Go give some insight into how quickly that bottleneck is reached (networking applications are subject to the same bottleneck, typically) and what you can do to relax it in Go other than rewriting the bottleneck in a faster language? * * * Note my question was sufficiently different that I asked it anyway after reading related question:   * What kind of software is done best with The Go Programming language? I have a specific application I'm asking about, and I've limited my concerns to performance (not usability, library support, development tools, etc).


Why doesn't Java's BigInteger class have a constructor capable of taking a numeric literal? Every single time I use BigIntegers, and many times I merely think about them, I wonder this. What reason could the designers of java have had to exclude one despite the overwhelming convenience of one should it exist?


Does 'Me' in VB.NET refer to the instantiated object only?

Does 'Me' in VB.NET refer only to an instantiation of the type? Just occurred to me that since I can reference properties in my VB.NET class without using 'Me', that I don't see a reason for using it for this purpose. Will referencing the variable either way always refer to the actual stored value for the property at runtime?


How get and set accessors work

The standard method of implementing get and set accessors in C# and VB.NET is to use a public property to set and retrieve the value of a corresponding private variable. Am I right in saying that this has no effect of different instances of a variable? By this I mean, if there are different instantiations of an object, then those instances and their properties are completely independent right? So I think my understanding is correct that setting a private variable is just a construct to be able to implement the get and set pattern? Never been 100% sure about this.


Are elements returned by Linq-to-Entities query streamed from the DB one at the time or are they retrieved all at once?

Are elements returned by Linq-to-Entities query streamed from the database one at the time ( as they are requested ) or are they retrieved all at once:                   SampleContext context = new SampleContext(); // SampleContext derives from ObjectContext         var search = context.Contacts;              foreach (var contact in search)         {            Console.WriteLine(contact.ContactID); // is each Contact retrieved from the DB                                                   // only when foreach requests it?         }      thank you in advance


Relation between objects

For a few weeks I’ve been thinking about relation between objects – not especially OOP’s objects. For instance in **C++** , we’re used to representing that by layering pointers or container of pointers in the structure that needs an access to the other object. If an object `A` needs to have an access to `B`, it’s not uncommon to find a `B *pB` in `A`. But I’m not a **C++** programmer anymore, I write programs using functional languages, and more especially in **Haskell** , which is a pure functional language. It’s possible to use pointers, references or that kind of stuff, but I feel strange with that, like “doing it the non-Haskell way”. Then I thought a bit deeper about all that relation stuff and came to the point: > _“Why do we even represent such relation by layering?_ I read some folks already thought about that (here). In my point of view, representing relations through explicit graphes is way better since it enables us to focus on the _core_ of our type, and express relations later through combinators (a bit like **SQL** does). By _core_ I mean that when we define `A`, we expect to define what `A` is _made of_ , not what it _depends on_. For instance, in a video game, if we have a type `Character`, it’s legit to talk about `Trait`, `Skill` or that kind of stuff, but is it if we talk about `Weapon` or `Items`? I’m not so sure anymore. Then:               data Character = {         chSkills :: [Skill]       , chTraits :: [Traits]       , chName   :: String       , chWeapon :: IORef Weapon -- or STRef, or whatever       , chItems  :: IORef [Item] -- ditto       }      sounds really wrong in term of design to me. I’d rather prefer something like:               data Character = {         chSkills :: [Skill]       , chTraits :: [Traits]       , chName   :: String       }          -- link our character to a Weapon using a Graph Character Weapon     -- link our character to Items using a Graph Character [Item] or that kind of stuff      Furthermore, when a day comes to add new features, we can just create new types, new graphs and link. In the first design, we’d have to break the `Character` type, or use some kind of work around to extend it. What do you think about that idea? What do you think is best to deal with that kind of issues in **Haskell** , a pure functional language?


What are the common approaches & practices for big applications?

Developing big applications requires huge effort. There may be teams for each phase of development and they must use different design patterns and go through the whole SDLC. I have two years of experience as a software developer on small applications and I'm interested on what are the common approaches & practices for big applications? Especially from a project management perspective. How can I adopt such working practices?


Is there a such thing as a Program Manager for Outsourcing Companies?

Accordingly to the first paragraph of Joel's post, a Program Manager is a very good thing to have in products. But what about having a Program Manager for a company that doesn't have a product, but have projects? The only coincidence that I'd see if you ask me and ask me to answer right away is that a Program Manager for an outsourcing company would be someone that oversees all the projects that the company have, ensuring that the things are being done aligned to the company strategy, from a technical point of view.


Independent Developer Pre-Coding Planning/Design/Architecture

For the independent developers, or the weeknight/weekend developers, when you are about to begin a large/enterprise project, what are you first steps to take when hashing out the pre-coding details and designs? What are the tools you use? Do you find it easiest to keep with the traditional mechanical pencil and pad of paper? Do you use a text editor to get your ideas and requirements in a bulleted format? Do you use UML? What my question is, is what's the first step you take when designing a large application? What medium do you use to record your notes? And when are you typically content to start writing code?


How to write useful Java programs without using mutable variables

I was reading an article about functional programming where the writer states > >     (take 25 (squares-of (integers))) >   > > Notice that it has no variables. Indeed, it has nothing more than three > functions and one constant. Try writing the squares of integers in Java > without using a variable. Oh, there’s probably a way to do it, but it > certainly isn’t natural, and it wouldn’t read as nicely as my program above. Is it possible to achieve this in Java? Supposing you are required to print the squares of first 15 integers, could you write a for or while loop without using variables? > **Mod notice** > > This question is _not_ a code golf contest. We are looking for answers that > explain the concepts involved (ideally without repeating earlier answers), > and not just for yet another piece of code.


Would using Quercus make my code fall under the GPL?

Quercus is an implementation of PHP written in Java, and released under the GPL. If I use it, does my PHP code fall under the GPL? What about my Java code? Assuming I write new Java code, and new PHP code, and use Quercus to run my PHP code on the JVM and call into my Java code, which pieces fall under the GPL? Also, assume that the result is commercial software that I want to distribute.


What do you think was a poor design choice in Java?

Java has been one of the most (the most?) popular programming languages till this day, but this also brought controversy as well. A lot of people now like to bash Java simply because "it's slow", or simply because it's not language X, for example. My question isn't related to any of these arguments at all, I simply want to know what you consider a design flaw, or a poor design choice in Java, and how it might be improved from your point of view. Something like this.


Obstacles to using Git Flow in Subversion

My team at work is starting a new project, using Subversion as our VCS (you may consider this set in stone for the purpose of this question). We're still in the early stages of the project and are trying to agree on a branching model. Our previous project was based on a non-standard version model that led to issues when managing hot-fixes and patches to existing releases. I've found different branching models to be rather complicated, but one model that I do understand fairly clearly is git flow. I'm curious how hard/undesirable it would be to implement a variation of this in Subversion. Obviously there would some difference in terms of people collaborating on branches. The feature branches would have to be centralized rather than limited to local repositories, but the other concepts of the model should be reproducable in Subversion as I understand it. What would be the drawbacks or challenges to this approach. What I've heard is that in SVN "merging is expensive" relative to Git. But I'm not completely clear on what this means in practice or how it would effect our ability to use a git flow like branching model. What would be the biggest concerns with this approach. Is there a similarly clear approach that is more natural in Subversion?


What is a practical level of abstraction in a web application?

(Originally asked on StackOverflow - http://stackoverflow.com/questions/14896121/what-is-a-practical-level-of- abstraction-in-a-web-application) I still consider myself a newcomer to OO programming, especially in php, so forgive me if I have missed some fundamental principle! Say I have an intranet application with a `staff` object with properties and methods unique to being a member of staff:               class staff {         ...         private $job_title;         private $start_date;         etc...     }      In the quest to keep the maintainable parts of my code in one place, make my data model more intelligent and make my code less tightly-coupled, is it reasonable to abstract each object property to another level? For example, I expect each property to have a `value`, but to complicate matters, I'm also interested in what `label` and `description` to use when referring to it in human-readable applications. More of interest is which `type` it is, as well as the capability of the object to validate itself, if its member properties can validate themselves also. It seems then, that properties of the majority of objects have a lot in common. So, the `$start_date` property might actually be an object in itself:               abstract class property {         public $value = NULL;         protected $label; // A simple label which can be used on user forms, reports, etc.         protected $description; // Some detail to describe what this property is used for         protected $type; // Helps choose the right HTML form control and validate user input         protected $regex; // Regular expression to prompt user entry and validate return value         protected $unique = FALSE; // If TRUE, check for duplicates in the persistence layer         protected $default_value; // Prompt the user when entering new values         protected $HTML_form_element; // Which form element suits this field best?         etc....     }          class start_date extends property {         ...         public function __construct(){             ...             $this->label = 'Start date'; // Might be an i18n entry             $this->description = 'Enter the date on which the contract starts for this staff member'; // Might be an i18n entry             $this->type = 'VARCHAR(512)'; // Better to use persistence layer's requirements?             $this->regex = '/^([0-9]{1,2})[/.-]([0-9]{1,2})[/.-]([0-9]{2,4})$/'; // UK date             $this->default_value = date('Y-m-d'); // Depends on the business policy of the company             $this->HTML_form_element= 'datepicker'; // Chooses the correct HTML element when building forms automatically             ...         }         etc...     }          class staff {         ...         public function __construct(){             ...             $start_date = new start_date();             ...         }         etc...     }      In previous applications, these related things have lived in different places; random global variables, commented code, decorator objects, a config file, embeded in HTML, a database table, a scrap of paper. It makes sense to bring all an objects properties together in one place, but is this the right way?


How to extract operators from the grammar productions for conflict resolution in LALR parser?

Is there some standardized or widely accepted algorithm for picking up operators in shift/reduce conflicts in LALR parser? The question is naive, my problem is not with implementing my solution, but implementing the solution is already widely used. For shift the operator is the next input token, for reduce, it depends -- I consider all already read symbols (for given production) declared as operators:   * if there is one -- it is the operator   * if there are more than one -- I report grammar error   * if there is none I use the input token as operator So for example:               E ::= E + E     E ::= E * E     E ::= num      in case of               E + E | * num      Considering first production I read `+`, and since it is the only one operator read I pick this one for reduce operator. `*` is the first token in input so it servers as shift operator. But is my algorithm correct (i.e. the same as normally used for LALR parsers)? I am especially worried for the point when I have more than 1 operator in the read tokens. * * * ## Update What I **NOT** am asking here I don't ask how to resolve shift/reduce conflict once you have the operators. I don't ask how to set the precedence for operators. What I **am** asking here I ask how to extract operators from the "stream" of tokens. Let's say user set some precedence rules for `+`, `-` and `*`. The stack is: `-` `E` `+` `E` and input is `E`. Or the stack is `E` and input is `*`. What is the operator for reduce in first case? And in the second? Why? _The stack is really entire right hand side of production._


Custom error handling

I'm trying to figure out the best way to handle custom errors in my application. Option 1:               if(expr) {     } else {         $_SESSION['error'] = "Some message describing the error";     }      Option 2:               if(expr) {     } else {         $_SESSION['error'] = 2;     }      In option 1, the same error might be recycled in multiple situations. If I ever decide to change the message then I'll have to dig through my code and find every occurrence. In option 2, I give a numerical value which could reference a master list of errors. This seems to solve the problem associated with option 1 but makes the code harder to read. What should I do?


C++ name mangling and linker symbol resolution

The name mangling schemes of C++ compilers vary, but they are documented publicly. Why aren't linkers made to decode a mangled symbol from an object file and attempt to find a mangled version via any of the mangling conventions across the other object files/static libraries? If linkers could do this, wouldn't it help alleviate the problem with C++ libraries that they have to be re-compiled by each compiler to have symbols that can be resolved? List of mangling documentations I found:   * MSVC++ mangling conventions   * GCC un-mangler   * MSVC++ un-mangling function documentation   * LLVM mangle class


Issue with My.Settings using Visual Basic

For my A2 Computing project I have created a game using Visual Basic. For the leaderboard section, I have used the My.Settings feature to store the scores when the game closes, but only one or two actually save. My teacher doesn't know and I can't find anything helpful after a google search of the problem


How to camel-case where consecutive words have numbers?

Just wondering if anybody has a good convention to follow in this corner- corner-corner case. I really use Java but figured the C# folks might have some good insight too. Say I am trying to name a class where two consecutive words in the class name are numeric (note that the same question could asked about identifier names). Can't get a great example, but think of something like "IEEE 802 16 bit value". Combining consecutive acronyms is doable if you accept classnames such as `HttpUrlConnection`. But it seriously makes me throw up a little to think of naming the class `IEEE80216BitValue`. If I had to pick, I'd say that's even worse than `IEEE802_16BitValue` which looks like a bad mistake. For small numbers, I'd consider `IEEE802SixteenBitValue` but that doesn't scale that well. Anyone out there have a convention? Seems like Microsoft's naming guidelines are the only ones that describe acronym naming in enough detail to get the job done, but nobody has addressed numbers in classnames.


Modern analog of DDD (Data Display Debugger)

I if there are visual applications for debugging code in popular languages (like C, Pytho, Javascript). By visual I do not mean debugger with UI which is bundled with almost every IDE, I'm rather talking about a debugger that can visualize data and process of changing this data over time. E.g. imagine you're implementing a sort algorithm. It would be very cool to have an application that would save states of the array at each iteration and then would allow you easily go back and forth between states with good animation of insertion/deletion and move. I understand that there maybe no general utility for that. Insetead I expect some environment (like R or MatLab) that can be used to easily create such debugging applications.


Looking for feedback on my approach to implement an algorithm

We've recently worked with a mathematician to build us an algorithm. The algorithm will look at click data and will continuously update data associated with the user, the content, and the content's category and then pair the user with relevant content. With that said, I have never implemented an algorithm before but I'm guessing that our current environment (PHP, MySQL) is not entirely suitable for continuously crunching and updating data. **Looking for feedback on whether the following approach is on the right track?**   * Write algorithm in Java (or other compiled language) for best performance.   * Store user, content, and category data on a NoSQL server (or use memcache).   * Use Gearman (or equivalent) to submit click/user data to a job server.   * Run jobs on separate worker server that contains the algorithm.   * Update user, content, category data. If this is not on the right track, can you explain why would that be?


How does java resolve class names in a lot of jars?

Recently I found one of my Maven project have 100+ jar dependencies. FWIK a zip archive doesn't have index at all, so it should scan the whole zip to determine if it contains a specific path. But I found Java resolve class names against so many jars rather fast, why?


What would be a good set of first programming problems that would help a non-CS graduate to learn programming?

I'm looking at helping a friend learn programming (I'm NOT asking about the ideal first language to learn programming in). She's had a predominantly mathematical background (majoring in Maths for both her undergrads and graduate degree), and has had some rudimentary exposure to programming before (in the form of Matlab simulations/matrix operations in C etc) - but has never been required to design/execute complex projects. She is primarily interested in learning C/C++ - so, with respect to her background, what would be a set of suitable problems that would both engage her interest ?


Convert filenames to their checksum before saving to prevent duplicates. Is is a smart thing to do?

TL;DR:what the title says * * * I am developing some sort of image board in PHP. I was thinking of changing each image's filename to it's checksum prior to saving it. This way, I might be able to prevent duplicates.   I know this wouldn't work for two images that are the same but differ in size or level of compression or whatnot, but this method would allow for an early check.   What bugs me is that I never saw this method implemented anywhere, so I was wondering if there is a catch to it. Maybe it is just more efficient to keep the original filename and store the hash in DB? Maybe the whole method is just not useful and my question is moot?   What do you think? On a side note, I don't really get how hashes are calculated so I was wondering, **if** my first question checks out, if it would be possible to calculate the likeness that two images are similar by comparing hashes (levenshtein or something of the sort).


Why is Today() an example of an impure function?

It seems like, when reading something like this Wikipedia article about "pure functions", they list `Today()` as an example of an impure function but it seems pretty pure to me. Is it because there is no formal input argument? Why is the actual time of day not treated as the "input to the function" in which case if you gave it the same input, i.e. executed `today()` twice at the same time, or traveled back in time to execute it again (maybe a hypothetical :) ), the output would be the same time. `Today()` never gives you a random number. it always gives you the time of day. The Wikipedia article says "different times it will yield different results" but that's like saying for different `x` `sin(x)` will give you different ratios. And `sin(x)` is their example of a pure function.


Embedded Web Server Vs External Web Server

So I've thought of creating a web application in either Lisp or another functional language and was thinking of embedding the web server into the application (have my application handle the HTTP requests). I don't see any issues with that, however, I'm new to creating web applications (and in the grand scheme of things, programming as well). Is there any drawbacks to handling HTTP requests within your program instead of using a web server? Are there any benefits?


How to make an ASP.NET MVC site modular

I'm in the planning stage for an employee intranet system to be built with ASP.NET MVC 4. We'd like the site to consist of separate "modules", each of which provides a different feature: messaging, payroll changes, etc. I'd like these modules to be able to be enabled or disabled at compile time. The homepage will display some kind of navigation that will link to each module that is loaded. That's easy so far, but I don't want the navigation feature to have to know about the modules beforehand. In other words, I want the modules to be dynamically discoverable; I want to be able to write the code for a new module and then have a link added to the navigation bar with no code changes anywhere else in the source. Each module should have some way of registering itself with the navigation bar, and--more importantly--this should be done for each module as it's loaded. I believe that this precludes using MVC's Areas, since those are designed for the case when the layout of the site is known beforehand. MEF seems like it might be appropriate, although people seem to have had mixed success in combining MEF with MVC. Is MEF actually the way to go here, or is there a better way to accomplish what I need?


How to handle Real Time Data from a database perspective?

I have an idea in mind, but **it still confuses me the database area**. Imagine that **I want to show real time data** , and using one of the latest browser technologies ( _web sockets_ \- even using older browsers) it is very easy to show to all observables (user browser) what everyone is doing. **Remy Sharp** has an example about the simplicity about this. But I still don't get the database part, **how would I feed** , let's imagine (using Remy game Tron) that I want to save **the path for each connected user** in a database and if a client wants to see what is going on with a **5 sec delay** , he will see that, not only the 5 sec until that moment but **the continuation in time** ... how can I query a DB like that?               SELECT x, y FROM run WHERE time >= DATEADD(second, -5, rundate);      is not the recommended path right? and pulling this x in x time ... this is not real data feed correct? If can someone help me understand the Database point of view, I would greatly appreciate.


Is It Common For a Company to Have Their Own Definition of Job Titles such as Software Architect

Recently I am very confused about my position in the company. Months ago, this company offered me the position of Software Architect and I accepted. But about one year passed and I came to realize that this "Software Architect" title in this company is almost totally different from the one I used to know and the one I see people discussing here. Below are several items what a software architect is responsible for. They are from This Post:                  A Systems Architect should:        1. Specify the high-level architecture        2. Participate in code reviews        3. Approve technologies used        4. Assist the developers in their coding effort        5. Maintain and monitor the development schedule        6. Produce SA artifacts, such as UML diagrams, Gantt charts and the like.      But as a "Software Architect" in this company, I can only touch the 6th Item together with a lot of coding. So this title in my company is more like a Senior Developer rather than a Software Architect. My questions are:   1\. Is it common for a company in IT industry to have their own definition of Job Titles?   2\. If the answer to question 1 is No, then is it legal for a company to do that? **Update**   The reason why this issue became a problem recently is that, our General Manager seems to want me to be responsible for a project which is being developing by many members, but he **never** authorizes me to lead other team members or coordinate between teams (coordination among teams is a must especially when are developing software suites). Instead, he just came to me and blame me when the project didn't get progressed as expected. Though I designed all the interfaces and classes of some modules for other members to work and did lots of coding, pushing and guaranteeing the progress is beyond my responsibility especially when this Software Architect is not the usual one we see, I feel it is so unfair to me！


Is PHP "list()" language construct a bad convention?

PHP supports the `list()` language construct which, in short, allows you to return multiple values from a function and then attach them to different variable, eg:               function myBigReturn(){         return array("foo", "bar");     }     list($fooer, $barer) = myBigReturn();     echo $fooer; // echoes "foo"     echo $barer; // echoes "bar"      I have failed to find much info about such a language construct and I am curious - is usage of PHP `list()` construct considered a bad coding convention? Are there any serious articles/literature on this subject?


wpf and mvvm printing report startegy

I am developing a WPF application and I need some clarity on printing in WPF and MVVM (I am using MVVM-Light). I want to create standard looking reports for my application and I don't want to have to code each one from scratch. But I want to write this solution myself, without stuff like crystal reports etc. But I am open to other open source examples of course. 90% of my reports will be generated from datagrid itemsources. I want to have a report footer and header and then the "records" that get paged in a content section. **My idea is:** use Fixed document as report wrapper (with header and footer properties), use a listview for records in report content, and generate report to xps that gets opened in document viewer for user to review and print etc. But I have never created reports from WPF before and it looks like there are lots of options and no clear best practice. I am looking for some suggestions or advice on which direction to go from someone with some experience creating custom reports in WPF and keeping MVVM. What was you strategy?


Is there a pattern that will help with this data structure

I'm doing a java project. My main structure contains 2 lists with elements of type A the other type B. B itself contains a list of objects which may contain elements of A. It must be that when an element from list of A is removed it must be removed from all subelements in list B. also if an possible member of list A is added to a B it should also be added to A. And also I need some way to find the parent objects containing an A. So far I have a "working" implementation - using lots of loops. I am wondering - can you suggest patterns that will help me in this task? * * * more details. I think my main issue is boils down to that i have objects A that have multiple parents. And when I add/remove from one parent I need to adjust some other parents. I can't help but believe such a problem is solved already. * * * to clarify: I have a main `List<A>` , and each `B` contains a `List<A>` When a A is removed from the main list it must be removed from all B. But not when it is removed from a B. It's essential that all A used in the application are present in the main list.


What are the best resources for learning about concurrency and multi-threaded applications?

I realised I have a massive knowledge gap when it comes to multi-threaded applications and concurrent programming. I've covered some basics in the past, but most of it seems to be gone from my mind, and it is definitely a field that I want, and need, to be more knowledgeable about. What are the best resources for learning about building concurrent applications? I'm a very practical oriented person, so if said book contains concrete examples the better, but I'm open to suggestions. I personally prefer to work in pseudocode or C++, and a slant toward game development would be best, but not required.


what is the difference between Soak testing and Stress testing?

Can anybody explain the difference about soak and stress testing? I googled about them and found that both are about to test the software beyond its limits. Is it right for both testing strategies?


how should I design Objects around this business requirement?

This is the business requirement: " A Holiday Package (e.g. New York NY Holiday Package) can be offered in different ways based on the Origin city:   * From New Delhi to NY   * **From Bombay to NY**   * NY itself ( Land package ) (Bold implies default selection) **a.** and **b.** User can fly from either New Delhi or Bombay to NY.   **c.** NY is a Land package, where a user can reach NY by himself and is a standalone holidayPackage. " Let's say I have a class that represents **HolidayPackage** , **Destination** (aka City).               public class HolidayPackage{         Destination holidayCity;         ArrayList<BaseHolidayPackageVariant> variants;         BaseHolidayPackageVariant defaultVariant;     }          public abstract class BaseHolidayPackageVariant {         private Integer variantId;         private HolidayPackage holidayPackage;         private String holidayPackageType;     }          public class LandHolidayPackageVariant extends BaseHolidayPackageVariant{     }          public class FlightHolidayPackageVariant extends BaseHolidayPackageVariant{         private Destination originCity;     }      What data structure/objects should I design to support:   * options   * a default within those options Sidenote: A HolidayPackage can also be offered in different ways based on Hotel selections. I'd like to follow a design which I can leverage to support that use case in the future. This is the backend design I have in mind.


Training a company to use a DVCS coming from a CVCS mindset, is it as hard as one would think?

So, I'm preparing to consider the outcome of training a lot of people (>25) to use **Mercurial** coming from a centralized mindset. I've done it with **individuals** and had success with it, although the time invested in each one has been different and most of them have been both proactive and open to trying something new. I was wondering if there was someone here with experience giving such training to a large group of people **as I would like to find out what are the do's and don'ts... of course, this would be more oriented towards dealing with those resistant to change** , and a don't I can come to think of is telling them to avoid cheat-sheets mapping commands, as Joel Spolsky suggests.


Why is it so difficult to make C less prone to buffer overflows?

I'm doing a course in college, where one of the labs is to perform buffer overflow exploits on code they give us. This ranges from simple exploits like changing the return address for a function on a stack to return to a different function, all the way up to code that changes a programs register/memory state but then returns to the function that you called, meaning that the function you called is completely oblivious to the exploit. I did some research into this, and these kinds of exploits are used pretty much everywhere even now, in things like running homebrew on the Wii, and the untethered jailbreak for iOS 4.3.1 My question is why is this problem so difficult to fix? It's obvious this is one major exploit used to hack hundreds of things, but seems like it would be pretty easy to fix by simply truncating any input past the allowed length, and simply sanitizing all input that you take. **EDIT: Another perspective that I'd like answers to consider - why do the creators of C not fix these issues by reimplementing the libraries?**


Suggestions to improve small team workflow (CI / Deployment)

I'd like to improve my team's workflow and architecture. Right now we have a LAMP dev server on which every member of the team has a subdirectory. We work directly in this directory via LAN. There is also a "release" directory for when we're ready to upload via FTP to the production server. We use a github private repo that serves as a centralized repo. Example of a programmer's current daily workflow : Choose a user story to work on after a quick daily meeting Open a git branch named after the user story Work, commit some changes Push to github When I decide to deploy, I pull the changes, perform a code review, change the needed variables for production and upload via FTP. If changes were made to the dev database I replicate them on the production server's database as well. Any ideas where I should begin to improve this situation ? Current issues :   * Members of the team can't easily work from home since they'd have to edit on the dev server directly (lag issues)   * Deployment process is awful (changing variables manually and FTPing to production) EDIT : I'll try to add better questions.   * Setting up subdirectories for each developer on a common dev server : good idea or not ? Possible alternative : each developer setups his own dev environment (using WAMP or similar) and pushes to test server.   * For the deployment aspect I feel manually changing config variables and FTPing to production is a bad idea. Possible alternative : setting up git on production server, set config files in .gitignore (maintain them manually directly on production server) and git pushing the changes.   * For remote developers, should they replicate the dev environment (again, WAMP or similar) but work on the dev server's database ? I think it's better than copying the database on local machines.


Deny use of my library to compete a certain company

I'm developing a library for reading/writing a file format of a program created by a certain company. The guys from that company were so kind that they provided me with a documentation for their format, which I'm really grateful for. I'm intending to release the library as open-source under a license "derived" from MIT, the difference being that the library must not be used to create a program that would compete with the original program, as an expression of my gratefulness to the company. What I'm asking: is adding this rule to the license legally possible?


Good way to learn how to solve questions on InterviewStreet

> **Possible Duplicate:**   >  How do I adapt to pre-interview challenge questions? InterviewStreet is a new company that essentially acts as a filter for companies to find programmers that can code. My problem is my math is fairly weak and I'd like to study it, even if it's from the ground up, to be able to solve questions such as this one, that is found on their site: `Find the no of positive integral solutions for the equations (1/x) + (1/y) = 1/N! (read 1 by n factorial) Print a single integer which is the no of positive integral solutions modulo 1000007` Now, please do NOT post the answer to that question, it is taken directly from InterviewStreet and should not be posted here. It is not the answer I'm seeking for in this thread. What I'm asking is a more fundamental question which probably can be answered by some of the hackers in the SO community. How does one prepare for such a question? What resources are available for me to study/learn how to solve this type of problem? Is this covered on MIT open courseware? Khan Academy? Any particular books? I'm not even sure where to begin to start solving the problem above and I'd like to learn what steps I can take to do so.


Does Text Editor Sign The Files?

As images have EXIF data which provide info about where and how they are created, do any Text Editors append such kind of descriptive details to code files? For example I use Coda for my programming works. Does Coda sign any files created by itself? Is it possible to find out the author of two different projects by just looking at the inners of the files?


How hard is Python to learn?

I'm on the list of the tutors in my university _(for PHP, MySql, CSS, etc)_ but someone contacted me asking me to teach them entry level Python. Would I be able to be up quickly enough and be able **to teach it to someone else?** (I've coded in PHP, Java, C#, Javascript, jQuery, tiny bit of C++ and ASP.NET. I'm a Computer Science student. Just finished my third year.)


How can a child state machine relinquish control back to the parent state machine?

My top level state machine has some states and edges. I will call this the parent state machine.               A ----> B ----> C      Any state within the parent state machine can be a state machine too. I will call these children state machines.                          ___________              /            \     A ----> |  B0->B1->B2  | ----> C              \____________/      If the parent state machine transitions from A to B, B's state machine takes over. Once B is done running, how should it relinquish control to the parent state machine and transition to state C? Which design pattern do you use? If you're wondering, I have children state machines within parent state machines because my exact project is quite complex and it is natural to encapsulate the internal workings of a child state.


choosing a functional language platform for a new project

I have been writing code for a few years now and I don't believe I can claim to have a complete knowledge in this job yet. My experience primarily rolls around C# related areas with a decent knowledge on Silverlight and Asp .Net MVC as well. I tend to use Sql server and Postgres for normal RDBMS related tasks with Mybatis or LinqtoSql as ORM (and Cassandra as well for NoSql). Given that background, I am looking to building a new project which is a normal application using database and user interface screens. It is considerably a big project which we plan to be rolled out as a product. In recent times, I see a lot of noises being made about functional programming like Haskell and F#. I am wondering \- if it is worth to build the new system using Haskell \- or just stick to a regular application building model using Silverlight/Prism with a layering similar to onion architecture I understand the benefit of staying with the same technology background as it is always good to work on a familiar technology. I also heard that by moving towards a functional language like Haskell we get cleaner code, improved testability etc., Is it really worth considering a move to build new systems in Hasekll? Or it is yet to be proven in production environments? Simply put would I be safe if I build the new project using Haskell and my preferred database or it is too risky at this point in time to choose Haskell. Any help appreciated. Edit: I have already viewed a few other threads like the following and a few more as well, but did not get a definitive answer. Choosing a functional programming language


How does a one-person ISV handle software patent research? What due-dilligence is required?

I'd like to sell software, but I'm worried about infringing on software patents. What should I do/research prior to writing code?


Introducing Fowler's Table Data Gateway to refactor poorly designed systems

I am developing an application, which currently has about 150,000 lines of code. The previous developer didn't really use any discipline when writing code. Application is in production but is continually developed. I have read Martin Fowler's book (Patterns of Enterprise Application Architecture) and it talks about 'Transaction Scipt' and 'Data Access Objects'. These are the patterns used i.e. there is a class called Person, which contains everything Person related and a class called Order with everything Order related. The functions are not reusable because they contain everything i.e. data access logic, business logic etc. For example, Person.GetPerson will connect to the database find the person, check the age of the person, get all the orders linked to the person etc. I am thinking about introducing what Martin Fowler terms a Table Data Gateway. I am seeing this as a longer term refactor project. The problem is that this will mean inconsistency to begin with i.e. data access logic will be contained in the new Gateway, but also in the Transaction Script classes (where the other developer put it)? Is it a bad idea to go against the original developers style of coding?


Is there a comparative study of the memory consumption of programming languages runtimes, correlated with expressiveness and production bug ratios?

There are many comparative studies and available online when it comes to the runtime performance of applications built using one language or another. Some driven by corporations, some academic, some just personal experiment reports. We also get a decent share of comparative studies on side-effects of a programming language and its tooling, like:   * build times,   * likelihood of post-production bug detection,   * expressive power,   * etc... However, I've recently been more and more bummed out by the memory consumption of my programs more than anything else. This might come from the fact that while Moore's Law is on our side for raw performance, we have come to realize that other bottlenecks matter more. That, and I don't tend to update my hardware every so often, and I have some "old" (read 2005-2006 3.6GHz Pentium 4 with 4GB of RAM) that nowadays are hard-pressed to be useable for large applications without requiring me to go through great trouble to squeeze every bit of juice out of them (choice of OS, UI, tweaking of services and daemons, choice of applications to use for a task or another...). Quite honestly, sometimes I fire up `top` or `procexp` and weep at the sight of the memory used by the most innocent programs. I can address this by keeping to push in the direction listed above, and essentially trying to limit myself and the programs I use (I have a dear love for cli programs for that reason, I guess), but I also cannot help but to think that maybe we're doing it wrong. ### Modern Tools for Modern Needs Of course, higher-level languages are arguably better and justify their worth of dead weight. Some design choices were made for good (or supposedly well- intended) reasons at the time, in many toolchains. Shared libraries, memory models, pre-processors, type-systems, etc... But some might be more viable than others with our modern hardware, and I'd be curious to read a few serious studies on the matter. So, my question is, is there a pendant to the Benchmarks Game and others that focus on a comparison of the languages' base runtime memory consumption? And even further, are there some studies that cross-reference this with other parameters (similar to what this article did, for instance, for other criteria, also based on the Benchmarks Game)?


How should one implement the dependency-injection for a geocoding client that aggregates different coordinate provider implementations?

I am new to DI and I would like to know how DI might be used to help resolve this problem. If I have an `ILatLongLocation` which implements a `Latitude` and `Longitude`, then given two of these I can produce a `Distance` using a variety of algorithms, but I can also reasonably pick one of these as the "best" algorithm at design-time without losing any sleep. However, since users will rarely input physical coordinates, I may need to instead compare by zip codes or something similar. Now, in order to resolve zip codes to coordinates, I could apply a naive algorithm that uses string concatenation, etc to do a rough guess as to the physical coordinates, I could pick a random set of coordinates, etc. But in all likelihood, I will need to resolve the zip codes by using some sort of database mapping zip codes to coordinates. So being new to DI, I would like to know if the following is a reasonable application of DI and/or if I am overthinking it. `ILocatable` has `ILatLongLocation` `ILocatableProvider<T> : ILocatable` has a `T RawLocatable` and can return an `ILatLongLocation`. `IZipCodeLocatableProvider : ILocatableProvider<string>` has a `string RawLocatable` and returns an `ILatLongLocation`. `NaiveZipCodeLocatableProvider` is an implementation that just uses patterns in zip codes that are well-known to provide a best-effort guess as to the coordinates. `DbZipCodeLocatableProvider` is an implementation that uses a database (maybe through a `DbContext` or somehow else) to return the coordinates. Now `DbZipCodeLocatableProvider` itself must depend on some sort of repository or context or connection or something to access a database (unless it is literally hard-coded)... so then this means I need to have a `DbContext` or something similar... here is where I get lost. Am I thinking about this the right way? Is this a legitimate scenario for dependency injection? And how do I discriminate between, say different connection strings vs different strategies altogether for resolving zip codes to coordinates? Edit: ...and don't forget about `WebServiceZipCodeLocatableProvider` ... there's another (realistic) option.


Is it safe to rely on static analysis to "reproduce" concurrency bugs reliably?

I've inherited some Java code which I suspect harbours some concurrency bugs when synchronizing between a thread that queries data and an IO event that updates the same data. I'm trialling a static analysis tool called ThreadSafe which indeed detects various concurrency issues (i.e. field accessed from asynchronously invoked method without synchronization and Inconsistent synchronization of accesses to a collection). After discovering how difficult it is to reproduce data races reliably by writing unit tests, I wondered if it's advisable to depend on ThreadSafe to "reproduce" the bugs reliably? What I'm asking is, is it safe to depend on the static analysis tool to tell me when I've fixed the bugs? (Of course, to fix the bugs I will need to understand each one in context).


Maze generation given intersection tree

**Background Information:** I'm building a 2D maze generator. I have tried Prim's algorithm, Wilson's algorithm, and a recursive backtracker algorithm for generating my maze, however was not satisfied with the difficulty of any. I have decided to create my own. I decided that two things make a maze hard. First, mazes can have lots of intersections and choices to make. Second, they can be disorienting and cause you to lose your way. I decided to create a tree to represent the intersections and dead ends in a maze and connect each node in the tree with a randomly generated path to disorient users. **The problem:** If I begin to generate the cells in the maze for the tree, I may find that a node doesn't have the room it needs to connect to or create its children. How do I fix or avoid this problem? **My Thoughts:** There seems like there might be a way to do this by dividing the maze into sections and subdividing them, but that still doesn't guarantee enough room at the end of the division. I could also try to start small and work my way up, sectioning off smaller areas and then creating connections between them, but that could still run into pathing issues with not having enough room to connect the sections together or even creating really long paths between sections. I am using a hexagonal grid, but any solution you guys come up for rectangular grids should be easy to transfer to a hexagonal one. I wasn't sure if this should be posted in the theoretical computer science section or here, and opted for the more general one.


Is there any way to test how will the site perform under load

I have made an Asp.net MVC website and hosted it on a shared hosting provider. Since my website surrounds a very generic idea, it might have number of concurrent users sometime in future. So, I was thinking of a way to test my website for on-load performance. Like how will the site perform when 100 or 1000 users are online at the same time and surfing the website. This will also make me understand whether my LINQ queries are well written or not.


Should the deploy script be an artifact of the build?

This is a web project written in Java. So, I'm writing the build and the deploy scripts. To create the build, I used ant. The continuous build is done with Jenkins. The build generates 3 different artifacts:   1. The war file   2. A zip with layouts   3. A zip with images So far, so good, but now I need to write the deploy script, which should:   * Deploy the war (artifact 1) to the tomcat running at _server 1_   * Place the artifact **2** at _server 1_ in a specific directory   * Place the artifact **3** at _server 2_ in a specific directory So I was talking with my colleague and he said that we should also generate an artifact (maybe _deploy.xml_ ) that deploys these artifacts when placed at the correct server. So there would be another script, that would:   * Download the jenkins artifacts   * scp to each server and place the deploy.xml there   * remotely invoke the deploy.xml What makes me a little uncomfortable is the act of having the deploy.xml as a build artifact. The motivation behind this would be to be able to make a deploy without needing to have access to the VCS repositories, so a build would be self-contained, ie, any build could go into production only with what was generated by Jenkins. Where should the deploy scripts be placed? Should they be **only** at the VCS or should they be build artifacts too?


Right Tools For The Job? One Location vs Multiple?

I'm currently using Codebase for all my project management (where I'm learning Agile). I use it for tracking bugs, user stories (via tickets), wikis, files and git hosting. However, I'm looking to improve on this and find some tools better suited to things like bug tracking, managing stories, git hosting, collaboration, client feedback etc. I'm part of a small team of 3 or 4 developers. Does anyone have any recommendations? My initial thoughts based on research was:   * Project Management: JIRA   * Bug Tracking: JIRA   * User Stories and Agile: Pivotal Tracker   * Git hosting: JIRA   * Storage: Dropbox However it seems this is quite disjointed in that it could prove more work than its worth. Appreciate any advice on the above or tools which you've used and found work great for small-medium teams and suit Agile. My SPECIFIC requirements are: Bug tracking, managing stories, git hosting, remote team collaboration, client feedback, time tracking, storage, build management, project lifecycle progression data... I also found Assembla which seems excellent. One of my team members believes in "the right tool for the job" and that there is no single tool to manage all of this. I was hoping for a central location.


Move from Curl to Aria2?

We have a crawling engine that uses curl and caters to about 400,000 ppl / month. Although curl supports concurrent downloads, it does not support bandwidth limiting ( only in php 5.4.0 ) which is why my boss wants me to move to aria2. He also says Aria2 is faster ( which seems to be true to me as well ) Aria2 would require a large amounts of changes to the system. Right now we have crawling system which does not crawl in a conconrrent manner. Would moving to aria2 be a good decision?


Why do popular websites store very complicated session-related data in cookies -- and what does it all mean?

As web developers, we all learn that sessions help overcome the problems related to the stateless nature of HTTP. We create a unique session id, and send it to the browser -- and when the browser sends the same id back to us, we identify the user easily. All this sounds pretty straightforward, and NOT so complicated to implement in any language. ## NOW Look at the following screenshots I took. These show the kinds of cookies popular websites store. It looks like they are storing multiple session IDs, or they are trying the hide the actual id by setting so many cookies, or, it is something very specialized security measures they're taking to prevent session hijacking and other related problems. Or, whatever. ## Gmail (before login) ![enter image description here](http://i.stack.imgur.com/RKLmL.jpg) ## Gmail (after login) ![enter image description here](http://i.stack.imgur.com/9pWMf.jpg) ## Facebook ![enter image description here](http://i.stack.imgur.com/f760r.jpg) ## StackExchange ![enter image description here](http://i.stack.imgur.com/CIXd4.jpg) (Don't worry, you can't steal my session -- it's stale and incomplete :)) So, my question is -- what purpose does this complicatedness serve? Please explain what these different cookies mean (in general), and for what purposes these are set. Lastly, hint on how I can do it (and whether I should) in my own apps. One more question: In a lot of instances, the values in the cookies look like they are URL-encoded -- why so?


Call stack starts at bottom or top?

A stack is something that piles bottom-up. Hence a call stack adds new items on the stack when functions are called with items being removed from the stack as each function ends until the stack is empty and then the program ends. If the above is correct, why do people refer to control moving "up" the call stack? Surely control moves _down_ the call stack until it reaches the bottom.


Selling LINQ To Management

I recently started working at a new company that currently doesn't use linq, but does use C# and the .net framework. I'm coming from a LINQ background, so I'm biased, but I still think there are a lot of advantages to using linq. That being said, it's still going to be hard to influence change as I'm still very new. What suggestions do you have to sell this to management? The database systems are still relatively new, so I think now, as things are still developing, would be the best time to try convincing people to use this. This is both a technical and political question. Any help would be appreciated.


Isolated environment for software stacks

I was sure that I would find this question, but I couldn't. How to create an isolated development environment? It other words, a sandbox, where I can install different combinations of web servers, databases, other software packages and play with them, without cluttering my system packages and without manually downloading packages from official websites. Something for software stacks as virtualenv + pip is for Python. Before that I tried to install OSes inside QEMU/KVM, but that is an overkill and a bit complicated (couldn't set up bridging, for example). Is it possible to create isolated virtual environments without running virtual machines with full-blown operating systems? I use Debian GNU/Linux. **Edit (01.08.12):** A similar question on Unix.SE with more elaborated answers - http://unix.stackexchange.com/q/31136/11397


Inspirational software for end-users written in Haskell?

I think great technology is invisible. Besides the usual suspects (GHC, Xmonad, proprietary trading software) what great examples are there of end-user software written in Haskell? I think good examples are FreeArc, Hledger and "Nikki And The Robots". Do you have more examples (full blown GUI apps, small CLI tools, etc)? **Edit:** For example, I am fascinated by Wings3D, because, while it's written in Erlang, users cannot tell that. It just works. Among Haskell's weak spots are cross-platform GUIs. There are not many GUI apps written in Haskell in general and most of them are not easy to use, install or even compile. What are good examples to learn from how to make hard things look easy?


How to interpret programmer salary survey data, especially concerning different job titles?

I've been trying to understand how my compensation stacks up against the competition. I understand that this can be a bit of a localized question, so I'll do my best to avoid local issues. There are a number of web sites that provide salary survey data about different jobs. I've been looking at the data on careerbuilder.com in particular. I would like to use this data to understand how much salary I would be wise to ask for in negotiation, but it seems impossible to interpret. Let me start with job titles. I have a background in mathematics and computer programming. I am currently doing database-driven web development using mostly SQL, .net, and Javascript. I do much more programming than I do web design. In my current position, I was told that I would be a "Web Developer". I was told that I would be junior to the "Application Developers", but senior to "Junior Developers". That was fine with me. After several months lapsed, I received (with no prior notice) a new nameplate for my cube that bore the title "Application Developer". The developers who had been previously called "Application Developers" are now called "Sr. Systems Analysts". As far as I know, these new nameplates did not accompany any actual organizational change or pay differences. However, when I go to the salary surveys on careerbuilder.com and enter in "computer programmer", "application developer", "web developer" and other seemingly similar titles, I get wildly divergent results. Even more divergent are the results on Glassdoor.com, which reports survey results from individual companies. Consider this example: ( http://www.glassdoor.com/Salaries/net-salary-SRCH_KO0,3.htm ) that has differences of over 100% salary between different companies for the same title!


Regarding interfaces of classes in OOP

When one says "a class' interface": Does he/she refer to all of the get and set methods - or do they refer only to the methods' signatures and return types, without the inner implementation of these methods? (Aka, the implementation of a 'get' method isn't considered part of the interface, but rather part of the inner implementation of the class. The interface is the return type for that method and the signature of that method).


Guide developers to not forget their obligations

> **Possible Duplicates:**   >  What is the Best Way to Incentivize a Team of Developers?   >  How do you motivate peers to become better developers? Aside developer's tasks, there are minor stuff that each developer should do. In our company, the project leader spends some time with each developer to guide them on how to do several stuff, especially on inexperienced ones. Of course each developer has their tasks, but also they have notes that either they or the project leader noted. Those tasks can be like:   1. You should change the flow of this method,    2. I don't like the way you solve this issue,   3. Consider a faster solution   4. etc. Those notes of course can be noted! But laziness is an issue, even if the developer has the abilities required. My question is: How do we 'force' them to become more hypochondriacal than lazy?


Is using MultiMaps code smell? If so what alternative data structures fit my needs?

I'm trying to model nWoD characters for a roleplaying game in a character builder program. The crux is I want to support saving too and loading from yaml documents. One aspect of the character's is their set of skills. Skills are split between exactly three 'types': Mental, Physical, and Social. Each type has a list of skills under if. My Yaml looks like this:               PHYSICAL:         Athletics: 0         Brawl: 3     MENTAL:         Academics: 2         Computers      My initial thought was to use a Multimap of some sort, and have the skill type as an Enum, and key to my map. Each Skill is an element in the collection that backs the multimap. However, I've been struggling to get the yaml to work. On explaining this to a colleague outside of work they said this was probably a sign of code smell, and he's never seen it used 'well'. Are multiMaps really code smell? If so what alternate data structures would suit my goals?


Finding the time to program in your spare time?

I've got about a dozen programming projects bouncing about my head, and I'd love to contribute to some open source projects, the problem I have is that having spent the entire day staring at Visual Studio and or Eclipse (Sometimes both at the same time...) the last thing I feel like doing when I go home is program. How do you build up the motivation/time to work on your own projects after work? I'm not saying that I don't enjoy programming, it's just that I enjoy other things too and it can be hard to even do something you enjoy if you've spent all day already doing it. I think that if I worked at a chocolate factory the last thing I'd want to see when I got home was a Wonka bar.


Why profile applications using AOP?

When tuning performance in a web application, I am looking for good and light- weight performance profiling tools to measure the execution time for each method. I know that the easiest profiling method is to log the start time and end time for each method, but I see more and more people using AOP to profile (add @profiled before each method). What's the benefit of AOP profiling compared to the common "log" way? Thanks in advance Vance


When calling a method should we use base.methodname and this.methodname?

In C#, with an inherited class set -- when calling a method should we use keywords 'base.methodname and this.methodname'... irrespective of whether it is a overridden method or not? The code is likely to undergo changes in terms of logic and maybe some IF-ELSE like conditions may come in at a later date. So at that time, the developer has to be compelled to revisit each line of code and ensure that he/she makes the right choice of which method is being called --- base.methodname() or this.methodname() ELSE the .NET framework will call the DEFAULT (I think its base.methodname()) and the entire logic can go for a toss.


Should I buy Clean Code after reading The Clean Coder?

I"m currently reading _The Clean Coder_ by Robert C. Martin. It's a great book and I'm learning a lot from it. My objective is to become a "professional" programmer so I'm trying to learn the most I can when I'm not at my office. I was wondering if I should buy _Clean Code_ from the same author. Is it the natural "sequel" to _The Clean Coder_? Does it cover much the same ground to make its purchase not worthwhile?


Technology Selection for a dynamic product

We are building a product for Procurement Domain in JAVA. Following are the main technical requirements.   1. Platform Independent   2. Database Independent   3. Browser Independent In functional requirements the product is very dynamic in nature. The main reason being the procurement process around the world is different from client to client. Briefly we need to have a dynamic workflow engine and a dynamic template engine. The workflow engine by which we can define any kind of workflows and the template engine allows us to define any kind of data structures and based on definition it can get the user input through workflow. We have been developing this product for almost 2 years. It has been a long time till we can get down with the dynamics of requirements. Till now we have developed a basic workflow and template engine and which is in use at one of the client. We have been using following technologies.   1. GWT-Ext (Front End Framework)   2. Hibernate (Database Layer) In between we have faced some issues with GWT-Ext (mainly browser compatibility) and database optimization due to sub classing in hibernate. For resolving GWT-Ext issue, which a dying community so we decided to move to SmartGWT. In SmartGWT we faced issues related to loading and now we are able to finalize that GWT 2.3 will be the way to go as the library is rich and performance is upto the mark. We are able to almost finalize GWT-Spring based front and middle layer. In hibernate, we found main issues with sub-classing due to that it was throwing astronomical queries and sometimes it would stop firing any queries for 5-10 seconds or may be around 30 seconds and then resume again. Few days back I came to one article related to ORM. I am a traditional .Net SQL developer and I have always worked with relational database. Reading through this article, I also found it relating to the issues I face. I am still not completely convinced of using hibernate and this article just supported my opinion. Following are the questions for which I am looking for an answer.   1. Should we be going with Hibernate in case of dynamic database requirements and the load of the data will be heavy in future? How can we partition the data, how we can efficiently join the data, how we can optimize the queries? If the answer is no then how do we achieve database independence?   2. Is our choice related to GWT and Spring proper or do we need to change that too?   3. Should we use any other key value pair database if the data is dynamic in nature and it is very difficult to make it relational?


Documenting mathematical logic in code

Sometimes, although not often, I have to include math logic in my code. The concepts used are mostly very simple, but the resulting code is not - a lot of variables with unclear purpose, and some operations with not so obvious intent. I don't mean that the code is unreadable or unmaintainable, just that it's _waaaay_ harder to understand than the actual math problem. I try to comment the parts which are hardest to understand, but there is the same problem as in just coding them - _text does not have the expressive power of math_. I am looking for a more efficient and easy to understand way of explaining the logic behind some of the complex code, preferably in the code itself. I have considered TeX - writing the documentation and generating it separately from the code. But then I'd have to learn TeX, and the documentation will not be in the code itself. Another thing I thought of is taking a picture of the mathematical notations, equations and diagrams written on paper/whiteboard, and including it in javadoc. Is there a simpler and clearer way?    * * * P.S. Giving descriptive names(`timeOfFirstEvent` instead of `t1`) to the variables actually makes the code more verbose and even harder too read.


Inspiring Computer Science College Student Stories?

After watching "The Social Network", a movie about Mark Zuckerberg and Facebook, I had a productivity spike as it inspired me to learn many different languages and software. That spike has been deteriorating somewhat and I don't feel like watching the movie all over again so I was wondering if anybody had any other similar success stories/links/articles/whatever. Mainly about successes that started for people in college.


Vernon's book Implementing DDD and modeling of underlying concepts

Following questions all refer to examples presented in Implementing DDD In article we can see from Figure 6 that both **BankingAccount** and **PayeeAccount** represent the same _underlying concept_ of _Banking Account_ **BA** **1.** On _page 64_ author gives an example of a _publishing organization_ , where the life-cycle of a book goes through several stages ( _proposing a book_ , _editorial process_ , _translation of the book_ ... ) and at each of those stages this book has a different definition. Each _stage of the book_ is defined in a different _Bounded Context_ , but do all these different definitions still represent the same _underlying concept_ of a **Book** , just like both **BankingAccount** and **PayeeAccount** represent the same _underlying concept_ of a **BA**? **2.** a) I understand why `User` shouldn't exist in **Collaboration Context** ( CC ), but instead should be defined within **Identity and Access Context** IAC ( _page 65_ ). But still, do `User` ( IAC ), `Moderator` ( CC ), `Author` ( CC ),`Owner` ( CC ) and `Participant` ( CC ) all represent _different aspects_ of the same _underlying concept_? b) If yes, then this means that CC contains several _model elements_ ( `Moderator`, `Author`, `Owner` and `Participant` ), each representing _different aspect_ of the same _underlying concept_ ( just like both **BankingAccount** and **PayeeAccount** represent the same _underlying concept_ of a **BA** ). But isn't this considered **a duplication of concepts** ( Evan's book, page 339 ), since several _model elements_ in CC represent the same _underlying concept_? c) If `Moderator`, `Author` ... don't represent the same _underlying concept_ , then what _underlying concept_ does each represent? **3.** In an **e-commerce system** , the term **Customer** has multiple meanings ( page 49 ): When user is browsing the **Catalog** , **Customer** has different meaning than when user is placing an **Order**. But do these two different definitions of a **Customer** represent the same _underlying concept_ , just like both **BankingAccount** and **PayeeAccount** represent the same _underlying concept_ of a **BA**? **UPDATE:** 2. > 2a) As with the book, they refer to the same identity but express different > aspects of that identity in a specific context. Sort of like a single object > implementing multiple interfaces which embody the roles that object plays. a) Does having two _model elements_ ( both within same **BC** ) , each representing _different aspect of the same underlying concept_ , result in what _Evans_ calls **duplicate concepts**? b) I thought terms " _representing different aspects of an identity within particular BC_ " and " _representing different aspects of the same underlying concept within particular BC_ " are interchangeable ( ie they mean the same thing )? If not, how do they differ? c) > Sort of like a single object implementing multiple interfaces which embody > the roles that object plays. I assumed each _role_ represents a _particular aspect of the underlying concept_ , but you're saying it doesn't? What then does _role_ model and how is the thing that role models conceptually different from _an aspect of the underlying concept_? **2\. UPDATE:** **2.** a) > > Does having two model elements ( both within same BC ) , each representing > different aspect of the same underlying concept, result in what Evans calls > duplicate concepts? > > I don't recall what Evans called duplicate concepts so not sure. On page 339 Evans describes **Duplicate concepts** as being one of the two conceptual splinters that cause the unification of a model to break down. Here's the quote: > Combining elements of distinct models causes two categories of problems: > duplicate concepts and false cognates. Duplication of concepts means that > there are two model elements ( and attendant implementations ) that actually > represent the same concept. Evry time this information changes, it has to be > updated in two places with conversions. Every time new knowledge leads to a > change in one of the objects, other has to be reanalyzed and changed too. > Except the reanalysis doesn't happen in reality, so the result is two > versions of the same concept that follow different rules and even have > different data. b) and c) > This may be a linguistic issue. The way I see it, an identity can have > different concepts associated with it depending on the context. > > Again this seems to be a linguistic issue. You use "underlying concept" to > refer to identity which I think isn't clear enough to distinguish from > simply "concept" which by itself isn't sufficient. Perhaps the following will make my questions clearer: By _underlying concept_ I'm referring to _an aspect of reality_ ( ie the thing ) which we try to model. thanks


Internationalization messages based in views or in model entities

I have a small webapp in java and I am adding the internationalization support, replacing texts with labels that are defined in dictionary files. While some texts are obviously unique to each view (v.g. the html title), other refer to concepts from the model (v.g. a ticket, the location or status of such ticket, etc.) As usual, some terms will appear many times in different locations (vg, in both the edition page and in the search page and in the listings I have a "ticketLocation" label). My question is: can I organize the labels around the model concepts (so I have a `ticket.location` label and I use it everywhere such field is labeled) or should I make a different label for each (so `form.ticketLocation` and `filter.ticketLocation` and `list.ticketLocation`). I would go for the first option; I have searched for tips and the only thing that I see that could hinder me is due to the length of the string disrupting the design, and even for that I would prefer having to add a `ticket.locationShort` for places where there is not much space. What is your opinion/tips/experience?


how to find out if spelling mistakes in source code are a serious issue or not?

I find very troubling amount of spelling mistakes I see everyday in our codebase, from which I will reproduce a very short but representative example:               ArgumnetCount     Timeount     Gor message from queue       Unfortunately this is in no way limited to one person. There is a lot of non- native English speakers in our team who contribute to that, however I can also pinpoint some of the worst spelling mistakes to our Software Architect who is American, born and raised. These are also to be found even in emails, presentations, documents, whatever piece of written information we have in a software development company. I'd like to know how to find out if it is a serious issue or not? I've always met these spelling mistakes with concern, but my own, personal, **official** policy is that we are not paid to spell things right, we are paid to get things done, so inside the company I never really criticized anyone about it. But I have raised this issue with some of my close friends, and never settled it for good.