Switch Parent Children relationship in C#

Using C# and WPF I have a situation where my data is organized hierarchically. I am using a treeview to represent this :   * Group_01      * Object_01        * Material_01          * Texture       * Material_02          * Texture_02   * Group_02      * Object_02        * Material_03          * Texture_03 I would like to be able to switch the order of the hierarchy, for example be able to create the data starting from the Materials and know all the objects that use that particular material   * Material_02      * Object_01        * Group_01     * Object_02        * Group_02 What is it the recommended data structure to organize the data? And how I could switch easily between any of these visualizations?


What should a C programmer know?

What are some concepts/techniques/language features that every decent C programmer should know/be aware of (exclude general software engineering and similar and focus only on C specific stuff). I would like to know so that I would be able to fill in some possible gaps in my C knowledge.


How to Track File Uploads and Return Upload Status with REST?

The users for our software will want to upload potentially large amounts of files in bulk to our servers. It is then desired that we display the upload status any time the user views the upload screen. This doesn't have to be any more fancy than a progress bar with a percent status. ![Our user will want to upload many files at once and to see the status of their upload.](http://i.stack.imgur.com/04DEU.png) My question is, how can I keep track of the uploaded files and return them at any possible time with a simple GET request at '/upload/status'. A first solutions aims to keep track of the uploads requested and those processed in a database table. That way, it is as easy as querying the database any time the user wants to see his upload status. ![the uploaded files are saved to a database](http://i.stack.imgur.com/KHf7v.png) Is this a viable- and correct- solution to handling the state of file uploads in a REST service? Should I be looking for solutions elsewhere?


What are the most necessary non-language specific things a programmer needs to know?

I've been thinking about this a lot lately. Right now I work at a little web company, am almost done with school, and have written an iPhone app, but I'm not sure what else I need to focus my learning energies on. I've decided I want to do software programming, so I've been actively reading everything I can get my hands on that deals with Objective-C / C++ (Cocoa, OpenGL, etc). But those are not the things I'm talking about. I know I need to "master" a language or two. What I'm talking about are the other "things". Things such as learning and using source control, design patterns, etc. What thing (or things, just one per response), would you say I should concurrently be focusing on? You can consider in your answer that I'm wanting to do the aforementioned career path, but you don't have to. I just want a nice list of things to research, and actually use in my career. NOTE: I asked this question on Stackoverflow, and after a few good answers, it got closed, and I was told i should move it here. Here is the original: http://stackoverflow.com/questions/4452857/what-are-the- most-necessary-non-language-specific-things-a-programmer-needs-to-kn One thing is, a lot of the answers were about people skills, which is fine, and I do agree, but I was looking more for programming specific kind of things, like, i don't know, learning Hexadecimal, or design patterns (maybe specific), etc.


Where do I place my example implementations in my framework?

I've created a pretty simple templating framework and have default implementations for some of my interfaces used for passing around information. I store these in MyFramework.Default namespace However, I am unsure of where to place example implementations, such as a template that creates a concrete class. This template seems like it would be useful to people who use my framework, but I am not sure if it belongs in a separate assembly, or perhaps a namespace within the framework. If it's a namespace, is there any convention for its name?


Avoid becomming a "Theoretician" programmer

I have found this article in several posts on SO. I find myself falling into the 6th archetype; the "Theoretician". It defines the "Theoretician" as: > The Theoretician knows everything there is to know about programming. He or > she can spend four hours lecturing about the history of an obscure > programming language or providing a proof of how the code you wrote is less > than perfectly optimal and may take an extra three nanoseconds to run. The > problem is, The Theoretician does not know a thing about software > development. When The Theoretician writes code, it is so “elegant” that mere > mortals cannot make sense of it. His or her favorite technique is recursion, > and every block of code is tweaked to the max, at the expense of timeliness > and readability. > > The Theoretician is also easily distracted. A simple task that should take > an hour takes Theoreticians three months, since they decide that the > existing tools are not sufficient and they must build new tools to build new > libraries to build a whole new system that meets their high standards. The > Theoretician can be turned into one of your best players, if you can get him > or her to play within the boundaries of the project itself and stop spending > time working on The Ultimate Sorting Algorithm. Even when working on what should be a simple project, I tend to get bogged don in trying to over engineer everything from scratch(This probably explains why I wasted about 2 years trying to make an operating system from scratch. But even I saw that it was pointless eventually). What can help me to avoid doing this? And stick to KISS principles? Thanks


Best place to start a blog

I want to start writing a programming blog and that way to market myself in addition to CVs. Can you recommend me good site that will be easy to start a blog and it has a high light syntax functionality built in. saw blogger and wordpress.com and not sure were to get started payed sites can be an option too. Thanks for help.


How should i set up my source folder?

I have /src/main/ with all my code (i also have /src/online, /src/prvlibs, /src/test, etc) but now i am thinking about moving a few non active projects out of the folder. Sure i could go in and delete all objs, (some) project files, etc so it doesnt take 200mb of generated data. But i think it might be nice for only 20projects or less instead of dozen of prototypes that aren't throwaway test. I use git for source control (but i'm sure all scm do the same thing). They dislike files are missing and if i delete them they aren't easy to browse. I like how i can commit all of my source by going to /src/main and commiting. And i can push all of them just as easily. But moving folders (to my external HD and keep history) is the problem. Should i have every folder have its own repo? or is there some kind of workaround i can use? If every folder has its own repo is there an easy way to push all my folders to my HD (or website) for backup?


What background is needed to understand The Art of Computer Programming, Volume 4A?

I recently made the investment in the newly-printed four-volume set of Donald Knuth's _The Art of Computer Programming._ Like this poster, I probably do not have the time right now to read the entire set, with a full-time programming job, spending time with my girlfriend, doing housework, etc., though I have no doubt I would find it fascinating. Public transit is not available for my commute, and unless there is a "books-on-CD" version, consuming the material during my commute is probably out of the question. After reading this review of Volume 4A, I realized that at least some of the information may be of great help in my thesis. Incidentally, the thesis is for my doctorate in music, which has been on the back burner for a little longer than I would like. It sounds like, from the reviewer's description, combinatorial algorithms could be of great help in solving the problem I am attempting to solve. Am I going to need to read the first three volumes to understand the fourth? While I have no computer science degrees per se, I do have a reasonable amount of experience, and I have succeeded in graduate coursework in algorithms, compilers, and databases. Have any of you read some or all of Volume 4A? What background did you feel you had (or lacked) that helped (or would have helped) you understand the material?


Architecture Best Practice (MVC): Repository Returns Object & Object Member Accessed Directly or Repository Returns Object Member

Architecturally speaking, which is the preferable approach (and why)?               $validation_date = $users_repository->getUser($user_id)->validation_date;        * Seems to violate Law of Demeter by accessing member of object returned by method call   * Seems to violate Encapsulation by accessing object member directly `$validation_date = $users_repository->getUserValidationDate($user_id);`   * Seems to violate Single Responsibility Principle as $users_repository no longer just returns User objects


System Decoupled in the Wrong Places: Meta-Problem?

At a meta level, I often find that when I grow a codebase organically, parts of the system that I eventually find need to know about each other (at least through some interface) have been mercilessly decoupled. This often occurs in research prototype code, where one tends to frequently think of tweaks and small improvements that weren't planned for in the original codebase. Usually, some setting or piece of data needs to be plumbed through about 15 zillion layers of function calls in ways that I never anticipated when I designed the code. This leads to a very ugly dilemma:   1. Use an ugly hack. This can be yet another global variable, bolting the data onto a class that it clearly doesn't belong in, putting a bunch of print statements in the middle of code that previously had nothing to do with I/O logic, doing a seemingly straightforward task in a very roundabout way to make it fit in my original codebase, etc.   2. Shotgun surgery refactoring. This almost never gets done in practice because the code will likely have to be rewritten anyhow if it is to become production quality, was hard to get working the first time, is hard to test, or I just plain have higher priorities than writing clean, maintainable code when either I have a deadline or I know it's just a prototype for now. Furthermore, the next tweak may break whatever nice abstractions I come up with. Are there any good meta-tips or design principles that will help me avoid situations like this in the first place? I am **_NOT_** looking for answers that simply recommend refactoring after the fact, as a nightmarish shotgun surgery refactoring session is exactly the kind of thing I'm trying to avoid.


Should the 12-String be in its own class and why?

This question is regarding a homework project in my first Java programming class (online program). The assignment is to create a "stringed instrument" class using (among other things) an array of String names representing instrument string names ("A", "E", etc). The idea for the 12-string is beyond the scope of the assignment (it doesn't have to be included at all) but now that I've thought of it, I want to figure out how to make it work. Part of me feels like the 12-String should have its own class, but another part of me feels that it should be in the guitar class because it's a guitar. I suppose this will become clear as I progress but I thought I would see what kind of response I get here. Also, why would they ask for a String[] for the instrument string names? Seems like a char[] makes more sense. Thank you for any insight. Here's my code so far (it's a work in progress):               public class Guitar {               private int numberOfStrings = 6;     private static int numberOfGuitars = 0;     private String[] stringNotes = {"E", "A", "D", "G", "B", "A"};     private boolean tuned = false;     private boolean playing = false;          public Guitar(){         numberOfGuitars++;     }          public Guitar(boolean twelveString){         if(twelveString){             stringNotes[0] = "E, E";             stringNotes[1] = "A, A";             stringNotes[2] = "D, D";             stringNotes[3] = "G, G";             stringNotes[4] = "B, B";             stringNotes[5] = "E, E";             numberOfStrings = 12;         }     }          public int getNumberOfStrings() {         return numberOfStrings;     }          public void setNumberOfStrings(int strings) {         if(strings == 12 || strings == 6) {             if(strings == 12){                 stringNotes[0] = "E, E";                 stringNotes[1] = "A, A";                 stringNotes[2] = "D, D";                 stringNotes[3] = "G, G";                 stringNotes[4] = "B, B";                 stringNotes[5] = "E, E";                 numberOfStrings = strings;             }             if(strings == 6)                 numberOfStrings = strings;         }//if         else             System.out.println("***ERROR***Guitar can only have 6 or 12 strings***ERROR***");     }          public void getStringNotes() {             for(int i = 0; i < stringNotes.length; i++){                 if(i == stringNotes.length - 1)                     System.out.println(stringNotes[i]);                 else                     System.out.print(stringNotes[i] + ", ");             }//for     }


Algorithm development in jobs

I have a mathematics background but also consider career in some form of software development. In particular I'm interested in finding out what sort of industries are most likely to have more algorithm development/mathematical and logical problem solving slant rather than pure application development etc. Obviously, I'm assuming that some subset of the canonical data structures and associated algorithms (trees, lists, hash tables, sets, maps with search, insert, traversals etc.) are mostly going to be present in software development. However, where am I more likely to encounter problems of more discrete maths nature (combinatorial, graph theory, sets, strings, ...) explicitly or more likely in disguise. Any pointers much appreciated (including possible open source projects that I could use for my further search for applications and also possibly contribute to).


Distance from point to n-dimensional line

The solution for the 3-d case can be found here; I would like to get the generalized version. There's no simple generalization of the Mathworld algorithm since the cross product is defined only for 3 and 7 dimensions, so I understand.


Extracting useful information from free text

We filter and analyse seats for events. Apparently writing a domain query language for the floor people isn't an option. I'm using C# 4.0 & .NET 4.0, and have relatively free reign to use whatever open-source tools are available. </background-info> If a request comes in for "FLOOR B", the sales people want it to show up if they've entered "FLOOR A-FLOOR F" in a filter. The only problem I have is that there's absolutely no structure to the parsed parameters. I get the string already concatenated (it actually uses a tilde instead of dash). Examples I've seen so far with matches after each:   * 101WC-199WC (needs to match 150WC)   * AAA-ZZZ (needs to match AAA, BBB, ABC but not BB)   * LOGE15-LOGE20 (needs to match LOGE15 but not LOGE150) At first I wanted to try just stripping off the numeric part of the lower and upper, and then incrementing through that. The problem I have is that only some entries have numbers, sometimes the numbers AND letters increment, sometimes its all letters that increment. Since I can't impose any kind of grammar to use (I really wanted [..] expansion syntax), I'm stuck using these entries. Are there any suggestions for how to approach this parsing problem?


Location of development solutions on disk - Common or upto the individual

In our team meeting today a senior member brought up the proposal that we should be having a common location/structure for our development solutions. A couple of his points were:   1. Making it common meant when talking about projects and emailing stuff everyone is on the same wavelength and knows where to look.   2. If there is ever the need to hard code a location path then it will work across all developers pc's. He had a more few points to back up his suggestion but I unfortunately got distracted during the discussion and so didn't hear all of them. I have no issue with the idea and can see it's merits but I was wondering if it is common or even recommended that all developers place their code in the same folder structure. Or do developers like to have the flexibility of location solutions where-ever they want? We currently use **SVN** for our version control. In this case his recommendation was to place all code in:               c:\Work\Development\<Customer>\<project>\Code\<solution>\ the code      I guess actual path is irrelevant for this question but added for completeness.


KISS principle applied to programming language design?

**KISS** ("keep it simple, stupid" or "keep it simple stupid", see e.g. here) is an important principle in software development, even though it apparently originated in engineering. Citing from the wikipedia article: > The principle is best exemplified by the story of Johnson handing a team of > design engineers a handful of tools, with the challenge that the jet > aircraft they were designing must be repairable by an average mechanic in > the field under combat conditions with only these tools. Hence, the 'stupid' > refers to the relationship between the way things break and the > sophistication available to fix them. If I wanted to apply this to the field of software development I would replace "jet aircraft" with "piece of software", "average mechanic" with "average developer" and "under combat conditions" with "under the expected software development / maintenance conditions" (deadlines, time constraints, meetings / interruptions, available tools, and so on). So it is a commonly accepted idea that one should try to keep a piece of software **simple** (or **simple stupid** , in case you omit the comma) so that it easy to work on it later. But can the KISS principle be applied also to programming language design? Do you know of any programming languages that have been designed specifically with this principle in mind, i.e. to "allow an average programmer under average working conditions to write and maintain as much code as possible with the least cognitive effort"? If you cite any specific language it would be great if you could add a link to some document in which this intent is clearly expressed by the language designers. In any case, I would be interested to learn about the designers' (documented) intentions rather than your personal opinion about a particular programming language.


Why can't WARs share session info?

I have seen several developers looking for a solution for this problem: **accessing session information from a different WAR** (even when inside the same EAR) - here are some samples: Any way to share session state between different applications in tomcat?, Access session of another web application, different WAR files, shared resources, Tomcat: How to share data between two applications?, What does the crossContext attribute do in Tomcat? Does it enable session sharing? and so on... From all I have searched, there are some specific solutions depending on the container, but it is somehow ' **contrary to the specification** '. I have also looked through Java EE specification without any luck on finding an answer. Some developers talk about coupling between web applications, but I tend to disagree. What is the reason one would keep WARs inside the same EAR if not coupling? EJBs, for instance, can be accessed locally (even if inside another EJB JAR within the same EAR). More specifically, one of my WARs handles authentication and authorization, and I would like to share this information with other WARs (in the same EAR). I have managed to work around similar problems before by packaging WARs as JARs and putting them into a singular WAR project (WEB-INF/lib). Yet I do not like this solution (it requires a huge effort on servlet naming and so on). And no solution has answered the first (and most important) question: **Why can't WARs share session information?**


What information must never appear in logs?

I'm about to write the company guidelines about what must never appear in logs (trace of an application). In fact, some developers try to include as many information as possible in trace, **making it risky to store those logs, and extremely dangerous to submit them** , especially when the customer doesn't know this information is stored, because she never cared about this and never read documentation and/or warning messages. For example, when dealing with files, some developers are tempted to trace **the names of the files**. For example before appending file name to a directory, if we trace everything on error, it will be easy to notice for example that the appended name is too long, and that the bug in the code was to forget to check for the length of the concatenated string. It is helpful, but **this is sensitive data, and must never appear in logs**. In the same way:   * **Passwords** ,   * IP addresses and network information (MAC address, host name, etc.)¹,   * Database accesses,   * Direct input from user and stored **business data** must never appear in trace. So what other types of information must be banished from the logs? Are there any guidelines already written which I can use? * * * ¹ Obviously, I'm not talking about things as IIS or Apache logs. What I'm talking about is the sort of information which is collected with the only intent to debug the application itself, not to trace the activity of untrusted entities. * * * **Edit:** Thank you for your answers and your comments. Since my question is not too precise, I'll try to answer the questions asked in the comments:   * What I'm doing with the logs? The logs of the application may be stored in memory, which means either in plain on hard disk on localhost, in a database, again in plain, or in Windows Events. In every case, the concern is that those sources may not be safe enough. For example, when a customer runs an application and this application stores logs in plain text file in temp directory, anybody who has a physical access to the PC can read those logs. The logs of the application may also be sent through internet. For example, if a customer has an issue with an application, we can ask her to run this application in full-trace mode and to send us the log file. Also, some application may sent automatically the crash report to us (and even if there are warnings about sensitive data, in most cases customers don't read them).   * Am I talking about specific fields? No. I'm working on general business applications only, so the only sensitive data is business data. There is nothing related to health or other fields covered by specific regulations. But thank you to talk about that, I probably should take a look about those fields for some clues about what I can include in guidelines.   * Isn't it easier to encrypt the data? No. It would make every application much more difficult, especially if we want to use C# diagnostics and `TraceSource`. It would also require to manage authorizations, which is not the easiest think to do. Finally, if we are talking about the logs submitted to us from a customer, we must be able to read the logs, but without having access to sensitive data. So technically, it's easier to never include sensitive information in logs at all and to never care about how and where those logs are stored.


How can I change my career from Windows server administration to software development?

I am an Engineering Graduate in Telecommunication Engineering. I got into a server support job soon after finishing college. I have a total of 2 years experience in Windows server support. However, I want to move into software development and away from server administration. What courses or certifications can I take to move into a software development role?


UML class diagrams: How to show dependency

Please consider a program with four classes: Class A, B, C and D. Classes A and B are subclasses of abstract super-class C. Class D is dependent on C. Meaning: It holds a `C objectOfTypeC` field. As we know, polymorphically the `objectOfTypeC` reference may hold objects of classד A and B. The value of this reference may change dynamically during runtime. This kind of situtation is very common in OOP. A common example is the Strategy pattern, where several classes all inherit or implement the abstract-class or interface `SuperType`. Another class `SomeClass` holds a reference of type `SuperType`, and is able to dynamically hold different instances of `SuperType` subclasses in that reference. My question is this: I have two ideas how this can be shown in a UML class diagram, but I'm not sure which one is correct. ![enter image description here](http://i.stack.imgur.com/G8lkt.png) ![enter image description here](http://i.stack.imgur.com/aswgA.png) _(Please note: in these examples, the super type is an interface, but it could also be an abstract class, or even a regular super class)._ Which option is more correct?


Python - How To Get Cursor Position in Tkinter Text Widget

I want to get the cursor position (line and column) of the insertion point of a Tkinter.Text, but for the specific situation below. PROBLEM: My text editor project requires a custom undo/redo for Tkinter.Text. I put in the same string for both Test One and Test Two below, but undo does not act consistently due to a inconsistent column variable in KeyRelease event handler given by Tkinter. The problem seems to be that I type too fast for second test which produces a bad column value. Can you help me find the problem? TWO TEST PROCESS TO REPRODUCE THE ERROR: TEST ONE   *     1. Type this string slowly: 'one two three'   *     2. Press F1 to see each word undo.   * Result: Works fine. (For me atleast. Ephasis: type slowly.) TEST TWO   *     1. Type the same string as fast as you can: 'one two three'   *     2. Press F1 to see each word undo.   * Result: Gets the wrong column and does not undo properly. (Restart script and repeat this step if you don't see the error at first, it sometimes works fine with fast typing. I usually get it with 3 to 4 tries at the most.) QUESTION: Is this a bug in Tkinter, or am I not understanding something specific within Tkinter that would produce consistent columns for my undo/redo records?               from Tkinter import *          class TextView(Text):              def __init__(self, root):             Text.__init__(self, root)                  self.history = History(self)             self.bind("<KeyRelease>", self.keyRelease)                  # used to capture a char at a time in keyRelease.  If space char is pressed it creates a Word object and adds it to undo/redo history.             self.word = ""              def keyRelease(self, event):             if event.keysym == "space":                 self.word += " "                 self.makeWordRecord()             else:                 self.word += event.char              def makeWordRecord(self, ):             if len(self.word):                 index = self.index(INSERT)                 wordEvent = Word(index, self.word)                 self.history.addEvent(wordEvent)                 self.word = ""              def undo(self, event):             self.makeWordRecord()             self.history.undo()              def redo(self, event):             self.history.redo()          class History(object):         def __init__(self, text):             self.text = text             self.events = []             self.index = -1                  # create blank document record, line one, column one, no text             self.addEvent(Word("1.0", ""))              def addEvent(self, event):             if self.index +1 < len(self.events):                 self.events = self.events[:self.index +1]             self.events.append(event)             self.index +=1              def undo(self):             if self.index > 0:                 self.events[self.index].undo(self.text)                 self.index -=1              def redo(self):             if self.index +1  < len(self.events):                 self.index +=1                 self.events[self.index].redo(self.text)          class Word(object):         def __init__(self, index, word):             self.index = index             self.word = word              def undo(self, text):             line = self.index.split(".")[0]             column = int(self.index.split(".")[-1])             startIndex = line + "." + str(column - len(self.word))             endIndex = line + "." + str(int(column))             text.delete(startIndex, endIndex)              def redo(self, text):             line = self.index.split(".")[0]             column = int(self.index.split(".")[-1])             startIndex = line + "." + str(column - len(self.word))             text.insert(startIndex, self.word)          if __name__ == "__main__":         root = Tk()         root.geometry("400x200+0+0")              textView = TextView(root)         textView.pack()         root.bind("<F1>", textView.undo)         root.bind("<F2>", textView.redo)              root.mainloop()


Best way to learn to code?

I decided I wanted to learn to program so that I could one day make videogames of my own, so I set out to learn c++. I used a website called learncpp.com. First half of the lessons, I have a lot of fun, and I understand it mostly. About halfway through the lessons, I get incredibly bored. I plow through the lessons thinking that it will sink in eventually. Soon enough I realize that I have no idea what these lessons are talking about. Don't get me wrong, I love puzzles and logic and such, but I'm just not getting it. I feel like there was no way to actually work with the things I learned. There were no exercises. I didn't learn to code, I learned what code looked like. I've found that I learn best when I do it myself, and things aren't put on a platter for me. What is a practical way for me to learn code?


Adding field to the class at runtime - design pattern

Imagine your customer want's to have a possibility to add new property (e.g. color) to product in their eshop in their CMS. Instead of having properties as fields:               class Car extends Product {        protected String type;        protected int seats;     }      You would probably end up doing something like:               class Product {        protected String productName;        protected Map<String, Property> properties;     }          class Property {        protected String name;        protected String value;     }      That is, creating own type system on top of existing one. It feels to me like this could be seen as creating domain specific langauge, or couldn't? Is this approach a known design pattern? Would you solve the problem differently? I know there are languages where I can add a field in runtime, but what about database? Would you rather add/alter columns or used someting as shown above? Thank you for your time :).


MVVM or MVC? Want to use the same set of classes for WPF and ASP.NET

I am a newbie in terms of Design Patterns. I just started learning MVC when I am hearing a new buzz, MVVM. I want to learn the insights of both of these by redesigning an old inventory and invoicing application I developed for a client. I want to write both a Windows based WPF application and a Web based version. I want to use the same set of classes if possible, if not, then at least with little modification. I read a couple of articles, but I am not following the architecture and the high-level concepts of .NET 3.5 & 4 discussed there. I want to move step-by- step by designing only what I really need in my real-life project. Is there any easy step-by-step reference to MVVM? Is MVVM a super-set or a sub-set of MVC? Which pattern is modern and which one should I choose for Windows & Web versions of my application? There are certain classes which I rarely need to connect with the View. In that case, designing the same class in the MVVM way will prove to be an added labor.


Lead Programmer or What?

I was on a project where I did 80% of the programming. My boss said what he wanted and how he wanted the code structured, but I am the one who actually wrote the code (in the way he told me). Am I the "lead programmer"? Or something else?


What is the most concise solution for text and file processing?

I need to do text processing in files such as `"replace the second column of the third line of all files in the current folder with the string 'hello'"` or `"list all files in folder ./Hello and write the output into the file ./Hello.txt"`. I thought Python would be a good solution but in fact it is not since you can't directly overwrite files. But I might be wrong since I'm beginner. Here is a working example with Python : I have a list of names of files in `listRef.txt` and I want to write in another text file `list.txt` all the names of files that ARE NOT present the folder `C:\interface\output` :               import os          symbolsRef = []          #List of files to python list     for line in open(r'C:\interface\listRef.txt', "r"):         symbolsRef.append(line)          #Remove from the listRef all lines that contain the names of existing files     for symb in os.listdir(r'C:\interface\output'):         symbolsRef.remove(symb[0:-4]+'\n')          #Write list of files in folder to text file     with open(r'C:\interface\list.txt', "w") as presentList:             for filenames in symbolsRef:                 print(filenames[0:-1], file = presentList)      As you can see I have to create a list, work with the list then write it back to my output file. I might be wrong but I'm confident that you can do better with other solutions. I am giving this working example so an experienced programmer can compare the length of the same program but coded with an other solution. So what is, from your experienced point of view, the solution that -in general- requires the least number of line of code to do a wide variety of tasks in text and file processing : use of regex, index dependant line and column replacement, folder listing, file creation-deletion-replacement. Is it shell scripting with sed and awk, Perl, special libraries in Python or maybe some dedicated softwares ?


How can I verify a Wordpress hashed password using a Delphi application?

I have a Delphi application (D2007) which connects to a Wordpress installation (V4.0, PHP V5.3) and retrieves hashed passwords. I would like the application to be able to verify whether or not input passwords match the stored hashed password. As far as I understand it, the hash is Blowfish using randomly generated salts, which are concatenated into the hash..? **Pass** : newnewnew **Hash** : $P$BA8BEfC.y9WjbpiRqLQHbKrc2sQfbk0 I have been playing around with **DCPcrypt** but yet to make any real progress and I am not sure if what I am trying to achieve is possible Thank you


Should I be a professional in C# programming in order to build good web applications using ASP.NET?

I do not know if there is special programming in C# for the web or it is the same?. If it is the same then what are the topics that I should focus on in C# in order to use it building web application by ASP.NET (Web forms or MVC). For example, if I want to build a website for one of the health centers, will I need a lot of knowledge in C#? So,   * What are the topics that I should focus on in C# so I have enough confidence to build small - medium websites?


New cloud development workflow using Github, Cloud9ide and CloudFoundry

So time is changing towards cloud development/computing. I'm trying to get the new "cloud" workflow based on the services I'm going to use: Github, Cloud9ide and CloudFoundry. Here is what is on my mind:   * Github acts like a central (main repo) just like yesterday's local filesystem. Every service will base it service upon this main repo. Workflow:   1. Github: I create a new Github repo served as main repo for the project.   2. Cloud9ide. I open my Github repo and write my tests and implementation (BDD/TDD). When I'm ready I save (commit) it to main repo on Github.   3. X: A running instance of Jenkins detects someone has committed and fetches the latest commit, builds, deploys, tests (yeti and/or selenium) and reports if the tests were passed or not. If not, I make another commit til all tests are passing.   4. X: I run the CloudFoundry commands to push the main Github repo to CloudFoundry's server and it will deploy my app automatically. What I'm still confused about is where this X environment will be. On a local server where I have to install Jenkins? Or could I install it on Cloud9ide (when java is supported) or will it be on another cloud service? Also, that X environment has to be able to fetch (clone) the Github repo and run the build scripts. And since the concept of Cloud9ide is very new and there haven't been any other predecessors I really wonder how the workflow will look like. We all know Github's workflow. We now know CloudFoundry's workflow (deploy/scale with a restful API/command line tool). But how Cloud9Ide will operate is still somewhat unclear to me. Someone on Cloud9ide mentioned that there will be buttons like deploy so I can deploy with one click. But that I guess will depend on what services that deploy process will hook up into etc. Could someone enlighten this cloud workflow topic and fill in the gaps. Thanks.


Starting a game website. Sanity check (Jetty, WebSockets, Java, etc)

I'm starting a new game website. This is a project to help me learn additional technologies. My background is very much Microsoft and Apple technologies / languages / IDEs. This project I would like to use some Google technologies. The game website will be a simple site; html5 game board; muliplayer; for the sake of simplifying my example let's just say it is a poker game. Everyone sits at the table and the game begins; it is turn based etc. I've been thinking that the best route to go would be html5 w/ websocket communication back to the server. I'm also very interested in using GWT. So I figured a website built using GWT + HTML5 Gameboard would be the client side. Now for the server side; I did some research and I found a bunch of things like Jetty, jWebSockets, Atmosphere; etc. My thinking at the moment is that the server side would be hosted on Jetty (is Atmosphere worth using for server encapsulation?) and would basically be a WebSocket server. Does all this stuff make sense? Am I completely off base here?   Are there examples of this out there to help me along the way? I'm also interested in gaining information about how to host something like this? Any services out there that would host both the socket server and the website on one box? Is this the right thing to do? Anyway definitely looking for experienced knowledge on this topic to help my studies into this new area (google technologies).


Can notes/to-dos in code comments sent to code-reviews result in an effective refactoring process?

I want to start/improve a culture of collective code ownership at my company but at a geographically distributed level... I'd say there is some current collective code-ownership mentality, but only at single geographical sites. This is a follow-up to this question: What is the politically correct way of refactoring other's code? I'm just wondering if submitting ***just code comments*** for code reviews (we have ReviewBoard, possibly upgrading to Crucible) could actually be an effective mechanism to get the conversation started on improving code, without having others feel territorial about their code. For example, if I add:               //ToDo: Refactor this code and that code because of reasons X and Y      Then, submit it for code review, and it gets accepted... it could be considered as an agreement (which I think is sometimes harder to get with new code up front). At the same time, the author (and others) might have an easier time digesting and accepting the proposal; rejecting a proposal because it might break things will not longer be a valid reason and therefore the fear of making a change is lost... and at the same time, do not invest 10 hours optimizing something that no one thinks it is worth it and opposes to it just out of fear. This is all conjecture, but I'm feeling something like this (submitting refactoring notes in code comments at the code-review process) would work. **Has anyone done something like this in practice?, if so, what have been the results?**


Would I be in violation of these icons free license on my Android application?

Since there isn't yet a Q&A site for legal issues and since this is related to an Android app, I'm posting it here, instead of Stack Overflow cause this is not code related. I want to separate this question into 3 sub-questions which are all related though. These questions are about the Free, Commercial and Extended licenses of DryIcons. **1)** Generally speaking, would I be in violation of the free license if I used some icons in my paid version of an Android app? I'm a bit confused... The free license has the following in the "Grant of Rights" section: > b. You may use the Licensed Material in any personal **or commercial project > unlimited number of times** according to the DryIcons Free License Terms and > Conditions; From this I take that yes, I can use their icons in my paid Android app. But then I read this in the commercial license under "Restrictions": > e. Licensee may not use Licensed Material in electronic items for resale, > such as website templates, electronic devices (i.e. computer, iPhone, > phones, etc.) **software applications** , document templates, wallpapers, > screensavers, e-cards or similar products that Licensee intend **to sell or > distribute** ; Which one assumes the extended license is the one we need for a paid app. But isn't this a little bit contradictory? Doesn't that point in the free license allows me to simply use their work in paid apps? **2)** Now, let's assume I really need to buy a commercial/extended license to use their work on my paid/commercial Android app, something I'll be in fact selling to an unlimited number of users. Would I fall under the commercial/extended or the free license if I used In- app Billing in my Android app? With In-app billing I wouldn't be selling their work **at all**. My app would be free with a bunch of features and I would be also using their work. But since my app is free I'm also free to use their work as long as I give proper credits with a link to their website as they state in the free license (no problem doing that, I'm all for it). Then, with In-app Billing I would actually be selling **extra features** to my app (by providing an upgrade to a "Pro" version), not their work. Do you think I would be in violation of the free license like this? **3)** And now a similar situation as the previous point. What if, instead of In-app Billing, I would have 2 apps. One completely free using their work as the free license allows me. And another which is nothing more than an "unlock app", something that would unlock **extra features** on the **free** app. The "unlock app" is the real paid app and this app does not use their work **at all**. Do you think this is exactly the same situation as in the previous point and that I'm just playing with semantics? What's your opinion on that? Do you think I would be in violation of the free license like this?


Introducing design concepts/patterns/principles to co-workers

I've read Joel's article about getting things done when you're a "grunt", several times in fact, but I've never been able to do any of the things it mentions. I work as part of a small development team; we are now 5 strong (they recently expanded; started with two guys for a few years, and then added the rest of us - I have been here about 3 months now and two others were added after me) with a web designer that is kind of part of our group. The app we work on started out as an in-house system and was recently retrofitted to be software-as-a- service. From what I've been told, it went through several revisions and was outsourced twice, then brought entirely in-house. I come from environments that focus heavily on the use of design patterns, bits of Agile design, and a strong desire to write quality code. Because the current environment has changed so often, the code is a bit of a mess; logic is often just copied and pasted across various files (this includes HTML, Javascript and C# code). Almost everything is done in code-behind files with very little separation of logic. There is a common set of classes but they tend to just incorporate various mismatched logic that only slightly relates to the class. There are no coding standards and developers write code as they please (for instance, some code uses Hungarian notation, some doesn't, some classes begin with underscores, some don't). There is little object- orientation used; all the data is passed around as raw Datasets executed via stored procedures. The few domain objects have misleading and confusing names. We are almost always working on new features, and have no time to refactor since refactoring code isn't viewed as adding business value in lieu of adding new things. I have raised some issues with the manager about taking the time to go back and fix the application, extract and refactor code to be more modular and reusable, but he expressed concern that management wouldn't allow us to spend days (or more if necessary) working on old features instead of new. My co-workers don't seem too concerned with this and seem to not be as concerned as I am about the quality of the code we are producing. Also there are no unit tests (testing is done manually by poking around the app) and I wouldn't be able to take the time to test everything. This produces a dilemma for me because I find it frustrating to fix code in one place, only to be reminded it also needs to be fixed in several other places due to being copied across files, and I find it increasingly hard to stay enthusiastic about the code since I have to continually drop back to the existing style (or lack thereof) when fixing bugs; for new modules I write I try my best to keep the code as modular as possible within reason and without introducing radical changes (e.g. trying to incorporate Linq to Sql). Even this causes some concern because I am introducing a different architectural style (albeit one that is better than the style we have now) than the other developers are using. How, if at all, should I go about explaining these things to my co-workers and try to introduce some order to chaos? I look at the code and see how much better it can be with application of design patterns and real code re-use, but it seems like a daunting task because we are constantly inundated with new tasks and cannot just take a week or two out to refactor the code smells away. I know that I cannot ever get us to fix all the code that needs to be fixed since it would be a total rearchitecting of the application (and management would never approve that), but I feel that the code could be much more stable and robust for the future if _something_ was done.


Finding all subsets of a set running time

Given a set {1,2,3} output { {}, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3} } I have only been able to find as fast as O(2^n), is there any techniques for achieving faster results (besides parallelizing)


Ramping Up On Legacy Code

When starting to work on a project with an existing code base, the first thing that needs to be done is usually to understand the application & existing code. Let's assume that the existing code is legacy code; referring to Michael Feathers' definition of "code with no tests". I am sure that there are many different ways to handle this ramp-up phase. The most straightforward way is to go through the UI of the application (if there is one) and simultaneously debug the application to understand what is happening at the code level. This is a very time-consuming approach and also it is very easy to forget what you learn in a debugging session. Furthermore, there is no real way to share (among the team) what you learn during debugging. Understanding the down-sides of this approach, I have tried another approach for my most recent project. What I did was to write a kind of API layer that sits on top of the existing code base. This API contained the functionality of pretty much what a user would do in the UI. To be more specific, let's assume that the existing application is a typical transactional application with orders, items and shopping carts. My API turned out to something like this:               public class OrderAPI{         public Order createOrder(customerName);         public boolean deleteOrder(orderID);         public List<Order> getOrdersForCustomer(customerName);     }          public class OrderItemAPI{         public OrderItem createOrderItem(order);         public boolean deleteOrder(orderID);         public List<OrderItem> getItemInOrder(order);     }          public class ShoppingCartAPI {         public ShoppingCart createCart(customer,order);         public boolean addItemToCart(cart, item);         public boolean removeItemFromCart(cart, item);     }      The methods in the API correspond to the actions that the user would perform at the UI level. Within these methods, the calls to the existing codebase are made. Writing this API by itself, of course, doesn't mean much. So, I have written tests (I guess they automatically become integration tests) to ensure that the API works well; proving that I got an understanding of how the legacy code works. After all this introduction, comes my question: Can you define (possibly in software engineering terms) what I have done? When taking this approach, I have gone completely with my intuition. At some point, I remember being extremely confused; working on the API, then working on my tests, fixing my API, then my tests. I wasn't sure anymore if my main objective was to learn the existing code base or come up with a stable API layer. I would greatly appreciate any kind of explanation; I am sure that this must be a practice that other people have already experimented with. I just need the right guidance to point me to the appropriate discussions/resources.


What is a useful pattern to maintaining an object state in a one to many relationship?

I am looking for a design for my application, here are the players(classes) involved.               struct Transform {         // Uses a matrix to transform the position.         // Also acts acts as the state of a Dialog.         Position transform(Position p);              //other methods.     };          struct Dialog {          // There are multiple dialog for the user to transform the output.               Transform& t;          void ChangeTranformation(){t.rotate(360);}     }          struct Algorithm {         //gives us a position based on an implementation. For example this can return points on a circle or line.              Transform& t;         Position m_p;         Dialog& d;         Position GetCurrentPosition(){ return t.transform(m_p);}              //other methods.     }      **Properties I need:**   1. Each algorithms has one dialog and each dialog can have many algorithms associated with it.   2. When the user selects an algorithm a dialog associated with that algorithm is displayed.   3. If the user selects a different algorithm then re-selects back the state is restored in the dialog. Basically I want a good design pattern to maintain the state of the dialog given that many algorithms use it and they can be switched back and forth. Does anyone have any suggestions? * * * **Here is a use case:** **Dialog1** has a single edit box to control the radius. **Algorithm1** generates points on a unit circle. **Algorithm2** is the same as Algorithm1. The user has selected **Algorithm1** and entered **2** into the edit box. This will generate points on a circle of radius 2. The user then selects **Algorithm2** and enters **10** into the edit box of **Dialog1**. This will generate points on a circle of radius 10. Finally **Algorithm1** is selected again. The edit box of **Dialog1** should show **2** and points on a circle of radius 2 should be generated.


Trying to implement pre/post method code: better to use methods or a parent class?

I'm finding it difficult to frame this question so ... I want to execute code both before and after a method runs in PHP. There are, as far as I know, two ways to implement this: ### Method One: pre and post methods               class Model     {       function find($id)       {         $this->_precode();         // ... do stuff         $this->post_code();       }     }      Add the calls to `_precode()` and `_postcode()` to each method where I need this functionality. ### Method Two: __call and method naming               class Model extends PrePost     {       function prepost_find($id)       {         // ... do stuff ...       }     }          class PrePost      {       function __call($method,$param)        {         $method = "prepost_$method";         // .. precode here ..         $result = $this->$method($param);         // .. postcode here ..       }     }      This relies on naming a method in a specific way in the inheriting class. Is there a preferred way of doing this? The call method can be made to only handle its specific cases and even defer to a child class's call if there is one. I'm not looking for opinions; I'm looking to find out if there are valid reasons to choose one way over another.


Best online reference guide for gcc

My box is configured: Ubuntu, Code::Blocks IDE, GNU gcc compiler. I'm not very experienced in C. I am having some difficulty seperating what functions are available to me. Evidently there's a few different compiler versions and they have different libraries available. Is there an official GNU gcc compiler reference for C? I've considered buying K&R, but I think that is too much for someone at my skill level. Do you have any other tips for free C references considering my setup?


Does MS Visual Studio 2010 contain icons for source files?

I'm just wondering because the `.js` (JavaScript source files) on my computer have an icon from Windows Scripting Host which looks so Windows 95. I tried to look into `devenv.exe` but there aren't any differently colored icons for different languages' source files in it. Even better, of course, would be icons where the extension or something language specific (`++` or so) is featured in the icon. Do any of the DLLs or EXE files in the Visual Studio 2010 installation contain good icons or do you know of any other good source?


I have an inheritance hierarchy three deep : an abstract base class, from which I derive another abstract class, call it the intermediate class, from which will derive possibly a large variety of derived classes. At one point, the base class calls a `this.GenerateXml()` method, implemented in the derived class, that returns nothing, but writes xml to a public property. At this point, I would like the intermediate class to do some stuff, without the base class or the derived class having to call a specific method on the intermediate class. Is this possible in OO languages? Constructors call each other up the chain of inheritance. Can methods? Can an object call a method on it's immediate descendant? The language in this case is C# The obvious solution is to call a method, perhaps a same named method, from the derived class, using "base". This is less than ideal, because every derived class has to remember to make the call.


Java Xml intraction in Android

I'm working on Android application development. There is a question that always comes to my mind that: How XML interacts with Java code?. I mean `Button` inside XML is a view, but `Button` inside Java is a class. For populating and XML layout we use `setContentView(R.layout.name)`. What I want to know is how this XML code interacts with Java, what technique is used and what code is behind this. If any know please tell me in brief.


Design backward and forward button operations of a browser

If you were asked to design the backward and forward button operation (as a library) in a browser, how would you do it? What will be your APIs and parameters to them? what data structure will be best suitable for this usecase?


Hiring a Junior Developer, What should I ask?

We are currently hiring a junior developer to help me out, as I have more projects than I can currently manage. I have never hired anyone who wasn't a friend or at least an acquaintance. I have a phone interview with the only applicant that actually stood out to me (on paper), but I have never done this before. Our projects are all high scalability, data intensive web applications that process millions of transactions an hour, across multiple servers and clients. To be language/stack specific, we use ASP.Net MVC2, WebForms and C# 4, MSSQL 2008 R2, all running atop Windows Server 2008 R2 What should I ask him? How should I structure the phone call?


Understanding how audio/video chat works in the iPhone SDK

I am really looking forward on creating a **chat application** which features basic implementation of text chatting, as well as advanced features of **audio/video** chatting. I have clearly understood how to implement text chatting feature using **push notification**. Now I am heading towards implementation of audio/video chatting in my application. I Googled around to see some samples for the same. I found **Voice chatting**, **idoubs** and a couple of more sources, but ended on a negative note. What I realized is I am not sure of what actually happens during a audio/video chat. What are the background activities which take part when user is chatting. I believe, if I understand the process behind the **audio/video** chat, I may implement it in a way I too understand. So, if anyone among you has a brief/detail knowledge regarding audio/video chat, kindly share it with me.


How to for non-programmer : formulate web-programming requirements for designing a website by a third party how to ask and what to ask Example : I want to hire someone to design or implement any existing " Photo Voting Contest " with some extra features. How do I formulate my needs for a web-programmer to understand me ? Are there any templates ? Books ?


Checking members and instantiating in properties

Consider this:               public MyClass     {         private Resource _myResource;              public Resource MyResource         {             get             {                 if(_myResource == null)                 {                     _myResource = new Resource();                 }                      return _myResource;             }         }              public void UseResource()         {             MyResource.DoSomething();         }     }      Is this a recognised pattern, or possibly an anti-pattern? I've never seen it suggested in any books, but it does come up time and time again in code I see. I think the logic of this is that _myResource is instantiated 'just in time'. To me, it seems a bit smelly. UserResource() is accessing a public property from within the class, and the resource can never really be accessed through the private member - if someone did, _myResource could be null. Maybe performance reasons may sometimes necessitate, but I would generally favour instantiating in the constructor, or just having an instance of Resource local to the method. So is this an accepted pattern, or should it be avoided?


What is the relation between clojure reducers and loop fusion

I just stumbled upon Clojure reducers library. It looks a lot like loop fusion. However the term is not mentioned anywhere on the page. Is there a difference between the two?


Confused on selling GPL. How is it consistent with this section?

(Written against GPLv2.) It is always said that GPL does not prohibit selling the software, as long as its source code is provided under the same license (GPL). Now, I do not understand how it is consistent with Section 2b: > You must cause any work that you distribute or publish, that in whole or in > part contains or is derived from the Program or any part thereof, to be > **licensed as a whole at no charge** to all third parties under the terms of > this License. I don't get it. Does not this clause prohibit selling the software? If not, then what exactly does it trying to say? **EDIT:** Following the answers below, I wish to note that answering a question "everyone says that GPL says A but this part of GPL says B, how is it?" with "everyone says A so GPL must mean A" is not an answer.


When to use non-embedded databases over embedded databases

We are trying to start a web base project that need to develop based on MS technologies such as C#,.net, IIS etc. This is a web application suppose to sell as a product with a single installer. Now we are discussing which kid of database we are going to use. Some says `non-embedded database` (Ms Sql) Some of them idea is to use `embedded databases`. So we are in a bit of confusion stage for a batter decision. Can you guys give some feedback according to your experience. then that will help us to come up with a good decision. In simply what is need is **When to use non-embedded over embedded databases?** **Edit :** Anyway We have technical understanding about how to use Non- embedded database such as MS Sql Server or Embedded database. What I need is, Conceptually in which situations usually we prefers each type of databases and what are the pros and cons of using each types.


Is this method of writing Unit Tests correct?

I have created a small C# project to help me learn how to write good unit tests. I know that one important rule of unit testing is to test the smallest 'unit' of code possible so that if it fails you know exactly what part of the code needs to fixed. I need help with the following before I continue to implement more unit tests for the project: If I have a `Car` class, for example, that creates a new `Car` object which has various attributes that are calculated when its' constructor method is called, would the two following tests be considered as overkill? Should there be one test that tests all calculated attributes of the `Car` object instead?                   [Test]         public void CarEngineCalculatedValue()         {             BusinessObjects.Car car= new BusinessObjects.Car();             Assert.GreaterOrEqual(car.Engine, 1);         }              [Test]         public void CarNameCalculatedValue()         {             BusinessObjects.Car car= new BusinessObjects.Car();             Assert.IsNotNull(car.Name);         }      Should I have the above two test methods to test these things or should I have one test method that asserts the Car object has first been created and then test these things in the same test method?


Confusion of scope of a variable: Is Global Variable a solution?

I am newly learning C Programming. When we have a C Program with lot of functions, parameter passing, calling and all - It becomes a great problem as to which variable must be declared where. My question is: If I declare all the variables (or atleast the variables that are confusing me) as Global Variables - my problem will be solved - but is that a Good Practice?


How to license programming code as open-source to say I am the author?

I am just wondering. I've never licensed any code before and there is so many separate information about that I am a little bit confused; I watched the codes which are published in the Internet and some of them contain their author name and license info so that makes the code some kind of personalized; So my question is... what author should do to be able to : A) License his code B) Say he is the code author C) Place the code in Internet (apache web site or something in this direction) D) Say it is under apache/GNU license or something? I am talking about open-source and non-commercial licenses; And the most important thing is... should I patent the code before to prove I am the code owner to license it? And what organization(s) I should join? In music it is something like ASCAP ( but in my case I don't mean commercial purposes); but what about programming? Are there some societies which I can join to be sure I can prove the code I published (on their official site etc) is really mine? Thanks


Best practice modelling an active record entity using Linq-To-SQL as DAL

Currently I'm starting a new system on my company, and we are using a good separation between models, views and controllers, basically using Asp.Net MVC 3 for the user UI, and a C# class library for the model. The question is about "modelling a model". We are using Linq-to-SQL as a Data Access Layer, and modelling entities over this DAL. Example:                   // DAL, an autogenerated .dbml file         ...         public System.Data.Linq.Table<TB_USER> TB_USERs {            get {               return this.GetTable<TB_USER>();            }         }         ...      And we are mapping this table on an entity, like below:                   public class User {            // Entity, mirroring a .dbml table            public static IEnumerable<User> GetAll() {                var db = new MyDataContext();                var userList = (from u in db.TB_USERs select u).ToList();                IEnumerable<User> retorno = lista.ConvertAll(u => (User)u);                return retorno;            }                 // Active Record ?            public static User Save(User user) { ... }         }      Is this kind of modelling correct ? It feels like I'm repeating myself by having 2 entities meaning the same thing (User and TB_USER), but TB_USER is the raw representation of the database table that persists the User entity. And the GetAll method, a static method created on the entity with the sole purpose of retrieving all of them. That means that if I want to retrieve data using a filter, for example, I have to create another `GetDataBy...` method. And what about the Save method ? I know it's supposed to save the state of one User, but what if I have to save some random User object along with other objects to make a transaction ? Shouldn't this kind of transaction control be in the database ?


Does your workplace allow the use of multiple, interoperable programming languages?

Since now there are several good languages that target the JVM and can interop with Java with varying degrees of painlessness, and likewise for the CLR (especially with the recent addition of F# as an "official" language for the platform), it seems to me like more places could take advantage of this but are afraid to. In my own workplace, we can only write our components in C#. It's a good language, and I don't mind programming in it, but I'd really prefer to be able to use F# sometimes. I'm sure if we were in Java-land things would be similar, where I'd prefer Clojure or Scala. This is probably selfish of me, as I'm sure it's safer to stick with a lowest-common-denominator. What are your thoughts on this issue? Should more people take advantage of the great interoperability on these platforms?


Web workflow solution - how should I approach the design?

We've been tasked with creating a web based workflow tool to track change management. It has a single workflow with multiple synchronous tasks for the most part, but branch out at a point to tasks running in parallel which meet up later on. There will be all sorts of people using the application, and all of them will need to see their outstanding tasks for each change, but only theirs, not others. There will also be a high level group of people who oversee all changes, so need to see everything. They will need to see tasks which have not been done in the specified time, who's responsible etc. The data will be persisted to a SQL database. It'll all be put together using .Net. I've been trying to learn and implement OOP into my designs of late, but I'm wondering if this is moot in this instance as it may be better to have the business logic for this in stored procedures in the DB. I could use POCO's, a front end layer and a data access layer for the web application and just use it as a mechanism for CRUD actions on the DB, then use SP's fired in the DB to apply the business rules. On the other hand, I could use an object oriented design within the web app, but as the data in the app is state-less, is this a bad idea? I could try and model out the whole application into a class structure, implementing interfaces, base classes and all that good stuff. So I would create a change class, which contained a list of task classes/types, which defined each task, and implement an ITask interface etc. Put end-user types into the tasks to identify who should be doing what task. Then apply all the business logic in the respective class methods etc. What approach do you guys think I should be using for this solution?


What is the algorithm for expiring items in key-value storage?

I was thinking on how current key-value storages implement "expire date" for items. Currently I have 2 variants for that in my mind:   1. they don't do anything (keep expired data), and only do check when you do, for example, GET by some key. The problem here is that if you are limited in memory, expired items won't be deleted.   2. they keep additional data structures to be able to get "earliest to expire". I see it can be done with something like this:              storage_data = dict(key -> [value, expire_timestamp])     expire_tree = SomeBinaryLikeTree(expire_timestamp -> [keys])


Entity Framework with no direct table access

There are some similar questions I've found here, but none of them fully answer the question I'm asking. Similar questions: here and here In my company, I develop C# .NET applications and our Server Admins in IT don't allow direct table access so we're required to use stored procedures to insert, update, and delete from a table. In the past I've been using DataSets and TableAdapters to access the tables of a database, but I'm starting to realize that everything is starting to use Entity Framework. Herein lies my issue. There is another developer here that uses the Entity Framework, but he doesn't actually use entities. He uses Entity Models that have no tables or views, only stored procedures. Doesn't this defeat the purpose of the _Entity_ Framework, or am I crazy? Also, I realize that you can map the insert, update, and delete functionality to stored procedures and this article mentions some interesting ways of implementing that, but creating views for every table would be a major pain. Are there any more practical or easily implemented alternatives?


Unable to understand linked list example

Could someone please explain this code to me..               #include <iostream>          using namespace std;          struct link     {         int data;         link* next;     };          class linklist     {         private:             link* first;         public:             linklist() : first(NULL)             {}             void additem(int);             void display();     };     void linklist::additem(int d)     {         link* newlink = new link;              newlink->data = d;         newlink->next = first;         first = newlink;     }     void linklist::display()     {         link* current = first;              while( current != NULL )         {             cout<<current->data<<"\n";             current = current->next;         }     }          int main()     {         linklist li;              li.additem(25);         li.additem(36);         li.additem(47);         li.additem(58);              li.display();              return 0;     }      i get most of the code but i don't understand the following:   1. What is happening when `additem(int)` is called?   2. How does one object create 4 ints and loop through them?   3. How is the while loop working in this code sample?


Test interface implementation

I have a interface in our code base that I would like to be able to mock out for unit testing. I am writing a test implementation to allow the individual tests to be able to override the specific methods they are concerned with rather than implementing every method. I've run into a quandary over how the test implementation should behave if the test fails to override a method used by the method under test. Should I return a "non-value" (0, null) in the test implementation or throw a UnsupportedOperationException to explicitly fail the test?


What is the best implementation strategy for this html + javascript widget?

**The Problem**   I came up with this select-box variant in answer to a question on UX.SE: http://ux.stackexchange.com/a/48951/16187 ![enter image description here](http://i.stack.imgur.com/w2hEC.png) However, working out how to implement it has been driving me mad ever since I wrote that post. **What I've tried**   Initially I figured it would be easy enough to do. The strategy I would have taken would be to model all the options in a javascript object, with their own name and selected properties, and then write a view function to display them as an unordered list or something. I could then create the button as another javascript object, modelling it's own state, and have a view function spiting it out a representation of it into the widget. Maybe throw in some event code for transitioning between button states and I'm done. **Where I'm Stuck**   The more I thought about that approach, the more I realised that having all of the state sitting in javascript objects was a terrible idea. I figured that I should probably store the state in the dom, and mutate it with javascript. However I have no clear idea what that sort of architecture would look like, or how I should go about coding it. Can you help me work out what a better high level implementation strategy for this sort of widget looks like?


Where to put Spring configuration file?

I want to integrate Spring framework in my project especially into server side. So, I don't want to put it within WEB-INF folder of war file. Should I put an applicationContext.xml it into each layer (means each project since divided in distinct projects? (Services, Domain, and DAO) What is the good practice ?


Iterative process modelling on a kanban board

Kanban does assume a more-or-less linear flow. Most of the time this models software development quiet well: we crate a user story, we code it, we test it, and we deploy it. However, some internal stages are iterative in nature and thus not so obvious. Take this (simplistic) board:               ||   Planning   ||  Development ||     Test     ||     Deploy   || Done ||     || doing | done || doing | done || doing | done || doing | done ||      ||     ||       |      ||       |      ||       |      ||       |      ||      ||      Let's focus on the Planning column. If this is where user stories are developed, clearly some sort of iteration is needed: write story, refine/conversation, improve story, customer feedback, etc ... These stages are not modelled on the board at all. Let's focus on the Test column. Once a story (or task/whatnot) is being tested: some tests will pass, some will fail. Thus the story needs more work. Should it go back into the develop column? Stay in a special test/development? Should there be Test/Fail and Tests/Pass columns? Over complicating the board is not an optimal solution. _Should you model iterative processes using Kanban?_ If so, how? If not, why not?


Does it make sense to ask, "What is the difference between Design Pattern and Algorithm?"

From Wikipedia: > In mathematics and computer science, an **algorithm** is an effective method > expressed as a finite list of well-defined instructions for calculating a > function. > > In software engineering, a **design pattern** is a general reusable solution > to a commonly occurring problem in software design. By description(assuming they are correct on Wikipedia), it appears that Algorithm and Design Pattern are somewhat similar/same. They both achieve the task of solving a problem and both are certainly reusable if properly implemented. Does it make any sense to compare them to evaluate differences between them?


What does “S” stands for in OOPS?

I have searched for the full form of " **OOPS** " in Google, but unfortunately, there are many ambiguous answers. Some say it's " **Systems** ", and some say it's " **Structure** ", and some have even mentioned it as " **Synopsis** ". Can anybody please enlighten me, to find the full form of OOPS, with some proper & correct reference? Many thanks to everyone, helping me out.


Starting up in a basement and scaling

So I have this 'great' idea in my head that I want to start working on and build a company around it. Been working on desktop development for 5+ years and the idea revolves around the web. My exposure to web development is purely academic(a few database driven websites etc). I know I have the wherewithal to get started and build something that works but am also sure that I don't have the expertise to scale whatever I build to huge numbers. Looking at how some of the web majors started in dorm rooms etc, I am wondering how most web startups approach this problem (I'd find it difficult to believe that all the major startup founders had something that would scale to millions of users in their first jab). Do you think its wise to run with whatever I can and then worry about scaling if and when its necessary? Or do you think its a sign that I am trying to bite more than I can chew?


Feeling well out of my depth

I have just started a new job as a front end web developer, this is my second day and I have just been handed quite a big project that involves lots of javascript which I dont know, this is leaving me extremely stressed (last night I couldnt get to sleep with worry) basically I got the job from the boss of the company phoning me up and asking me for a chat which then ended up in a job offer which I accepted, my previous role was just css and html with the odd little piece of jquery here and there and now this is way outside my comfort zone. What should I do? Against my name in here it says my name + DHTML, CSS and JQuery?


Include years experience on CV?

I have been programming in C# .Net for nearly three years, and only C# .Net. I'm filling in my CV/resume and it looks a bit rubbish because I don't know any other languages (that I'm confident enough to include anyway). As I can't put my age/DoB on it I'm a little worried that employers won't take a second glance. I'm very good at OO design, TDD, etc... And so a graduate level job is probably a little low but with only one language under my belt I'm not sure I'll be considered for 'regular' level developer. Is it a good idea to include years of experience? Or should I just big up the cross cutting concerns (TDD, OO...)? Or any other suggestions to get to interview?


How can I complete a project as a single web developer?

I am a PHP 'developer' who codes for fun. My problem is I have never completed my large projects. Please I would like to know how experienced programmers like you are able to complete projects single-handedly. My problem is I tend to allow frustration get me. I think this is because I do all of the coding and the graphics alone and this is really challenging for me coming from a country where electricity is epileptic(In Nigeria - You would have to do things quickly, because power will be cut short after certain times that are sometimes unpredictable). So a very picky person like me finds it hard to immediately make design(graphics) decisions. What am asking from you is a formula that works for you. A formula that gets the work done. Right now, I am thinking of a formula that involves the coding of a 'dirty' prototype of my idea. Then, when am done, I'll just focus on the graphics aspect. Is this really a good idea? Please I need your advice because I may never get to complete any project of my own. Note: I have no problem coding with PHP. Thanks


Will I learn more from changing other people's code?

I am currently trying to break through the intermediate coder stage to advanced and needless to say it's been tough. I have been working through several books with example code. I have felt lately that taking the example code, changing it to fit my own similar project, breaking it, and fixing it, is more effective for learning than simply re-coding line after line of example work. Does anyone else similar or contrasting opinions? Will this method pay off in the long term? Thoughts on this method of learning? Thanks!


Codeigniter/MVC workflow

Bit of a workflow question. I'm just staring with MVC and wondered how other people usually work in MVC? The 2 options I see is to code the model and controller completely first and then work on the views after. The other option is to code all parts at the same time. I'm looking for what might be the quickest most efficient way to code in MVC? We don't have inhouse designers or designated jobs so everyone does the same tasks (coding, designing, testing, db, etc). Thanks!


What is the difference between a procedure-oriented and a problem-oriented programming language?

This is one of the questions given to us an assignment and I've tried to search for this on the internet but didn't get the required answers. Would be great if examples are provided too :)


What hat should a programmer not wear?

In my experience, software developers tend to wear multiple hats and fill multiple roles with different responsibilities. From not only coding, but sometimes also writing SQL, designing the user-interface, designing the database, graphics manipulation, to even QA testing. **If the primary role is to write software/code, what roles should the developer not take on?** Are there any? The intention of this question is not because a developer is incapable of filling another role-- but having the additional role actually _works against the primary role_ , or should really be a dedicated role of someone who does not primarily program.


Are we developers mere tools in the hands of visionaries and business people?

Dear fellow programmers I'm the CTO and the lead programmer at our start-up. Our CEO came into office with hurry and asked me to reschedule so we can pick a very important customer at the airport. When at the airport, I realized the customer is actually more of a business man, a visionary (and a quite successful one) than a programmer. I knew from somewhere else that he was a programmer once so I asked him what happened? After a long humiliating look at my expense he replied : "-What happened ? I have people to code for me !" I have been thinking about what he said since that moment. I am bit by bit losing my interest in development and feel like we are all kinda 2nd class citizens in the IT industry. I can't help feeling like programmers and technical people in general are mere tools in the hands of more visionary people. Your insights are most welcome. EDIT: As it appears, to some the question is unclear. What I'm asking is a comparison between technical and visionary people and to give evidence that technical people are not replaceable work-units in the big scheme of things. The story is just to give the reader a picture of the problem.


Is it bad practice to pass instances through several layers?

In my program design, I often come to the point where I have to pass object instances through several classes. For example, if I have a controller that loads an audio file, and then passes it to a player, and the player passes it to the playerRunnable, which passes it again somewhere else etc. It looks kind of bad, but I don´t know how to avoid it. Or is it OK to do this? EDIT: Maybe the player example is not the best because I could load the file later, but in other cases that does not work.


Programming to ANSI standards (for engineering)

I am currently tasked to write a software to help engineers design standard compliant designs. If there is a bad design, software will report an error or warning. Maybe it's just me, but anyone who has done this should be familiar with the massive amounts of ANSI standards tables like this one: http://en.wikipedia.org/wiki/Nominal_Pipe_Size Computers are, as its name suggest, computing machines, not lookup machines. I feel that feeding formulas into computers and churning out standard compliant designs is much more efficient than doing memory intensive data lookups that are prone to human input errors and susceptible to "data updates". I actually think that there are formulas to calculate all those numbers, but nobody so far could give me that information. Anyone been through this before? What is **THE** best approach to this? Thanks for sharing.


What quality standards to consider for software development process?

i'm looking for metrics/standards/normatives to evaluate a given "Software Development Process". I'm NOT looking to evaluate the SOFTWARE itself (trough SQUARE and such), i'm trying to evaluate software development PROCESS. So, my question is if you could give me some pointers to find this standard, considering that "evaluation objetives" would be documentation quality, how good is the customer relation, how efective is the process, etc. Very much like a ISO 9000, and like CMMI on a sense, but much lightweight and concrete and process oriented, not company oriented. Please help, i'm trying to stablish the advantages of our development process as formal as i can.


What to do with obsolete code?

Code that we no longer use builds up. So what should one do when one doesn't need it anymore? Deleting it feels wasteful, especially large chunks, and there's always the chance the exact same thing will be needed again later. Commenting the code out is nice because it leaves it in place for later, but then the code can start to get cluttered. Version control keeps everything clean and in the right place without the fear of deleting anything, but finding the right code in the version histories is often a project of its own. It's also not great practice to commit code that doesn't work just because you might need it later. **Q:** Does anyone have a good solution to managing obsolete code?


How does Python work?

This question may seems a little bit silly, but what the heck. I started to learn Python. I know basic syntax, etc. When I work with HTML, PHP, etc., I simply write code, put it inside .html or .php file and double click this file. Then my code runs. I can work with databases and other stuff - it's just simple. But how does Python work? I'm working inside Eclipse or Python command line and I can run this code, but what if I want make website with Python for example? I don't think it's like I put .py file on my server, so what I need to do? I understand I need to install Python on my webserver through some server command line (I've never used it, but I will find some tutorials day I will need it) but what's next? How can I combine my Python knowledge with HTML, CSS, PHP, etc.? Python may also be used to create desktop apps, what then? Can I export .exe file with Python code or what? Any links with content describing my concerns are welcome!


What do you think are the biggest software development issues, in small to medium businesses?

I own a small software development company that developes Web software to other small and medium companies in Chile. The business process is very complex and it is hard to stablish where to put the efforts to make our company better, more efficient, and give better solutions. I'm also a TI master's degree student and i'm making a paper about this subject, so any help would be great to help my company and my paper. I have considered 3 areas for the problems: 1) Software development problems   2) Web development problems   3) Small and Medium companies problems I don't know about you, but at least this "business formula" in Chile has not received very much support but it is getting better, but today my company is far from being self-sufficient. UPDATE: Thanks guys for your support so far, i'm updating because i have somewhat enough information so i decided to go deeper within the subjects, wish i would like you to consider for your next answers/commentaries on the subject: 1) Software development problems (3) 1.1 Incomplete problem picture   1.2 Useless delivered software   1.3 Unrealistic or inadequate schedule 2) Web development problems (3) 2.1 Apparently non-viable implementation   2.2 Unefficient module construction design   2.3 Reduced result system inter-operability 3) Small and Medium companies problems (3) 3.1 Very specific, but narrowed requerired system characteristics   3.2 Developed system is not used   3.3 Positivist demand for activities in project execution There are only 3 problems for category, to deliberately keep a thiner scope. Also, i have considered that it would have been apropiated to separate the third clasification on two, but won't be doing it just now: 3) Small and Medium software developement providers problems 4) Small and Medium software developement clients problems In that case, i think i would have made the scope of the problem wider and it is not what i want to do now, until at least i'm very trough with the other two clasifications. What you think?


Next in Concurrency

For past year I have been working a lot on concurrency in Java and have build and worked on many concurrent packages. So in terms of development in the concurrent world, I am quite confident. Further I am very much interested to learn and understand more about concurrent programming. But I am unable to answer myself what next? What extra should I learn or work on to inherit more skills related to Multi-core processing. If there is any nice book (read and enjoyed 'concurrency in practice' and 'concurrent programming in java') or resource's related to Multi-core processing so that I can go to the next level?


Do you obfuscate your email address in open-source code to prevent spamming?

I've been thinking of releasing a few projects, and most authors in the community leave their email address right in the code, often as is or using commonly used schemes like "meATNOSPAMgmail.com", which sort of gets my paranoia flag up... When releasing source code publicly, does it often lead to your email address being parsed by spam bots, and if so how do you obfuscate it ?


How to have two different programmings with two different languages interact?

I don't know if this is too broad or not, but I am a youngish programmer still in college, its my Junior year. I feel like I have a pretty good grasps for different languages and have a pretty good base. But I am stumbling to think how if for example, I am trying to create a program and say I wrote one part in python just because its easy, and does the job, but this program would need to get output from another program that I wrote in C and I am using C because of its speed. I am not sure how to have the two different programs and languages interact with each other to create an overall one total program. I am thinking of like sure you can write to a file, but then what if python and C programs both accessing a file I would need to think of locks. Most times I have done this was with importing files into a program, but in that case they are the same language so that is easy I just use the import function, but with two languages/programs interacting to create one cohesive output I am having trouble. I was thinking about this question because I was thinking of diving into creating some basic web applications just to learn but I have no idea how to have say javascript file interactive with something that I wrote in python or vice-versa. I feel like I am missing something really easy here and just not understanding. Sorry if this question is too broad but I couldn't really find a clear answer online, I was trying to look through an opensource webapp, but couldn't really grasp an answer from it, again pardon me if the question seems dumb I thought this be a good place to ask I love reading on stackexchange. Thank you for any reply.


Is `catch(...) { throw; }` a bad practice?

While I agree that catching `...` **without rethrowing** is indeed wrong, I however believe that using constructs like this:               try     {       // Stuff     }     catch (...)     {       // Some cleanup       throw;     }      Is acceptable in cases **where RAII is not applicable**. (Please, don't ask... not everybody in my company likes object-oriented programming and RAII is often seen as "useless school stuff"...) My coworkers says that you should always know what exceptions are to be thrown and that you can always use constructs like:               try     {       // Stuff     }     catch (exception_type1&)     {       // Some cleanup       throw;     }     catch (exception_type2&)     {       // Some cleanup       throw;     }     catch (exception_type3&)     {       // Some cleanup       throw;     }      Is there a well admited good practice regarding these situations?


Separate domain entity in small ones

I have the Customer entity, this entity has a huge list of attributes, so you are thinking in separate in small entities (for example: "basic info", "document", "declarations", etc). This approach will be used in the view layer, where the user can fill your info, step by step, making possible stop and comeback later. But I'm no sure if make sense to reflect this fragmentation in others layers. Because, we will have a lot of controllers in client and server side (since we are using express.js and angular.js). Follows an overview of the complexity in terms of fields, remembering each "partial" must be valid and once valid, it is saved in the database:               - info for generate the customer       -- name       -- email     - basic info       -- dob       -- gender       -- hometown       -- state       -- country     - phone info (just one phone)       -- prefix       -- phone number     - bank info (can be more than one)       -- bank       -- agency       -- account number     - etc      Any suggestions?


Form cancellation. Where should any data rollback occur?

You have a form that has an object injected into it. The user interacts with the form and updates the injected object via the UI. If the user then 'Cancels' the form, whose responsibility is it to undo those changes? Should the form have created a clone of the object passed in, and return that to the client? Or should the client watch for the 'Cancel' action and perform the undo action? Is there a 'best practice' for this?


Am I doing TDD wrong when multiple tests can fail for the same reason?

Assume a method with the following declaration               public IList<Location> GetLocations() { ... }      I write (at least) the following tests   1. Check to see if the method returns an empty collection if no locations are found.   2. Check to see if the method returns the correct number of locations.   3. Check to see if the data in the locations the method return is correct. However, all the tests above will fail if the method returns null. I feel like a single error should only result in one unit test failure, but at the same time I do not see how to avoid it in a scenario like this. Is this just the way it works; sometimes multiple tests will fail for the same reason?