title: Sharing only part of code with git

text: **The situation** I have code which has features X and Y. Bob needs access to the code to help develop feature X further. Normally I would allow Bob to clone the code, but the problem is that feature Y is confidential, so this is not possible. Bob does not need to be able to view feature Y code to develop feature X further. If I create a new branch to share with Bob and delete feature Y from the code, it will still be viewable in the commit history. So I guess the only option is:   1. Create a new branch and delete feature Y.   2. Create a completely new repository to share with Bob   3. Copy the files (while the new Y-less branch is checked out) to the new repository.   4. Give Bob access to that new repository.   5. After Bob develops feature X further, cherry pick relevant lines and files, and put them into my master. (painful) **Question** Is there a better way to go about this?


title: MVC - sharing multiple models

text: I am building a java desktop application where I am attempting to implement MVC. The GUI interface has multiple views (think pop-up windows) from the main view. Each view has its associated model that it receives updates from. I am running into scenarios where **two views** need to access a particular data field from one **model**. This requires that one model "knows about" the another. What are my options to solve this? The data field is a table that is populated in one of the views and is then subsequently accessed in the main splash view. I have tried passing the second model into the first's constructor from the controller, however I feel this is sloppy. Should a model listen to another model (Observer pattern)? Perhaps my question is too subjective....


title: How would you design a programming language?

text: If you were to design a programming language, how would you do it? What features would you put in? What would you leave out? Statically or dynamically typed? Strongly or weakly typed? Compiled or interpreted? Justify your answers.


title: "Saving method name in a variable: Python", How does this code works?

text: I am trying to make sense of the following code snipet:               factor = misc.kkt_chol2(G, dims, A)     ....     ....     factor(W, P)      How the parameter in factor binding with the parameters inside kkt_chol2? Thank you in advance for the response.


title: Categories of 'for' loops

text: I remember once reading some research where a body of C code had been analysed, and the findings were that the vast majority of `for` loops could be categorised into about five categories, corresponding to the functional equivalents of `map`, `filter`, `fold`, etc. I can't seem to find this paper/article anymore. Can anyone point me to it?


title: Why contribute to non-free open source projects?

text: As a owner of an open source project you'd want people to contribute and make it better, right? But if you then decide to throw on a nice tasty licencing model for people to use the software [Corporate or otherwise], do you get rights to all the income? if so why would people bother contributing? They could be doing all the work while you, the owner, reap all the rewards? This just seems wrong to me, maybe i'm misunderstanding it.


title: Am I considered "technical"?

text: Am I considered "technical"? I am starting my third company, and in the process of doing so, I meet investors. They seem to be all caught up in whether a startup has a technical co-founder. Ok. So what makes a person technical? Here's some info about me. You be the judge.   * I have worked for software and internet companies for 18 years.   * I have built web sites.   * I am starting my third company.   * My business partners build the web architectures for the businesses I dream up.   * I've successfully launched technical products for mobile and web in the US and Internationally.   * I do the rest of the work.   * I have a Github account.   * I've built my own gaming PCs. But I may be taking the question too literally when asked "Are you technical?"   * I don't code, but I can read code well enough to copy/paste it.   * I've worked on command line editors like emacs and vi, but it's not my forte. Or should I just lighten up and answer "Yes" when asked?


title: Is it ethical or even legal to track user data/metrics using IP

text: This one is a bit tough. It is publicly available information, is it not? But it's can also be used maliciously. So is it legal/ethical to store and/or gather information on users based on IP? It's mostly for curiosity, but it would also be important for marketing purposes, and maybe something to anonymously post on the homepage. One use for this is detecting attacks and, for some products, limiting your release to one part of the world. I can see no real downsides from a business point of view, but I can also see how it would make users feel uncomfortable, and may actually be illegal. Right now, I'm simply storing the user-agent and ip strings in a slightly randomized line-break format, so if a vulnerability is found by a web bot, there's less of a chance for ips to be properly scraped. But I'd like to eventually compile a map of users, and put a little dot where each user logged in. It would be a world-wide map, so the fine details would not be disclosed. But for some reason, I feel like I'm guilty of something or will get into trouble for collecting this data. On the legal side of things, I've noticed articles similar to this: http://www.adexchanger.com/the-debate/why-ip-tracking-is-a-bad-idea/, and I've read about companies like Google and Facebook getting into hot water with users for collecting data. I am in the United States, and the server will most likely operate somewhere in the US, but I have the impression that the per-country laws pertained to the client visiting.


title: How to organize software document for the same application supporing both iOS and Android

text: I have to write software project documentation for an application which will support both iOS and Android. Each platform has its specific features and the mobile app design and requirements are almost the same. At first, I thought to include all the requirements in one document by separating the platforms side-by-side. However, why should android devs see the iOS dev part and vice-versa? Should I write the document separately for each platform or include it in one document? Which one is good for QAs and for the overall professionalism of the software requirement specification ?


title: Advice for good web server development setup

text: A month or so ago I created my first LAMP stack and implemented a simple web site that exercised each letter in that acronym. However my development setup was much less than ideal. I don't really have a local test server, but instead I was writing all of my CGI scripts in vim while ssh'ed into the remote machine as _root_. Now I intend to start more serious development. **Question:** What is a good setup so that development goes as easily as possible? I would like to understand what is available to me along the lines of an IDE, subversion (or alternatives), uploading and downloading content, and just best practices. I'm pretty new at all of this. Also, feel free to point me at good websites. There's plenty of websites, but only people who are already heavily developing web content are able to quickly determine if they are good websites.


title: Rolling your own Hackathon

text: **Background Info** Hey, I pitched the idea of a company Hackathon that would donate our time to a charity to work on a project (for free) to improve morale in my company and increase developer cohesion. As it turns out most like the idea but, guess who's gonna be the one to put it together. lol Yeah me. I should add that we are a fairly small shop with about 10-12 programmers (some pull double duty as programmers, inters etc..) So, that might make things a bit easier. **Base Question** While I am no means a project manager or of any level of authority (Entry level guy) I was wondering if anyone knew the best approach for someone in my position to put together such an even with possibly (some) company backing. Or for that matter have any helpful advice to pass along to a young padawan. **So far.....** As of right now it is just an idea so, to start with I presumably would have to put together some sort of proposal and do some that office stuff that I became a programmer to steer clear of to some extent.


title: When is it right to edit the code written by a co-worker?

text: For which issues is it right to edit the code written by a co-worker? For which issues is it wrong?


title: Getting a coherent view of the state of the data

text: Here is a theoretical problem. It could apply to many systems. Let's assume RESTful Web services for example. You want to find out something but as it happens you can't get it in a single query. You can make multiple queries. For example, you have a joint bank account (or a company bank account) and you want to find out how much money is in there. Meanwhile someone else transfers money from checking to savings.               Checking:  $5,000   Savings:  $3,000      > Me: Query Checking. Response: $5,000 > Joe: Transfer $4,000 from Checking to Savings               Checking: $1,000   Savings:  $7,000      Me: Query Savings. Response: $7,000 Total $12,000. How do you avoid anomalies like this? The example shows two accounts at one bank, but it can also happen with two accounts at two different banks.


title: Topics for development team cross training sessions

text: Our team of developers are going to start holding monthly meetings for the purposes of cross training and knowledge improvement. We're looking for ideas for topics to discuss. We've already made a list of some obvious ones, such as discussions/training on specific applications, proper usage of TFS for source control, bug tracking and code reviews, coding standards, and corporate architecture. The problem we're having is that we are a cross-platform development team so we don't want to look at topics that only apply to certain members of the team (Sql, .NET, reporting, third party apps, etc). We'll use sub-team meetings for those. So what other topics that would apply across a broad development team would be good for these training sessions?


title: Preventing some downsides of a static class

text: Here is my situation. I have implemented the accepted .NET 4.0 answer in this question, which is working. However, my codebase is quite large and as responsible for this code I've started getting inquiries regarding this solution. I've been asked if there are no easier ways of accomplishing the same thing, and if there is any way to shorten the usage. In almost all cases, this class is used to get or set a single property only. This favors other solutions, since the usage ends up like this: `new UserSessionData().CustomerNumber = 123;` The closest thing I have is a class (static or not) with static members and methods, like this:               public static class UserSessionData     {         public static Dictionary<string, string> AsDictionary()         {             return typeof(UserSessionData).GetProperties()                        .ToDictionary(p => p.Name, p => p.GetValue(null, null) as string);         }         private static string Get(Expression<Func<string>> e)         {             var me = e.Body as MemberExpression;             return ExternalInterfaceClass.Get(me.Member.Name);         }         private static void Set(Expression<Func<string>> e, string value)         {             var me = e.Body as MemberExpression;             ExternalInterfaceClass.Set(me.Member.Name, value);         }              public static string CustomerNumber {             get { return Get(() => CustomerNumber); }             set { Set(() => CustomerNumber, value); }         }              // ... and hundreds more properties similar to "CustomerNumber"     }      This feels like a quite good solution:   * It's strongly typed (i.e. I can easily refactor `CustomerNumber` throughout)   * Usage is great (`UserSessionData.CustomerNumber = 123;`)   * The boilerplate is not _that_ ugly - I think it's acceptable However, there is one issue that I can't wrap my head around. Sometimes we need to be able to use this a little differently, A) as a return type and B) bulk-editing the structure before saving. As for A, I understand that a static class cannot be used as a return type, however I don't know what my alternatives would be in this specific situation? As for B, I guess that I could delay the actual saving by providing a stated subclass and requiring explicit save, but the usage would be worsened for the normal use case (setting or getting a single property) since every one-liner would have to be followed by a call to the save method. I thought about creating an interface for the class but interfaces can't define static properties. I'm feeling a little muddled here, help is appreciated. Please provide a minimal code example when presenting your thoughts, if possible - it clarifies the point a lot.


title: How can I save my university's Computer Science & Engineering department?

text: I'm currently pursuing a B.S. in Computer Engineering at the University of Florida, and we're having a bit of a problem right now... The state recently passed a budget plan that cuts funding for higher education in Florida. The dean of UF's College of Engineering decided that the best way for us to absorb the blow is by executing the following plan:   * All of the Computer Engineering Degree programs, BS, MS and PhD, would be moved from the Computer & Information Science and Engineering Dept. to the Electrical and Computer Engineering Dept. along with most of the advising staff.   * Roughly half of the faculty would be offered the opportunity to move to Electrical/Computer Eng., Biomedical Eng., or Industrial/Systems Eng.   * Staff positions in CISE which are currently supporting research and graduate programs would be eliminated.   * The activities currently covered by TAs would be reassigned to faculty and the TA budget for CISE would be eliminated.   * Any faculty member who wishes to stay in CISE may do so, but with a revised assignment focused on teaching and advising. In short: **our department (at least as we know it) is being decimated.** Computer & Information Sciences & Engineering (one of 9 departments in the College of Engineering) is taking more than 50% of the cuts. If you're interested in reading the full proposal, you can access it here. A vast, VAST majority of the students and faculty in the department are vehemently opposed to this plan, however the dean is already taking measures to implement it. This is the only proposal on the table right now, and she has not entertained our requests for alternatives. She sees it as an obvious (albeit drastic) solution to our budget problem, citing that many other universities have combined Computer and Electrical Engineering departments. I'll bet those universities didn't have to eliminate an established department to get there, though. The budget goes into effect July 1, 2012 (this is non-negotiable), and the dean's proposal is currently set to be finalized some time next week. We don't have much time! **My question to everyone here is this** : Are we overreacting to this plan, or are we justified? And could you explain why or why not? It's obvious that CISE students will resist any cuts to our department, but I'm curious to see what other people in the field have to say. Any feedback is greatly appreciated. **I will select the answer that saves our department.** Just kidding, I'll pick the one that best explains why this is a good or bad decision for the dean to make. Please note that anything you say _can_ and _will_ be used to further our cause (and we might track you down if you provide a compelling argument against us).


title: Possible applications of algorithm devised for differentiating between structured vs random text

text: I have written a program that can rapidly (within 5 sec on a 2GB RAM desktop, 2.33 Ghz CPU) differentiate between structured text (e.g English text) and random alphanumeric strings. It can also provide a probability score for the prediction. Are there any practical applications/uses of such a program? Note that the program is based on entropy models and does not have any dictionary comparisons in its workflow.


title: How to explain the history of programming to non-programmers?

text: Sorry if this question is not appropriate for this stack exchange site, I've never used this one before. I am doing my senior project on computer programming. I'm going to be presenting the project to classmates, teachers and (most importantly) judges, who haven't the slightest clue what programming is. My question is somewhat broad, but how should I make my project to be about programming but still be simple enough for the judges to understand? Here are some things I considered:   1. The project will focus on the history of programming, what it has accomplished, how it is used today, etc. and I will show pictures of code and say "This is what code looks like". So the presentation would be simple, easy, and average.   2. Try to explain a little bit of code, perhaps show a loop in action or something like that, and try to make the audience think a bit rather than just watch someone present some stuff they consider to be boring. But then again, I don't want to make them feel stupid or anything.


title: using unsigned integers in c, c++

text: I have a very simple question that baffles me for a long time. I am dealing with networks and databases so a lot of data I am dealing with are 32-bit and 64-bit counters (unsigned), 32-bit and 64-bit identification ids (also do not have meaningful mapping for sign). I am practically never deal with any real word matter that could be expressed as a negative number. Me and my co-workers routinely use unsigned types like uint32_t and uint64_t for these matters and because it happens so often we also use them for array indexes and other common integer uses. At the same time various coding guides I am reading (e.g. Google) discourage use of unsigned integer types, and as far as I know neither Java nor Scala have unsigned integer types. So, I could not figure out what is the right thing to do: using signed values in our environment would be very inconvenient, at the same time coding guides to insist on doing exactly this.


title: Is it okay to convert dataset from stored procedure to IEnumerable

text: So, I am working on a project with a team and we are using Entity Framework. We basically want to use linq to entities, and not use stored procedures. I use quite a bit of lists and IEnumerables and so does everyone else. My question is, will converting the dataset produced by a stored procedure to an IEnumerable dramatically slow down the applications performance speed, say it parses through 1,000's of rows. Or would it be better to convert the store procedure to linq to entities(the procedure is a bit complex). We have not set up testing unit tests and integration yet.


title: INI files or Registry or personal files?

text: I want to save the configuration of my project which includes   1. Screen size   2. Screen position   3. Folder paths   4. Users settings and so on. The standard places where you can save these are configuration values are:   1. Registry   2. INI files   3. Personal files (like *.cfg) How do you choose between these places? Also, are there any **pros and cons** of using any of them?


title: What's the difference between an Asset and a Resource?

text: I've used several IDEs and created several default projects. Upon creation, I'll find folder structures created for me. Sometimes I'll see a Resources folder, sometimes an Assets folder, and sometimes both. Is there actually a (standard) difference?


title: 2 year degree plus experience vs 4 year degree

text: Alright, I have searched around a bit on this site and found two somewhat similar questions: Computer Science Programming Certificate vs. Computer Science Degree? Is it possible/likely to be paid fairly without a college degree? But these do not provide an answer specifically to what I am seeking. I have my 2 year A.A.S. Degree in computer programming, along with a networking certificate from a technical college. I also have been working at a small educational game development company for 3 years now in various positions, but steadily moving up and now as a lead programmer on a few projects. Some of the higher programmers I work with claim that no matter how much experience I develop it still will not mean as much as someone with a 4 year degree. Their argument is that most employers will look over my resume because of the common '4 yr' minimum requirement. I have also heard people state (not as many though) that experience is everything and that an employer would rather have someone that has worked in the field instead of a rookie fresh out of college. I have heard both sides of this argument, but am looking for a general consensus, or more arguments from both sides from the people who have been there, or are there.


title: How can I combine C/Fortran with JavaScript?

text: I'm working on a project where I need heavy numerical calculations to be real- time visualized with something flexible like D3.js. Are there frameworks out there that would let me painlessly achieve this? Or do I need to use some sort of "glue" code written in, say, Python?


title: In TFS, how should different "releases" be structured? (version 1.0, version 2.0)

text: I am importing a website into TFS that is stored in SourceSafe as               $/MyApp 1.0     $/MyApp 2.0     $/MyApp 3.0     $/MyApp 3.5      Should I import this as several distinct projects (MyApp1.0 ... ) or as one project called "MyApp"?


title: Hand over source code to customer

text: I have made a couple iphone applications for a customer and was asked today to hand over the source code so that they could do the maintenance if this should be required. Until now, no code issues were ever discussed. Is there any "common" practice regarding this?   Also, in which way should this affect the price?


title: What to explain when asked "How did you implement MVC"?

text: I have a project on my resume in which we had used `MVC Architecture` and `Java, JSP and MySQL`. Hence during the interviews if the position requires experience about MVC Architecture, I have to face the question like "`Explain this project.`" What exactly is the interviewer is expecting? I know that they want to know how we implemented the MVC. But what "exact" details should I tell them in the short time span of 2-3 minutes? Which key features/parts I am supposed to explain? Can someone experienced give some idea about it? The project is about Leave Management System.


title: Interview - Create a portfolio to show my skills

text: I have around five years of experience in PHP development and around one year of experience with ExpressionEngine. I use PHP 5, HTML, CSS, JavaScript and other web technologies. I decided to create a portfolio site and include hundreds of (if time permits) little examples to prove my skills. Then at the interview if the interviewer asks me to show my work I am going to show my portfolio site. Is this a good approach? If yes, can you suggest to me some great, creative projects to include in my portfolio? I am thinking: 1. Model View Controller 2\. Simple e-commerce site 3\. Content Manage System (CMS)


title: Questions about God's algorithm and Rubik's cube

text: I am creating Rubik's cube solver. It will be good if solver could solve cubes of any size and if it could generate short solutions. I have found many various information about God's algorithm, which as I understand is able to solve various puzzles, not only Rubic's cube. So I want to implement God's algorithm, but I cannot find any simple explanation of this algorithm. In simple words, how does God's algorithm actually work?


title: Is depending on lazy loading a code smell?

text: During my short experience with DDD I often find myself in the situation where I wished for some type of lazy loading mechanism to solve some dangerous cases where large nested data sets might be loaded. However after a while I realized that each time, that was the symptom of a poorly designed aggregate root that was taking too much responsibility. Additionally it used to be the case where the aggregates should be fully loaded to perform consistency operations. Getting used to work with Entity ids made things slightly easier. So after a while, I am wondering... is lazy loading a code smell? Is it something just to build non mature models without causing a big problem?


What roles do people take after scrum master/technical lead? EDIT: My current role is a mix of a technical lead and scrum master role, but that's how we do it in my company :) )


title: Dealing with large amounts of web service requests and storing that data

text: I have a desktop application that sends a POST request to my website every 5 minutes. This post request can contain a variable amount of data about the PC sending the request, but typically it contains about 20-30 variables of information. I'm storing all of this information in a MySQL table in a format like, RequestID|Field|Value. I want to be able to keep all of it so I can run trend reports over 24 hours, 48 hours, weeks, months, years, etc. This could amount so something like 10,000 rows of data every day. That's 3 million rows of data a year. I can imagine 20-30 people using my website and the database storing 100 million rows of data a year. What is the best way to approach this kind of 'notification' service and scale it?


title: Most "native"/integrated functional language for Mac OS X development?

text: If one views the CLR/.NET runtime and associated libraries as the future of windows, then the F# programming language could be seen in that light as the most native functional language. Meaning that it has support from the OS creator, presumably integrates best with their libraries, etc. Is there a similar logical choice of language on the Mac OS X platform? While the most-native language itself is obviously Objective-C, is there a first- among-equals or most obvious functional paradigm language that stands out?


title: How important is it to learn jQuery with ASP.NET

text: I'm reading a chapter on jQuery in a ASP.NET book. To be honest I'm finding it quite boring. How important is it to learn jQuery? And do many ASP.NET developers use it for their pages? Regards TDG


title: How can I profile database queries from PHP?

text: CodeIgniter has a very nice feature called a Profiler, which displays information at the foot of a page, information such as GET, Memory, POST data. It also shows database queries and how long they took to run which I find very useful. I have recently taken over a legacy PHP application and it would help a lot to see what tables in the database are being queried by PHP pages. Is there a library for raw PHP applications that could produce something similar to CodeIgniter's Profiler? I am already using xdebug, I am only interested in profiling database queries.


title: Loop fusion example using aspect-oriented framework

text: I had recently read a paper 'Aspect-Oriented Programming' by Gregor Kiczales and others, and found there _the loop fusion_ example. Here is a definition of the loop fusion from the paper > …the loop fusion composes by fusing the loops of those primitive filters > that have the same loop structure and that are direct neighbors in the data > flow graph. Each of these composition rules is easy to understand when > looking at its own appropriate picture. But the two composition relation- > ships cut each other so fundamentally that each is very difficult to see in > the other’s picture. Later in the paper _loop fusion_ mentioned to be implemented using metaobject protocol at Lisp: > …the loop fusion aspect … can be implemented, with some degree of > efficiency, using the method combination facility in the CLOS metaobject > protocol What does _loop fusion_ look like using any modern aspect-oriented frameworks in either static or dynamic typed languages? I'm looking for examples of aspect language and advices that could do _loop fusion_. ### Status for mid-January'13 As long as there is no any other answer, I have marked my own answer as an answer. Anyway I'm still looking forward for examples from other languages/frameworks. **ps** : _loop fusion_ discusion at "AOP in .NET" book's forum @manning forum


title: How would type errors be detected while creating mocks in a dynamic language?

text: The problem occurs while doing TDD. After a couple of test pass, the return types of some class/module change. In a statically typed programming language, if a previous mocked object was used in the tests of some _other_ class and was not modified to reflect the type change, then compilation errors will occur. For dynamic languages however, the change in return types might not be detected and the tests of the _other_ class will still pass. Sure there might be integration tests that should fail later on, but unit tests would erroneously pass. Is there any way how to avoid this? Updating with a trivial sample (on some made up language)... Version 1:               Calc = {         doMultiply(x, y) {return x * y}     }     //.... more code ....          // On some faraway remote code on a different file     Rect = {         computeArea(l, w) {return Calc.doMultipy(x*y)}     }          // test for Rect     testComputeArea() {          Calc = new Mock()         Calc.expect(doMultiply, 2, 30) // where 2 is the arity         assertEqual(30, computeArea)     }      Now, on version 2:               // I change the return types. I also update the tests for Calc     Calc = {         doMultiply(x, y) {return {result: (x * y), success:true}}     }      ...Rect will then throw an exception on runtime, yet the test will still succeed.


title: Interpreting Others' Source Code

text: Note: I am aware of this question. This question is a bit more specific and in-depth, however, focusing on reading the actual code rather than debugging it or asking the author. As a student in an introductory-level computer science class, my friends occasionally ask me to help them with their assignments. Programming is something I'm very proud of, so I'm always happy to oblige. However, I usually have difficulty interpreting their source code. Sometimes this is due to a strange or inconsistent style, sometimes it's due to strange design requirements specified in the assignment, and sometimes it's just due to my stupidity. In any case, I end up looking like an idiot staring at the screen for several minutes saying "Uh..." I usually check for the common errors first - missing semicolons or parentheses, using commas instead of extractor operators, etc. The trouble comes when that fails. I often can't step through with a debugger because it's a syntax error, and I often can't ask the author because he/she him/herself doesn't understand the design decisions. How do you typically read the source code of others? Do you read through the code from top-down, or do you follow each function as it's called? How do you know when to say "It's time to refactor?"


title: What are the challenges in building a scalable real-time web app?

text: I'm looking into real-time web applications using websockets and node.js. I'm interested to see what are some technical challenges with scaling such a setup. One such problem I've heard is that each socket requires a Unix file descriptor, and epoll/select takes time linear to the number of open file descriptors. Anyone have other insights into scaling?


title: To learn a new language/framework, which way is better?

text: For learning a new language or framework , is it better to learn by working with someone else on an existing project or creating a new one myself? I had experience on working on a open-source rails project for four months. The project was nicely written, and it has lot of good examples for me to learn, but I didn't get too much of rails in the end. At the end, I was still confused by many rails/MVC concepts. On the other hand, after that rails project, I myself started creating a ASP.net MVC from scratch. I ended up successfully building a fully functioning MVC web site and used a lot of ASP.net MVC features. I had a way better idea of MVC and ASP.net MVC's mechanisms after this project, but meanwhile, I might have employed many bad solutions without even realizing it. So which way do you think is better for learning? What are the pros and cons for each approach?


title: Semantic or structure - which should get preference for variable naming?

text: We've a call stack in our project. The program is written for microcontroller, the language is C. The call stack is basically an array of integers. The variable that represents this call stack ends with the string `_stack`. I was reviewing the implementation. The feature is reset recovery, not the call stack, but the call stack is part of the feature. When I first saw the variable, I thought it is used as a stack. So I assumed the following:   * No entries other than the last entry can be accessed.   * There will be PUSH/POP/CLEAR/TOP operations. Next, I found that the first entry (index 0) is always checked in a special condition. I also found a function where all elements of the array are read sequentially from index 0 to top. Both of them are invalid stack operation. I am thinking that the variable name should not contain the string `stack` as it is not a stack, rather it is used as a list. But the coder is showing valid logic, that according to semantic meaning, it's a stack and there is in fact PUSH operations. Should the variable be named with `*stack*`?


title: Do I have to internationalise the display of hexadecimal values?

text: For decimal numbers, obviously I want to localise everything. Whatever programming language I'm working in, there will tend to be tools for this, so it's also easy to do. In my application, I happen to be formatting numbers as hexadecimal quite often. This leads me to wonder:   * Are there locales which group hexadecimal numbers into different groupings to me?   * Are there locales which use a separator other than space for the groupings?   * Are A-F used as the extra six digits even in locales which don't use a Latin script? I guess in general - do I have to internationalise this, or does everyone in the world look at the same hexadecimal value and intrinsically understand it the same way?


title: Implementing the Visitor Pattern for an Abstract Syntax Tree

text: I'm in the process of creating my own programming language, which I do for learning purposes. I already wrote the lexer and a recursive descent parser for a subset of my language (I currently support mathematical expressions, such as `+ - * /` and parenthesis). The parser hands me back an Abstract Syntax Tree, on which I call the `Evaluate` method to get the result of the expression. Everything works fine. Here is approximately my current situation (Code examples in C#, although this is pretty much language-agnostic):               public abstract class Node     {         public abstract Double Evaluate();     }          public class OperationNode : Node     {         public Node Left { get; set; }         private String Operator { get; set; }         private Node Right { get; set; }              public Double Evaluate()         {             if (Operator == "+")                 return Left.Evaluate() + Right.Evaluate();                  //Same logic for the other operators         }     }          public class NumberNode : Node     {         public Double Value { get; set; }              public Double Evaluate()         {             return Value;         }     }      However, I would like to decouple the algorithm from the tree nodes because I want to apply Open/Closed Principle so I don't have to reopen every node class when I want to implement code generation for example. I read that the Visitor Pattern is good for that. I have a good understanding of how the pattern works and that using double dispatch is the way to go. But due to the recursive nature of the tree, I'm not sure how I should approach it. Here is what my Visitor would look like:               public class AstEvaluationVisitor     {         public void VisitOperation(OperationNode node)         {             // Here is where I operate on the operation node.             // How do I implement this method?             // OperationNode has two child nodes, which may have other children             // How do I work the Visitor Pattern around a recursive structure?                  // Should I access children nodes here and call their Accept method so they get visited?              // Or should their Accept method be called from their parent's Accept?         }              // Other Visit implementation by Node type     }      So this is my problem. I want to tackle it immediately while my language does not support a lot of functionnality to avoid having a bigger problem later. I did not post this to StackOverflow because I don't want you to provide an implementation. I only want you to share ideas and concepts that I might have missed, and how I should approach this.


title: Determinining "value" in multi-agent microeconomical simulation

text: I am trying to determine an objective way for a self-interested agent to calculate the optimal buying/selling price for goods in a multi-agent simulation not dissimilar to Sugarscape (http://en.wikipedia.org/wiki/Sugarscape). The simulation is as follows: Each agent has a stock of food F, a stock of money G, a certain amount of "energy", E, and a position (x, y) on a square grid. Moving from one square to a neighboring square expends A units of energy, and energy is naturally expended at a rate of B units per simulation day. An agent has the following options available to it during each day: consume a unit of food to increase its energy by Q units; move to another location (provided it has sufficient energy), "forage" for food (expend P units of energy to obtain a [possibly unknown] quantity of food), or trade with a neighboring agent for a mutually- agreeable price. Each agent's goal is to maximize its "utility function" U(E, F, G) without regard for that of other agents. Right away, this seems to give a base "use value" of food: Vuse = U(E + Q, F - 1, G) - U(E, F, G), but if this was the whole story, this wouldn't be an interesting problem. It seems the most general (but exponential-time) solution would look something like this:               Function SearchActions(State S):         Add(consume food) to action set         Add(forage for food) to action set         For each other agent A             For each possible trading price P                 Add(trade with A at price P) to action set         For each action X in action set             S' = Apply X to S             SearchActions(S')         Return optimal X     End function      However, the major difficulty gets swept under the rug by "for each possible price", because the price that agent A will buy/sell for is itself dependent on an identical calculation...e.g. My calculation of the value depends on either what I can get from using it myself, or what someone else will pay for it...but what they will pay for it depends on what I will pay for it. How do you cut this knot? I know this problem has been solved before...but I cannot find any references to it, let alone any actual implementations. The closest I've come has been a paper about "Strategic Planning" in SugarScape, but it only seems to give the results of the planning, rather than explaining how the planning is done.


**Do not declare interfaces for immutable objects** [EDIT] _Where the objects in question represent Data Transfer Objects (DTOs) or Plain Old Data (PODs)_ Is that a reasonable guideline? Up to now, I've often created interfaces for sealed classes that are immutable (data cannot be changed). I've tried to be careful myself to not use the interface anywhere where I care about immutability. Unfortunately, the interface begins to pervade the code (and it's not just my code I'm worried about). You wind up being passed an interface, and then wanting to pass it to some code that really wants to assume that the thing being passed to it is immutable. Because of this problem, I'm considering never declaring interfaces for immutable objects. This might have ramifications with respect to Unit Testing, but other than that, does this seem a reasonable guideline? Or is there another pattern I should be using to avoid the "spreading- interface" problem I'm seeing? (I'm using these immutable objects for several reasons: Mainly for thread safety since I write a lot of multi-threaded code; but also because it means I can avoid making defensive copies of objects passed to methods. Code becomes a lot simpler in many cases when you know something is immutable - which you don't if you've been handed an interface. In fact, often you can't even make a defensive copy of an object referenced via an interface if it doesn't provide a clone operation or any way of serialising it...) [EDIT] To provide a lot more context for my reasons for wanting to make objects immutable, see this blog post from Eric Lippert: http://blogs.msdn.com/b/ericlippert/archive/tags/immutability/ I should also point out that I'm working with some lower-level concepts here, such as items that are being manipulated/passed around in multi-threaded job queues. These are essentially DTOs. Also Joshua Bloch recommends the use of immutable objects in his book Effective Java. * * * **Follow Up** Thanks for the feedback, all. I've decided to go ahead and use this guideline for DTOs and their ilk. It's working well so far, but it's only been a week... Still, it's looking good. There are some other issues relating to this that I want to ask about; notably something I'm calling "Deep or Shallow Immutability" (nomenclature I stole from Deep and Shallow cloning) - but that's a question for another time.


title: How do IDE-s provide auto-completion, instant error checking and debugging?

text: Say you have a language compiler you would like to build an IDE for. How is auto completion, instant error reporting while writing code and debuggers commonly implemented?


title: Best ways to generate an embed code

text: I am developing a small web application in CakePHP which allows user to create contents using tools I provide. Once user is done creating the contents, I want to give an option to embed that in her own website. There are 2 ways I can think of right now to do this   1. Using iFrame embed code    2. Giving unique link to that content Are there any better ways to generat an embed code? Later on I would also like user to give style (css etc) to the contents she has created.


title: Is Emailing waste of time in Dev Teams

text: I know its not strictly related to what people ask here but I have to ask this anyway. Isn't having long conversations/discussions over emails reduce one's productivity. I have joined this new company where people prefer emails **alot**. It's not a big company so every one is accessible to everyone and also senior techies tend to get together for a 30 mins session every day to discuss and plan things with managers and stake holders. I think emails are great and should be used as long as they are to the point and don't waste anyone's time. In my professional experience getting or agreeing things over emails quickly becomes an endless game of ping-pong. Reaching to a conclusion often takes days just because.. oh well..not everyone has enough time to go through lengthy emails. Email subjects often become less subjective and more _"re:re:re:re:fw:"_. After few _"re:re's"_ and _"fw:fw's"_ it becomes a nightmare to find what you're looking for since not every single thing in emails is a key-point so coming back to conversation after 8-9 months is like going through someone's source code writen in C. It's also not the best approach for discussing ideas or agreeing over things as most people tend to be more reserved in email conversations than they are in real life because it's very easy to misinterpret one's tone. Most of the times I find it much easier and quicker to send an email saying "Lets discuss thing X at xx:xx" followed by a quick call at agreed time rather than dragging the issue for days (or in some cases weeks). When needed I follow up with an email saying "well here's what we agreed on the phone". Also people are generally more respectful to each other and open to discussions when talking face to face or over the phone. Don't get me wrong, emails are important and should be used whenever they are absolutely necessary. But in small/medium sized teams why is this culture (of writing long stories i.e. emails) so so important ? why don't people use tools like Basecamp, redmine, wiki's instead. How would you improve your team or company's communications so people become more productive and create a friendly environment. Thank you for reading.


title: Portfolio and NDA

text: So, working with NDA's prevent you from mentioning the projects in your portfolio.   * What is the way to deal with it?    * How would one showcase his experience in this scenario?  For example, I've worked on several complex iphone applications, since 2 years, and I cannot even mention the app store url's in my resume/online profile to those apps due to NDA? Does my experience go waste?


title: How to do data synchronisation between two applications?

text: Our client has a CRM application (let's call it `A`) and a custom built Windows application (VB.NET) (let's call it `B`) that directly writes to and reads from the CRM database. Application `A` is used (mainly) to manage clients and their orders. Application `B` is used to manage all the products our client sells. Our client wants us to build a webshop (`C`) using ASP.NET WebForms so they can sell the products they manage with `B`. All of their clients and orders should be present both in `A` and in `C`. Since `B` will take care of all the communication to `A`, will have to come up with a way to let `B` and `C` synchronise their data. This is something relatively new to us. We have done something like this in the past, but I really don't like the way it was solved there: > When someone orders something in the webshop, **C** puts the order in an > XML-file, zips the XML-file and sends it to an FTP-server in the network of > **A**. **A** monitors the directory on the FTP-server, unzips each new file, > processes the XML, creates a new XML-file, zips it and sends it to an FTP- > server in the network of **C**. **C** monitors the directory on the FTP- > server, unzips each new file and processes the XML. > > In addition to this, each night **A** generates an XML-file for each table > in its database, zips them and sends them to the FTP-server in the network > of **C**. **C** unzips the files and lets SSIS process the XML-files to > update the database of **C**. I _really_ don't like that. There must be other ways, right? We probably need single record sychronisation and batch synchronisation. How is this usually tackled? Webservices? Something custom like Rhino ETL? Something else? **Update:** It would be nice if you could also give a short explanation of how the technology you propose is typically used and how it impacts the different applications.


title: How does a Scrum team account for infrastructure tasks in the planning meeting?

text: How does a Scrum team account for dev/infrastructure tasks in the planning meeting? At first glance, they do not seem like user stories since they do not deliver end user value. However, attaching them as tasks to a particular user story sometimes does not make sense either. For example, say the task is: "Setup Bamboo." That task is not required to complete any user story since the team could manually build and deploy. So attaching it to a user story does not make sense since this task is not required to complete the user story. So, then, this suggests that these tasks become user stories. But then, if the team story points them, then this changes the velocity which is odd since the Product Owner wants to know the velocity against his backlog, not against his backlog with a bunch of technical user stories attached to it.


title: What's a good book to help non-technical management understand software development?

text: If you have some non-technical people managing your software development team, is there a book you'd want them to read to understand the process better? For example, in most work, you can pretty well estimate how long a task will take. But in development, the whole point is that you have to figure out the problem, which takes unknown time. This is hard to communicate. Anything you know of that explains this well?


title: The worst anti-patterns you have came across

text: What are the worst anti-patterns you have came across in your career as a programmer? I'm mostly involved in java, although it is probably language-independent. I think the worst of it is what I call the **main anti-pattern**. It means program consisting of single, extremely big class (sometimes accompanied with a pair of little classes) which contains all logic. Typically with a big loop in which all business logic is contained, sometimes having tens of thousands of lines of code.


title: How to use apache license in my project which will be LGPL

text: I want to use LGPL for my project, can I use some source code which is apache licensed ? If I only use the apache licensed component as library in my project, how should I make the clarification in my project ? Do I need to put some information about apache license at the beginning of source code which uses the library?


title: WCF Versioning, Naming and Endpoint URL

text: I have a WCF Service and a Main Lib1. Say, I have a Save Profile Service. WCF gets data (with predefined data contract) from client and pass the same to the Main Class Lib1, generate response and send it back to client. **WCF Method : SaveProfile(ProfileDTO profile)** **Current Version 1.0** ProfileDTO have the following UserName Password FirstName DOB (In string yyyy-mm-dd) CreatedDate (In string yyyy-mm-dd) **Next Version (V2.0)** ProfileDTO have the following UserName Password FirstName DOB (In UnixTimeStamp) CreatedDate (In UnixTimeStamp) **Version 3.0** ProfileDTO have the following (With change in UserName and Password length validation) UserName Password FirstName DOB (In UnixTimeStamp) CreatedDate (In UnixTimeStamp) In simple we have DataContract and Workflow change between each version 1\. How do I name the methods in WCF Service and Main Class Lib1? 2\. Do I have to go with any specific pattern for ease development and maintenance? 3\. Do I have to have different endpoints for different version? In the above example I have a method named “SaveProfile”. Do I have to name the methods like “SaveProfile1.0”, “SaveProfile2.0”, etc. If that is the case when there is no change between Version “3.0” and “4.0” then there will difficult in maintenance. I’m looking for a approach that will help in ease maintenance


title: A few clarifications about the DOM

text: I have been trying to understand the DOM, and although I have a fair idea of what it is, there are certain ideas I just cannot pin down. I will list down what I think the DOM is and my questions will be inline.   1. The DOM is a fully object-oriented representation of the web page. The W3C DOM standard forms the basis of the DOM implemented in most modern browsers. _So does the DOM talk about how an XML/HTML document is represented as an object model?_   2. The DOM does not specify that documents must be implemented as a tree or a grove, nor does it specify how the relationships among objects be implemented.  _In what other ways can the document be represented?_   3. When you do something like this -              document.write('welcome to my home page!');      the document object is provided by the DOM. The write methods are the interfaces that are exposed to JavaScript by the DOM. _So the objects and its methods are created as JavaScript objects by the DOM parser and then presented to the JavaScript engine? Or are the objects and methods within the DOM parsing engine in their own native language? And is exposed to the JavaScript engine? If this is so, then what is responsible for translating from JavaScript to the native language?_   4. What are language bindings ? The language binding is the set of objects native to the language in question that implements each of the interfaces in the DOM specification. Developers can create language bindings from the DOM to their language simply by following the IDL (Interface Definition Language) in the DOM specification. _So if the DOM parsing engine is implemented in say C++, does that mean that when you create language bindings by following the IDL, you are just creating objects in the specific language, i.e C++ that your DOM parsing engine is built with?_


title: Can you learn enough programming in 2 years to get good entry level job?

text: I have studied 2 out of 4 years in college, mainly math and physics so I am fairly technical. For some reason I have never really learnt to code before last month. And I was so thrilled and I am going to concentrate my last 2 years in college solely for learning to program. My question is: If I study like a Mad Man my last 2 years before graduation can I learn enough programming to get a good and reputable entry level software engineer job/intership. And by reputable I mean something like Microsoft, Apple, Facebook, Google, IBM, Oracle etc. Is it possible to start from scratch and learn in 2 years enough skills to make it?


title: SQL Table Design Modification based on data roles or implementation convenience?

text: I've got an existing SQL table structure that looks like this:               Orders     - order_id     - organisation_id     - [all the rest of the order data]          Organisations     - organisation_id     - [all the rest of the organisation data]          Users     - user ID     - [all the rest of the user data]      I'm trying to change the `Orders` table so that an Order can be linked to either an `Organisation` or a `User`. I've got two ideas: ### Option A   * Add field `orders.user_id`, and then set either `user_id` or `organisation_id` to null for each order, indicating whether the order was placed by a user or organisation. ### Option B   * Add a table `orderers` (or similar) and then add fields `organisations.orderer_id` and `users.orderer_id`. Then, users and organisations are both orderers, and orderers place orders. ### Evaluation Option B's role-based approach seems to make good sense and seems to be more extensible, but I just can't help but think about the hassle the extra `JOIN`s are going to cause, in terms of performance and SQL complexity. What is the best way to go about this?


title: How to code in a more functional style in Java?

text: I code Java for at least 5 years now and I really appreciate how the language works. When looking at new JVM languages (e.g. Scala, Clojure) there is a trend to more functional ways to code and this way has some major advantages. Anyway, are there patterns to achieve a more functional style even when using Java or other pure OOP? And does this make sense in Java?


title: Graph to show decreasing desirability when taking shortcuts

text: I'm responsible for creating a presentation to management that details how a system should be refactored or rewritten. We have an existing system that has had production failures and the code base is not in a desirable state. Here are the current possible options:   1. Rewrite the system using developers that provide the best code quality   2. Rewrite the system using developers that write less-than-ideal code quality   3. Leave the system as is and just maintain it   4. Rewrite the system using cheaper labor on the other side of the world The issue isn't which one to choose, because I believe #1 provides the best long-term value to the business. The issue is how to present this to management so they understand the costs to each shortcut they take from #1. For example, I would start with presenting #1... then what? My original idea is to somehow show each shortcut and what that means in terms of long-term cost/benefit. So, perhaps management wants to use cheaper labor. I need to show what that does to quality, time, etc. How do I show that? Perhaps management wants to use a hybrid of the above options. How do I show that? There could be 20 different permutations of the above options, and I'd like to show that if they take the short-term approach of low-cost everything, what that eventually means to the quality of the product. Are there graphs for this type of thing? A recommended approach? I could just start typing, but I don't want management's eyes to glaze over from too many words. Hope that all makes sense. An idea is to present something like this for each option: ![enter image description here](http://i.stack.imgur.com/qbsrs.png)


title: Who coined the term "performant?"

text: We all know that it's not a real word. But it is commonly used among programmers, and could probably be thought of as a "technical term." It might pass into common usage and make its way into the dictionary, if enough people use it. Wiktionary defines _performant_ thusly:   * **performant** (comparative more performant, superlative most performant)     1. (jargon, chiefly computing) Capable of or characterized by an adequate or excellent level of performance or efficiency. Ours is a performant network monitoring and systems monitoring tool. "This software is ten percent more performant than its predecessor." God knows why I want to know*, but fifteen minutes of searching later I still don't know who is considered the person who coined the term "performant" in software engineering? Who was the first person to use it? *That's not necessarily true. I suspect it's because 10am on Monday in the US and I'm ready to head home.


title: Browser as a rich client platform

text: In Java there is a notion of "rich client platform" - it's a framework for building desktop applications, provides common features like help browser, window layout management, etc. Prominent frameworks are Eclipse and Netbeans. Now I am curious if something like that can be done on top of web browser? I heard about XULRunner, Chrome extensions, NPAPI and such but hesitant to dive further (my current idea is to fork Chromium). Basically, is there a way from a (serverless) browser application:   1. Work with filesystem (Open/Save/open OS file browser)   2. Start OS processes (e.g. some utilities) and parse their output.   3. Access dynamic libraries.   4. Alter browser UI (e.g. remove home/address bar, redo menus)   5. Package as something easily deployed throw the app stores. Can this be done without forking the browser? What should I read about? **Updated Requirements:** Essentially I am looking for "PhoneGap for PCs" - but I really like how I could reuse Chromium UI (tabs, preferences, etc) if I forked it. I'm prototyping on Mac, will setup a Linux build. I am not interested in Windows at this point...


title: The better way to ask for input?

text: I am wondering which is the best way to go with java code. I need to create a class with simple prompts for input.. I have tried using both classes and cannot work out the particular benefits for each. Is this because I am still in the early stages of programming or are there situations that will occur as it becomes more complex??               import java.util.Scanner;          public class myClass     {         Scanner stdin = new Scanner(System.in);          public String getInput(String prompt)        {             System.out.print(prompt);             return stdin.nextLine();         }      ... or               import java.io.*;          public class myClass     {         public static void main(String[] args) throws IOException         {             BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));             System.out.print("Input something: ");             String name = stdin.readLine();      I know these examples are showing different methods within these classes, but thought this might serve well for the discussion. _I'm really not sure which site is the best to ask this on._


title: Continue working full time on projects or get a job for appearances on resumé?

text: Current situation: About five months ago I got a degree in something that has nothing to do with programming. Since then I have been intensively studying/working on programming projects the last five months. **(A) Do I continue working full time on projects progressing at a fast rate likely having finished decent enough projects to land a starter position/payed internship in 3 months** or **(B) do I get a job, almost surely one that has nothing to do with programming, merely so employers can see on my resumé that I did a job in between and significantly reduce my progress in programming?** I assume that HR interviewers from large companies would see my unemployment as a bad thing but on the other hand it's very unlikely I would even apply for a job for such company anyway because they almost always seem to require a related degree. But I am not sure how other employers would interpret the situation. Btw, I am talking about the western european job market, not the american job market. Also, I have learned WAY more in those 5 months on my own than in those three years altogether in university college. ## EDIT I am actually convinced that the best step is to continue working full time on those projects because I think that there is a significant number of employers of small companies who can look past unemployment on my resumé as long as I can present them with projects I have worked on. But my father fears no employer will be able to look past the fact I have not done an actual job in that period, regardless if it programming related. **I want to show my father this SO thread to convince him otherwise**. So can any employers or employees of such employers please state if my father's suspicion is correct or not. This has a great influence in my current living situation so it is important for him to understand that.


title: Compiler time versus programmer time

text: I want to briefly discuss managed or interpreted languages. It's said that they're worth developing in, because the CPU time is worth less than the programmer time required to develop in a faster language. I'm curious if the same thing could be said for the compiler. If I had some mythical compiler that took four times as long to compile as, say, C#, but took half the time to program with, would that be an advantage or a disadvantage? Is programmer time worth more than compiler time?


title: MIT License - possible to steal code?

text: Say your company has some closely-guarded internal software that happens to have an MIT License. Maybe it was based on MIT Licensed software but has been heavily modified over the years. Your company does not want to share it with the outside world. However, one day an employee decides to post the software up on GitHub against the wishes of the company. Is this legal? Does it violate the license?


title: Name for this pattern?

text: I'm writing a class that will handle thread synchronisation. It would have a begin method which would increment a counter and an end method that would de-increment a counter. It'll have another method which will block while the counter is not zero, then perform an action while holding the lock. Its a bit like the opposite of a semaphore, because it's unlocked at zero, and can get locked multiple times, only becoming unlocked again once it's been unlocked an equal number of times. Is there a name for this pattern? * * * It's a class based on the accepted answer of my question here


title: Why companies don't buy developers entertaining instruments?

text: Many times when I get tired of development and my mind doesn't really help me any more (at home), I simply do something entertaining and my mind gets free for more hours of work with higher problem-solving capacity. However, when I recommended this technique to my manager as a technique to increase developers productivity and efficiency, he refused to accept on the ground that work is not the place for entertainment. I think this formula works for me. Is it true for other developers too:               2 hours of productive work + 30 minutes of entertainment > 3 hours of dull work      Why companies don't believe in it? **Update:** I don't know why this has been closed as off-topic. Please if you feel that this is relevant, vote to reopen it.


title: what is need for a handler in general

text: I have been searching for a definition for handler. basics i've understood that "A handler is a piece of code that is called when something happens, and usually takes some action, like generating a response." - (from http://stackoverflow.com/questions/3246200/what-is-an-handler ). But that can be a trigger or a callback. Also in specific an event handler on a low-level , often works by polling a device and waiting for a hardware response. So, what is the specific role of a handler ( that makes it unique from a trigger or a callback or any other such function ). Do all handlers have similar role ( event handler, file handler , exception handler, error handler )...


title: How easy is it to hack JavaScript (in a browser)?

text: My question has to do with JavaScript security. Imagine an authentication system where you're using a JavaScript framework like Backbone or AngularJS, and you need secure endpoints. That's not a problem, as the server always has the last word and will check if you're authorized to do what you want. But what if you need a little security without involving the server? Is that possible? For example, say you've got a client-side routing system and you want a concrete route to be protected for logged-in users. So you ping the server asking if you're allowed to visit protected routes and you go on. The problem is that when you ping the server, you store the response in a variable, so the next time you go to a private route, it will check that if you're already logged in (no ping to the server), and depending on the response it will go or not. **How easy is for a user to modify that variable and get access?** My security (and JavaScript) knowledge isn't great. But if a variable is not in global scope and is in the private part of a module pattern which only have getters but not setters, even in that case, can you hack the thing out?


title: How is dependency injection not just moving the complexity into a separate class?

text: I've been looking into using the Typhoon framework for dependency injection this week. I get that separating the construction of objects is beneficial for replacing arbitrary components with mocks during unit testing, and so far I have seen benefits from this alone. But I cannot help but think that where before I had a humongous view controller class that had tens of header imports, I now have a humongous factory class that has tens of header imports. Am I supposed to avoid having a massive factory class?


title: Implementing a priority queue with a circular array

text: [If this fits more to stackoverflow then transfer it there please.] Hi, I'm trying to implement a priority queue in C. The easiest way I found to do it is with a circular array (rather than using a linked list). I have an array of fixed size, the index for the `first` element in the queue and the index for the `next` free place in the queue. But I'm struggling with dequing the maximum value... I know how to get the maximum value, but not how to move next and first so that the queue stays contiguous in the array (the only way I know of it working). How should I do this? Or do you have a suggestion for a better implementation? Thanks


title: How to certify an electronic vote?

text: I'm developing a simple 'voting' system for any type of group (political, working team). I was wondering what could be a good system to 'certificate' the votes? For example, a simple db structure is:               PollID, UserId, ChoseID (what user chose), DateTime      What can I do to certify that the vote has not been tampered with? Adding a KEY field resulting from an algorithm? Anything else ?


title: Call GPL software from non-GPL software

text: Can I (legally) use a program that is released under GPL from another program that I'm writing and not have to respect the GPL (for the program I'm writing)? For example, I have a GUI that uses a program (which is under GPL), can I hide the code in the GUI and even sell it?


title: Calling a GPL binary from command line

text: I developed some software which I sell / closed souce. There is a GPL executable I would like to call/execute from within my software (and use the data returned by it) _if_ users download the executable themselves and tell my program the path where to find it. (Hence, I do not want to distribute neither source, nor binaries of the GPL tool.) If I understood this correctly, I am therefore not linking in any way. The GPL tool will only constitute a very tiny part of the overall functionality and probably only be useful (and not likely mandatory) to less than a percent of my users. (Rough estimate.) Hence, by my understanding, I should be able to do above without further problem, i.e. I will not need to: \- Mention anything in my readme/similar since user downloads the GPL executable himself form the official site - my software will point to it, so the user can find it there) \- My own software can stay as it is (closed source, commercial) Am I correct in above?


title: Passing two different types down a chain of calls because of an overload further down

text: I've got myself into a bit of a mess. I've got code coming from Main, through myMethod and down to OtherMethod. One of the parameters can be either an int or a string, which affects OtherMethod but none of the intervening methods.               public static void Main()     {         myMethod(number: 10);         myMethod(letters: "ten");     }          public static void myMethod(int number = 0, string letters = null)     {         //long entirely shared code with calls to:         OtherMethod(number,letters);     }          public static void OtherMethod(int number = 1, string letters = null)     {         //Lots of shared code, embedded multiple times within this code is essentially:         if (letters != null)         {             Console.WriteLine("letters!");         }         else         {             Console.WriteLine("numbers!");         }     }      OtherMethod cares about when I'm passing it `int` or `string`, but none of the intervening methods care. I would also find splitting OtherMethod without unnecessary code reuse very hard. The solution I have provided works, but is probably an anti-pattern. Because, for example, a call to `myMethod(10,"ten")` would silently throw `10` in the bin. Would changing it to `private mymethod(int number = 0, string = null)` called by `public (int number)` and `public (string letter)` for each level be a terrible idea? I though of instead passing a class with both int and string and instructions of which to use right from the top to bottom. I suspect this is the solution. But it feels as OTT as it does OO. My real use case is that I'm randomly generating data at the bottom of this chain and I can either provide a seed (int), or cheat and provide the data to generate (string). It occurs to me that what I'm doing may be a procedural dependency injection bodge,


title: Programming for future use of interfaces

text: I have a colleague sitting next to me who designed an interface like this:               public interface IEventGetter {              public List<FooType> getFooList(String fooName, Date start, Date end)             throws Exception;         ....          }      The problem is, right now, we are not using this "end" parameter anywhere in our code, it's just there because we might have to use it some time in the future. We are trying to convince him it's a bad idea to put parameters into interfaces that are of no use right now, but he keeps on insisting that a lot of work will have to be done if we implement the use of "end" date some time later and have to adapt all the code then. Now, my question is, are there any sources that are handling a topic like this of "respected" coding gurus that we can link him to?


title: handling online payment for items with one quantity - design issue

text: I would like to implement a robust way to handle ecommerce payment for items with limited quantity, like for example exclusive paintings. Payment would ideally be accepted via PayPal and credit cards. Ideally, it would work on a 'first-come-first-serve' basis, and wouldn't just lock items out if you add them to cart like some online fashion stores do. However, the main problem is that once you redirect the user to the payment solution, you do not have control over the user. Even if I was to implement some form of locking on items, i.e a user adds it to cart and it is temporarily locked for other users for say 30 minutes - I think this problem would still prevail given the below workflow:   * User A adds item A with limited quantity (1) to cart. Item is removed from website for 30 minutes   * User A goes to payment on PayPal.    * For some reason, UserA does not pay immediately on PayPal but keeps session alive for say 1 hour   * After 30 minutes, website will restore item A back in stock   * User B adds to cart   * User B proceeds to payment   * User B pays for item   * User A, with the continuously refreshed session, pays for item as well. This would result in double-purchase for the same item. Is it possible to solve this problem 100%? I highly doubt this would happen in real-life, but would like to handle all possible cases.


title: How to invoke a method in a class always when the class is accessed - like a reaction?

text: I am working on a C# net micro framework project, in particular an I2C bus class. I have several different I2C devices each defined in separate classes which contain all of the devices' unique methods. In my case, I can only have ONE I2CDevice object defined and to switch to another I2C device, I have to change the I2CDevice.Config = DeviceConfig. For example (pseudo-code):               Class Device1      -DeviceConfig1     -Method 1     -Method 2     -Method 3          Class Device2     -DeviceConfig2     -Method 1     -Method 2     -Method 3               Main Program     {     I2cBus = new I2CDevice(configuration)     Device1.Method1     Device2.Method3     }      When switching between devices, I need to change the I2CDevice.Config property. I'm looking for an elegant way such that whenever I call a Method for a device, that the I2CBus.Config is automatically changed. Is there a way that I don't need to re-type this config code in each method? Have a separate internal method that's called each time I access any of those methods? I hope my description is clear. Update, As an alternative, is there a way I can have my make my I2C Bus class and then ADD the devices to the this class? Then To access The Devices, I would Do something like               I2CBus.AddDevice(Device1ObjectClass)     I2CBus.AddDevice(Device2ObjectClass)     I2CBus.Device1.Method1     I2CBus.Device2.Method2      I still have the same problem that I need to "automatically" switch the I2C configuration between Different Device calls.


title: Best way to create a web interface to query a particular database

text: I was asked to make a web application to allow users to query a particular database more easily. Simplifying, this database has only two tables, reports and products. The relationship between the two is that one report may refer to one or more products. The web application should allow users to specify in a graphic way (even in a simple form) a list of search criteria to retrieve a subset of reports. For example a user might ask for all reports in a certain period, with "(field1 = value1 and field2 = value2) or (field3 <> value3)", that refer to product A and product B. This is the description of the basic requirements; ideally the web application should also allow users to save and combine their queries (for example with "UNION, EXCEPT, INTERSECT"-like operators) and to dinamically order the results. Moreover, the products ca be grouped into hierarchical levels and a user might ask for all reports that refer to all products in a certain level. At this moment the reports table has only 114.000 rows but it's growing fast: it has existed for 27 years but 18.000 rows were inserted last year! So, my question is how to approach the development of this application. First of all, it is necessary to develop a NEW application or there is something I can use out-the-box (with some initial configuration, obviously)? If not, I believe I could write it myself with CodeIgniter and JQuery, but I would know if there are other PHP or JAVA frameworks or components useful to speed up my work. Finally I'd love to hear your opionion about the critical points I should worry about.


title: Book on network cryptographic protocols

text: I am looking for a book that describes in fair detail the most common network cryptographic protocols such as SSL, TLS, SSH, HTTPS, etc. I already have some books that cover the underlying cryptographic protocols (such as DES, AES, etc.). It's the next layer up that I am interested in learning about.


title: Ease the pains of unit testing C# when you are the only person on the team unit testing

text: I have ran into this a few times where you get put on a project and you want to do unit testing of some type, but the project isn't setup right to allow for this and you might not have buy-in from everyone. The main issues tend to be code smells like issues with dependencies (especially the over use of statics) and seperation of concerns. New code that you write can be setup easily, but anything that operates with other legacy code or even those not drinking the cool aide can become an issue. Some things that I have found are that isolation frameworks like TypeMock can make this easier. **What are some other tools/tricks/best practices that you have found that ease this sort of pain?**


title: Starting a coherent architecture in a legacy application

text: I have responsibility for a large Asp.Net based website. It is currently a website (not web application), some windows services and a number of class libraries. The data layer uses a mixture of LLBLGEN and Linq To LLBGen, as well as a number of instances of legacy inline SQL which have not been refactored. There are some manager type implementations, but in many cases the application exhibits the Smart UI anti-pattern (i.e. too much business logic in code behind classes) The site is reasonably high traffic, and performance is fine, but we are growing our development capability to a team of around 10, and increasingly it is clear we need an overarching layered design on top of the existing middleware. My question is where to start? We have 10 years of code (some of it still really just migrated ASP Classic stuff), many different approaches, and styles. Refactoring the entire code base is not realistic and, probably not desirable I know this is not a novel situation, are there any useful ideas or concepts as to how to approach this problem?


title: What are common Silverlight specific mistakes/pitfalls developers should avoid?

text: What are some common mistakes/pitfalls, specific to Silverlight development, that developers should avoid? PS: Please, if you don't have hands on experience with Silverlight and want to simply state that people should just not use it, refrain from doing so. Thank you for you time and consideration. Here is a compilation of input from users on both StackOverflow and programmers.stackexchange.com to this question:   * Thinking it's the same as WPF   * Not using the MVVM design pattern   * Not knowing that it doesn't support ADO.Net Connections   * Not knowing that it only supports basicHttpBinding (no wsHttpBinding allowed)   * Not knowing that RelativeSource bindings don't support AncestorType   * Forgetting to setup IIS MIME types   * Thinking that Silverlight works the same way as WPF   * 5mb limit on XAP files and the need for third party solutions to work around that   * Not abstracting out the service layer calls.  > Abstracting out the service layer calls so that the silverlight pages load > in the designer (either Visual Studio or Expression Blend) without the > presence of the service helps out. Especially if the UI is being designed in > Expression Blend. Some dummy data can be returned without calling the > service and the UI designers still get a feel for the look and feel of the > application with data.   * Not using MVVM > You can program Silverlight like a winforms app but you are in for a world > of grief. The whole platform was designed to use MVVM and if you don't work > with that you are going to be swimming upstream the whole way.   * **Networking:** there are limits on sockets, e.g. no UDP, only the async model   * **Networking:** two (3.0) different HTTP stack, the browser one and the client one - each has its own quirks (a lot of applications ends up using both);   * **Security:** some API are marked as [SecurityCritical] and you won't be allowed to use them, even if it will compile just fine, at runtime (e.g. but that code has been working for years in my other application)   * **Security:** security policies on HTTP[S] and sockets (but works so well on your own computer)   * ditran.net/silverlight-common-errors   * Using MVVM but not truely understanding it  > blindly obeying its principles as if they were the 10 commandments, some > people really make things hard for themselves I bet most don't have any > separate UI design team nor are using Unit tests, so the benefits of MVVM > would be minimal >   * Not grasping the Asynchronous nature of Silverlight. >   * Over using UserControls when they should be using a Templated control > > > Thank you for constructive input to the following people: Rachel, > maple_shaft, Jesse C. Slicer, ChrisF, Jon Raynor, poupou, RKitty, DShah, > AnthonyWJones


title: Why do we use hungarian notations on local variable but not on function or global variable?

text: That doesn't seem to make sense. In local variable, we sort of know the type anyway. It's local. We're working on it. Yet in function name or global variable, the definition is very far away on other files. It seems that hungarian notations make far more sense there. For example, in objective-c I used this               +(CGFloat) fHeightOfNavigationController      So when I want to know the height of navigation controller, I will need to press a button that specify the function. What's the button? What's the name of the function. Is it heightOfNavigationController? Is it NavigationControllerHeight? Is it navHeight? I don't know which letter I should type first to activate the autocomplete. But I know the function is float. So I just type f... Tada... I got fHeightOfNavigationController in autocomplete. Yet I don't think this is how most people use hungarian notation. Why?


title: TDD - what are the short term gains/benefits?

text: Quite often benefits of using TDD are considered as 'long term' gains - the overall code will be better structured, more testable, overall less bugs reported by customers, etc. However, where are the short terms benefits of using TDD? Are there any which are actually tengible and easily measureable? Is it important to have an obvious (or even not obvious by quantifiable) short term benefit at all, if the long term gains are measurable?


title: Any legal issue in developing app similar to others?

text: There is a game I want to develop for mobile devices e.g. cellphone/tablet. I have been looking for this game and couldn't find it so I decide to just do it on my own. But I'm worried that there will be legal issues. I'm sorry but I do not know what is the process in doing this. I noticed for example the game Bejeweled Blitz. If I develop something similar, do I have to contact the developer and ask for permission if I develop a game with similar rules but use shapes rather than jewels? The original game exists only on Windows for free. If I develop the game, exactly similar rules but different display, am I allowed to sell it? Thanks...


title: How do you create interest in your projects?

text: > **Possible Duplicate:**   >  Ideas to get you programming mojo back? Its almost 10 years for me working in Java based applications (mainly on Web). Sometimes I feel really bored of the regular work...same old problems, similar challanges etc. Since I work for a company that provides services to different customers, I change my domain from time to time, I get to know about some new things, but ultimately all are web applications and I really find nothing interesting after 6-8 months in a new project. I would like to know from experts, how do you make working in same technology interesting?


title: Is it the job of programmers to design the database?

text: I've been a programmer for the past six years. Throughout my career, I have worked on many web applications. Most of the time, when a database was needed, it was given to us (the programmers) or we had some legacy database to work on. If not that, we had to create and design the database on our own which was not that tough. But are we, as programmers, supposed to create the entire database from scratch when we have to build new application where data is so important and have messy requirements with a complex data model? Isn't it in the best interest of the app and the company to get it done by an expert? I am not trying to run away from designing the database, but it's a thing that is so important to get right.


title: Does commentary style affect how readers understand code?

text: This question has been obsessing me for the past 2 months. A while ago a friend who is a great programmer gave me some example codes, and for the first time I've noticed a unique style of organizing comments. He took some effort to design comments in a way that would make me more comfortable with the code itself. For example:               /////////////////////////////////////////////                                                   //                                             //     //  This code prints a basic "Hello world" //     // message to the console screen. You can  //     // change the text in the brackets.        //     //                                         //     /////////////////////////////////////////////          #include <iostream>          int main() {       cout << "Hello world";          }      when he could have simply written               /* This code prints a basic "Hello world" message to the console, change text in brackets */           #include <iostream>          int main() {       cout << "Hello world";          }      This kind of example only on a bigger scale. I find this a little unproductive in professional situations but in a learning situation, it seems ideal. The question here is, if comment style affects how the reader understands code. In my personal opinion option #1 is prettier to the eye and easier to follow than #2. Does the way you comment on code affect ones ability to comprehend your code, or is it just wasted time and space?


title: Is there a measure of code rot?

text: I'm dealing, again, with a messy C++ application, tons of classes with confusing names, objects have pointers into each other and all over, longwinded Boost and STL data types, etc. (Pause and consider your favorite terror of messy legacy code. We probably have it.) The phrase "code rot" oft comes to mind when I work on this project. Is there a quantitative way to measure code rot? I wouldn't expect anything highly meaningful or scientific, since no other measure of code productivity or quality is so fine. I'm not looking for a mere opposite of measures of code quality, but specifically a measure of how many bad things happened after a series of maintenance software "engineers" have had turns hacking at the code. A general measure applying to any language, or many languages, would be great. If there's no such thing, at least for C++, which is a better than average language for creating messes. Maybe something involving a measure of topology of how objects connect during runtime, a count of chunks of commented out code, how mane files a typical variable's usage is scattered over, I don't know... but surely now, a decade into the 21st Century, someone has attempted to define some sort of rot measure. It would be especially interesting to automate a series of svn checkouts, measure the "rottenosity" of each, and plot the decay over time.


title: What is the best/ethical way to estimate code clean-up?

text: I have been working on a product line since my senior year of college for my current employer. Now several years out of college I am in a position where I am giving estimates for change requests on this same produce line. Please note that our software lead still approves the estimates, but is hands off during the process. As my skill set continues to grow, I continue to see things which I can improve upon. The issue is how to get these changes funded. My current process is to clean up / refactor code if it touches an area that has an active change request. However the dirty sections of code that aren't part of an active CR are neglected and bug me more and more as the product line matures. To help clarify, I do not believe that the customer should pay for a full rewrite of the software, unless it is in fact cheaper to do so to meet new requirements. I do prefer the incremental changes to clean up bits of code. When submitting quotes / estimates, what is the best way to _ethically_ try and recapture the costs of code clean up? To elaborate further, what kind of padding is typical for general maintenance? Should it be based on lines of code, project complexity, or some other metric?


title: How is technical debt best measured? What metric(s) are most useful?

text: > **Possible Duplicate:**   >  How can I quantify the amount of technical debt that exists in a project? If I wanted to help a customer understand the degree of technical debt in his application, what would be the best metric to use? I've stumbled across Erik Doernenburg's code toxicity, and also Sonar's technical debt plugin, but was wondering what others exist. Ideally, I'd like to say "system A has a score of 100 whereas system B has a score of 50, so system A will most likely be more difficult to maintain than system B". Obviously, I understand that boiling down a complex concepts like "technical debt" or "maintainability" into a single number might be misleading or inaccurate (in some cases), however I need a simple way to convey the to a customer (who is not hands-on in the code) roughly how much technical debt is built into their system (relative to other systems), for the goal of building a case for refactoring/unit tests/etc. Again, I'm looking for one single number/graph/visualization, and not a comprehensive list of violations (e.g. CheckStyle, PMD, etc.).


title: Improving Cohesion and Coupling of Classes

text: I am given this set of code and need to suggest ways to improve the code's cohesion and coupling of the classes. But I thought these classes are quite well de-coupled since it looks like they are making use of events. And in terms of cohesion, all the init() calls are placed together, everything seems quite alright to me.               public class A     {         private C t;         private B g;         public static void main(String args[]) {             // Creates t and g.             t = new C();             t.init();             g = new B();             g.init();             g.start(this);         }         pubic void update (Event e)         {             // Performs updating of t based on event         }     }          public class C     {         public C() { ... }         public void init() { ... }     }          public class B     {         public B() { ... }              public void init() { ... }              public void start(A s) {             e = getNextEvent();             while (e. type != Quit)                 if (e.type == updateB)                     update(e) ;                 else                     s.update(e) ;             e = getNextEvent();         }              public void update(Event e) { ... }         }     }      Are there still ways to improve the classes cohesion and coupling? It looks ok to me but I think I am missing something out. Thanks for any suggestions on this.


title: Software Design for Product Verticals and Service Verticals

text: In every industry there are two verticals `Product Vertical` and `Service Vertical`, so my question is:   * How does design approach changes while designing Software for Product Vertical as compared to developing Software for Service Vertical ? What are the pros and cons for each case ? Also, in case of Product Vertical,   * How you go about designing Product or Features and what are steps involved ?  Lastly, I was reading How Facebook Ships Code article and it appears that Product Managers have very little influence on how Product is developed and responsibility lies mainly with the Developer for the feature.   * So is this good practice and why one would go for this approach ?    * What would be your comment on this kind of approach ?


title: You are or will be a laid off programmer - what do you do a year ago, right now, tomorrow, and next week?

text: Many programmers, software engineers, and other technology professionals are out of work, facing layoffs, or are unprepared for layoffs though they _feel_ secure right now.   * What should every programmer do right now (even if secure in their current job) to prepare them for layoffs down the road? If your boss came to your cubicle while you read this and laid you off:   * What would you do immediately after?   * What would you do tomorrow?   * What would you do next week? It obvious that one should always have an up to date resume, always get recommendations from people when they see you at your best (not when you're looking for a new job), etc. What are the things, step by step, that every programmer should do (or should consider doing) long before they are laid off, when they're laid off, and shortly after being laid off? This is a question with many possible facets. While I want to encourage discussion to center around programming career based answers, please reconsider before downvoting someone because they're thinking in terms of how they're going to prevent going into debt. **Bonus catch-22 type question:** You can study a new language or technology while out of work, but most places want you to have more than 1-2 months experience in a working environment, not just from a learning exercise. Is it worthwhile to place a priority on new (ideally in demand) skills, or should you instead hone existing skills?


title: How to describe your skill levels in the CV?

text: What are possible/standard words to describe your skill levels in different programming languages in your CV? I currently use these three:   * expert   * advanced   * beginner I do not consider myself an expert in any programming language, so I classify all my skills as either beginner or advanced. However, I would like to differentiate more. I am especially looking for something between _advanced_ and _expert_. Any suggestions? Or should I not even bother to differentiate any more detailed?


title: Why are IT and development job titles so cryptic?

text: I'm a new intern in a fairly large company's IT department. I've been learning a whole lot of stuff and I'm loving every minute of it. However, the more people I meet in the company, the less I understand their titles or the general title hierarchy. Here are some examples:   * Senior Designer   * System Architect   * Systems Analyst   * Systems Analyst II   * Technical Support Analyst II   * Infrastructure Operations To name a few. But from what I gather sometimes two people will have the same title and do 2 completely different things, whereas sometimes they will have different titles and do the same things. No more do I actually understand anything from the titles themselves.


title: Python — Time complexity of built-in functions versus manually-built functions in finite fields

text: Generally, I'm wondering about the advantages versus disadvantages of using the built-in arithmetic functions versus rolling your own in Python. Specifically, I'm taking in GF(2) finite field polynomials in string format, converting to base 2 values, performing arithmetic, then output back into polynomials as string format. So a small example of this is in multiplication: Rolling my own:               def multiply(a,b):         bitsa = reversed("{0:b}".format(a))         g = [(b<<i)*int(bit) for i,bit in enumerate(bitsa)]         return reduce(lambda x,y: x+y,g)      Versus the built-in:               def multiply(a,b):  # a,b are GF(2) polynomials in binary form ....         return a*b  #returns product of 2 polynomials in gf2      Currently, operations like multiplicative inverse (with for example 20 bit exponents) take a long time to run in my program as it's using all of Python's built-in mathematical operations like // floor division and % modulus, etc. as opposed to making my own division, remainder, etc. I'm wondering how much of a gain in efficiency and performance I can get by building these manually (as shown above). I realize the gains are dependent on how well the manual versions are built, that's not the question. I'd like to find out 'basically' how much advantage there is over the built-in's. So for instance, if multiplication (as in the example above) is well-suited for base 10 (decimal) arithmetic but has to jump through more hoops to change bases to binary and then even more hoops in operating (so it's lower efficiency), that's what I'm wondering. Like, I'm wondering if it's possible to bring the time down significantly by building them myself in ways that maybe some professionals here have already come across.