Understanding hand written lexers

I am going to make a compiler for C (C99; I own the standards PDF), written in C (go figure) and looking up on how compilers work on Wikipedia has told me a lot. However, after reading up on lexers has confused me. The Wikipedia page states that: > the GNU Compiler Collection (gcc) uses hand-written lexers I have tried googling what a hand written lexer and have come up with nothing except for "making a flowchart that describes how it should function", however, isn't that how all software development should be done? So my question is: "What is a hand written lexer?"


How Python random shuffle works?

How shuffle from random works in Python? I ask because it works very fast. When I try to write shuffle it works 1 minute for 10^6 element, but Python shuffle does that in 8 sec?


How to properly learn ASP.NET MVC

I have a question to ask and maybe some of you will think it's lame, but I hope someone will get me on the right track. So I've been programming for quite some time now. I started programming when I was about 13 or so on Delphi, but when I was about 17 or so I switched to C# and now I really like to program with it, mostly because it's syntax is very appealing to me, plus managed code is very good. So it all was good and fun but then I had some job openings that I of course took, but the problem with them is that they all are about web programming. And I had to learn PHP and MVC fundamentals. And I somewhat did while building applications using CI and Kohana framework. But I want to build websites using ASP.NET because I like C# much, much more than PHP. **TL;DR** I want to know ASP.NET MVC but I don't know where to start. What I want to start with is build some simple like CMS. But I don't know where to start. Do I use same logic as PHP? What do I use for DB connections? And also, if I plan to host something that is build with ASP.NET MVC3 on a hosting provider do I need to buy some kind of license?


How do you include Support in your Sprint?

Our company moved to Scrum recently on a product that was almost coded by a single person (Joe). We have support to do with our exising customers that we try to integrate in our process. For now we tried the following approach:   * We do a rotation on a person in charge each week.   * The person in charge for the week may spend up to 8 hours on support. But we failed to have it work:   * Joe always does the support because he knows the code better, and it's always faster for him to do it than to explain it.   * We (the rest of us) tend to focus on what's on the Sprint board aka new stories instead of support tasks.   * Joe has too much work, he can't handle all the support by himself because he has to do things outside of the Sprint as well. Have you already faced similar situation? How did you manage to get out of it? Note: We can't dedicate a single person on the support right now. We hope to in the future.


What happens if I close an InputStream that is passed as an argument?

I have read that Java is pass-by-value, and I've been reading about it in this question at StackOverflow, but I'm still a bit confused, regarding the close() or shutdown() methods in various classes. What I want to know is, suppose that I do this:               public Constructor(){              if(isProceeding){             InputStream iStream = new InputStream();             processStuff(iStream);         }     }               public void processStuff(InputStream stream){         //do stuff         stream.close();     }      Does the iStream variable actually get closed in processStuff() method or a copy of it gets closed and iStream itself is still left open?


Algorithm for rating books: Relative perception

So I am developing this application for rating books (think like IMDB for books) using relational database. **Problem statement :** Let's say book " **A** " deserves 8.5 in absolute sense. In case if A is the best book I have ever seen, I'll most probably rate it > 9.5 whereas for someone else, it might be just an average book, so he/they will rate it less (say around 8). Let's assume 4 such guys rate it 8. If there are 10 guys who are like me (who haven't ever read great literature) and they all rate it 9.5-10. This will effectively make it's cumulative rating greater than 9 (9.5*10 + 8*4) / 14 = 9.1 whereas we needed the result to be 8.5 ... How can I take care of(normalize) this bias due to incorrect perception of individuals. **MyProposedSolution :** Here's one of the ways how I think it could be solved. We can have a variable **Lit_coefficient** which tells us how much knowledge a user has about literature. If I rate " **A** "(the book) 9.5 and person " **X** " rates it 8, then he must have read books much better than " **A** " and thus his Lit_coefficient should be higher. And then we can normalize the ratings according to the Lit_coefficient of user. Could there be a better algorithm/solution for the same?


Is it correct that Java Applets can do hardware acceleration while Flash can't?

I hope you can confirm or disprove whether I understand this correctly. I know for certain that Java Applets can have hardware acceleration and I wonder if this is the only known way to have graphics hardware acceleration in web pages or is there another way?


Functional Programming - Does Knowing It Help Job Prospects?

The main language that I use at the moment is C# and I am the most comfortable with it. However, I have started dabbling in F# and Haskell and really enjoy those langauges. I would love to improve my skills in either of those languages over time since it truly is fun for me to use them (as opposed to Ruby, which is hyped as "fun", I just don't get where the fun is, but I digress...). My question is directed at those who have hired/interviewed for programming positions (junior/mid-level): if you see a functional programming language on a resume, does it affect your opinion (whether positive or negatively) of that candidate? My rationale for knowledge of functional programming affecting the view of a candidate is because it can show that the candidate can adapt to different methodologies and take a mulit-dimensional approach to problems rather than the "same old OO approach". (This may be off-base, please let me know if this assumption is as well!)


How have you made unit testing more enjoyable?

If you've always loved unit testing, good for you! But for the unfortunate ones who weren't born with a liking for it, how have you managed to make this task more enjoyable ? This is not a "what is the right way to unit test" question. I simply want to know little personal tricks that reduce the boredom (dare I say) of writing unit tests.


Getting into JEE

I'm the author of this question from a couple of months ago: Java but no JEE experience I thought about just editing this question, because this a bit of a followup to it - but it's actually a different enough context to ask separately. Answers would cross over and the thread would get messy if I do that. Anyway, basically, in the past couple of months I've done a pretty intensive review of my JEE knowledge. Worked through a book, built apps from scratch, etc. At least in terms of a basic built-out-of-the-box Servlets/JSP CRUD app, I can say that I know how a JEE web application works now, how all the plumbing and configuration hooks up, etc. And I've got a much more comprehensive understanding of the JEE model in general than I had before. Here's my question: I'm hoping to go into JEE (probably web development, but preferably more the data-driven back end side of things) and am wondering if this knowledge is sufficient to start applying for work in the JEE space. I get conflicting reports: Some people say that good general programming skills + strong core Java are all that's needed, and others say that you actually need strong experience in the specific JEE-related frameworks and technologies for the given JEE roles. It's hard to get a good read on what's right - and I don't want to look ignorant for applying for things which I'm clearly not ready for. I have very strong core Java and almost a full decade of commercial programming experience, but really can't claim any of it as strong commercial JEE (only Swing, Applets, and lots and lots of core Java). **Note** : If it helps, I can mention I don't mind taking a job a notch below what can be expected with my overall level of commerical experience - to get into JEE. All this is mainly because the market for Applets and Swing development is pretty much dead at the moment, and I need to expand my Java ecosystem experience.


Cocoa Applications: Use custom preference dialog or system preference app?

When writing **_Cocoa Applications_** for **_MacOSX_** , you have the choice of either having a custom preference dialog, or using the **_Settings.app_** to manage your preferences. Functionality wise, there is no difference at all between the two (apart from the fact that preferences in the Settigns.app can be accessed when your app is not running). Which solution do you use and why?


What is logical cohesion, and why is it bad or undesirable?

From the c2wiki page on coupling & cohesion: > Cohesion (interdependency within module) strength/level names : (from worse > to better, high cohesion is good) > >   * Coincidental Cohesion : (Worst) Module elements are unrelated >   * **Logical Cohesion : Elements perform similar activities as selected > from outside module, i.e. by a flag that selects operation to perform (see > also CommandObject). i.e. body of function is one huge if-else/switch on > operation flag** >   * Temporal Cohesion : operations related only by general time performed > (i.e. initialization() or FatalErrorShutdown?()) >   * Procedural Cohesion : Elements involved in different but sequential > activities, each on different data (usually could be trivially split into > multiple modules along linear sequence boundaries) >   * Communicational Cohesion : unrelated operations except need same data or > input >   * Sequential Cohesion : operations on same data in significant order; > output from one function is input to next (pipeline) >   * Informational Cohesion: a module performs a number of actions, each with > its own entry point, with independent code for each action, all performed on > the same data structure. Essentially an implementation of an abstract data > type. i.e. define structure of sales_region_table and its operators: > init_table(), update_table(), print_table() >   * Functional Cohesion : all elements contribute to a single, well-defined > task, i.e. a function that performs exactly one operation > get_engine_temperature(), add_sales_tax() > (emphasis mine). I don't fully understand the definition of logical cohesion. My questions are:   * **what is logical cohesion?**   * **Why does it get such a bad rap (2nd worst kind of cohesion)?**


Is Intellisense faster in Visual Studio 2012 compared to Visual Studio 2010 for C++ projects?

We switched to VS2010 from VS2003 a few months ago, and there are many many improvements. But the speed of Intellisense is not one of them (although it does generate higher quality results, which is great). I read that Intellisense and the MSDN help system has been improved in VS2012. I'm curious if its actually faster? The only data I could find were graphs of an early release (VS2011). For the record, I am using a vanilla install of VS2010 with SP1 on Windows 7 SP1 (x64). No plugins or add-ins running. What I'm looking for specifically:   * Has the speed of intellisense auto-complete improved?    * Has the speed of F12 (GoTo definition) improved? The answers to these questions will help in determining if VS2012 is worth the money to upgrade at this time as the intellisense slowness would be the only major reason for upgrading. I'd also be interested in knowing if the help system has improved. I'm currently using MSDN help from VS2008SP1 because it has filtering and is faster.


How long is a typical modern microprocessor pipeline?

I learnt some about pipelining but those were 4-stage and 5-stage and I think that modern pipelining typical is much longer and more complicated in practice. How long are typical pipelines and how much can we expect them to increase and where is the point of reaching diminshing returns in performance gains for longer pipelines?


Is RESTful API appropriate for services which are nearly computational in nature?

Is RESTful API appropriate for the following scenario?   * A time-limited token is obtained, which will last for one minute only   * Image is uploaded to a server   * Server performs some CPU-heavy image processing upon request, within the time limit   * The result is available for download, within the time limit   * When the token expires:      * The image, computation, result are all discarded / terminated, and any open connection will be closed.   * All other necessary aspects of web services, such as authentication / service authorization, quota, encryption etc., might still be necessary. Since the "resource" is only allowed to exist for less than one minute, does it still make sense to make "resource" the first-class citizen in this API? * * * **Update** I have found this link that talks about a REST API for job queueing in RabbitMQ. However it is an "idea page", so I'm not sure whether this is relevant or not.


Interview question "What is virtual function"

It was funny for me, and I'm interesting the reaction for this question of the community. It was interview for C++/Qt developer, and question was asked **"What is virtual function"**. Not something like "how polymorphism in C++ works" or "how virtual functions works" but what is. My first thought was to answer "Virtual functions(methods) are methods that have word "virtual" before it's signature", but I explained about how they works =) What do you think, is this a proper formed question? And what will you ask for that question? PS: I hope that this part of stackexchange are proper for this question


Where should I store the files for python modules I install?

If I download a module for Python (such as alglib) and installing is simply a matter of running               python setup.py install      Where should I be keeping the files I download, or the files that get created after I run setup.py? Is there some neat folder in the python directory that people put these modules before running setup.py? Can I move the files around after running it? Can I delete them... or will that stop them working? I couldn't find any recommendation here: http://docs.python.org/2/install/ Also I am running windows and installed python through python(x,y)


Java BufferedReader vs Separate Producer consumer thread

I have a very big file delimited by some sequence of characters '*L*I*N*E'. The file will be of the order of 250G. And each line comes around 600bytes to 1000 bytes. I will be performing the following operations on the file, Read the file line by line and for each line, I will be giving it to a parser which will do some calculation on the line and update some stats. The parser will take roughly 15 micros per line. As of now I am using the `BufferedReader` to read the lines and pass it over to the parser in a single thread. My question is if I have a separate reader thread which only reads the file and dump everything in a queue (in memory) and have my parser act on the in-memory queue(in a separate consumer thread), can I achieve better throughput? Nothing changes except that my parser acts on the inmemory data and another thread takes only IO operation(read the file and dump in a queue). It is a complex piece of software in which the above is one part, so I am trying to speed up the above part. Hence I can't able to post the actual code.


How do you convince coworkers/stakeholders to try new technologies?

I've got a coworker/manager/stakeholder who is very conservative when it comes to adopting new technologies. I completely understand why: we have a lot of internal expertise with Java, MySQL/Postgres, and so on, they're well- established, and there's lots of good support for them. But technology evolves, and sometimes newer technologies are better suited to today's tasks. It makes sense, for example, to do heavy numeric processing in something like Python+Numpy. Some kinds of simple web sites are faster and easier to implement in Ruby/Rails. Processing hundreds of gigabytes of logs a day is well suited to a Hadoop M-R architecture. But I often encounter a lot of resistance to bringing new technologies into the mix, even when I think there's a strong case for it. The resistance even goes down to minor details, like using a heavy JavaScript front-end and web services rather than server-side heavy JSP for a recent project. The most common objection is that because we don't have significant expertise in the technology, it won't be maintainable if I'm not available to do it myself. How do you work with people like this to overcome these kinds of objections?


How important is an SSL certificate for a website?

I'm bootstrapping my own project, it has a registration/login area (via devise with RoR, properly hashed and salted of course). As I'm using subdomains and I need to access them with iframes (it's justified, really!) I'd need one of those expensive certificates that cover subdomains. As I'm doing this out of my own time and money, so I'm hesitant to drop a couple of hundreds on a certificate, plus a couple of hours delving into something I haven't tried before. I'm not storing any sensitive information besides the email address and the password. As far as I understand, the only vulnerability happens when a user logs or signs up from an unencrypted network (such as a coffee shop) and someone is listening the network. Am I being cheap? Is this something I should tackle before releasing into the wild. I probably should mention I have 25,000 users signed up to be notified when I launch, so I'm nervous about it.


Clients with multiple proxy and multithreading callbacks

I created a sessionful web service using WCF, and in particular I used the `NetTcpBinding` binding. In addition to methods to initiate and terminate a session, other methods allow the client to send to one or more tasks to be performed (the results are returned via callback, so the service is duplex), but they also allow you to know the status of the service. Assuming you activate the same service on multiple endpoints, and assuming that the client knows these endpoints (for example, it could maintain a `List` of endpoints), the client should connect with one or more replicas of the same service. The client periodically updates the status of the service, so when it needs to perform a new task (the task is submitted by the user via UI), it selects the service currently less loaded and sends the task to it. Periodically, the client also initiates a maintenance procedure in order to disconnect from one or more overloaded service and in order to connect with new services. I created a client proxy using the _svcutil_ tool. I wish each proxy can be used simultaneously by different threads, for example, in addition to the thread that submits the tasks using a proxy, there are also the following two threads which act periodically:   * a thread that periodically sends a request to the service in order to obtain the updated state;   * a thread that periodically selects a proxy to close and instantiates a new proxy to replace the closed one. To achieve these objectives, is it sufficient to create an array of proxies and manage their opening and closing in separate threads? I think I read that the proxy method calls are thread safe, so I would not need to perform a lock before requesting updates to the service. However, when the maintenance procedure (which is activated on its own thread) decides to close a proxy, should I perform a lock? Finally, each proxy is also associated with an object that implements the callback interface for the service: are the callbacks (invoked on the client) executed on different threads on the client? I would like to wrap the management of the proxy in one or more classes so that it can then easily manage within a WPF application.


How do you stop yourself from bringing work home?

Programming is a highly cerebral job, and one of the biggest problems I have is bringing my work home with me. It's so easy to do: whenever I get the chance to think, my mind naturally wanders to work-related matters. I find so many of the other things in my day rather mentally unstimulating and as they say, nature abhors a vacuum. Unfortunately, constantly thinking about work is stressing me out and I can't seem to just flip that switch at the end of the day. It's been causing me quite a bit of insomnia. To make matters worse, nearly all of my friends are co-workers, and many of our conversations do very little to make me forget about the week. They're fun people to be around generally, and once we've had our bitch-fest we all stop talking about work, but suffice it to say it does little to encourage me to forget about work-related matters. So what can I do to leave my programming projects behind me at the end of the day? Or failing that, what type of mentally stimulating activities couuld I do to occupy my non-work hours with (that are non-stressful and don't involve mind-altering drugs)?


Why are people afraid to die()?

I have seen a lot of people (first comment) hating `die();` instead of `exit;` As the follow-up comments on that post note, `die` and `exit` are the same - the attitude appears to be one of perception, with some feeling that one name is more appropriate in certain contexts than others. But why does it matter? If they do the same thing, why should I care what name I use? Does death by any other name not smell as sweet?


Is it worth using tool agnostic concepts in a development team?

We waste a lot of time using tool specific terms when we are all really talking about the same things. The problem is that person1 is familiar with toolset1, person2 with toolset2 etc. So each uses a set of terms that they are the most comfortable with and in the end, we end up talking at cross purposes. Has anyone come across this problem in your work place? How did you resolve it? I am asking specifically about development teams here.


Transitioning into a programming career from system administration

I have a bit of a unique story. I have some work experience in IT, which I've come to generally loathe, and about a year left on finishing my physics degree. I would like to pursue physics further but the career path is pretty grueling and I've decided against it. I know (or knew) the fundamentals of a good handful of languages: Java, C, C++, PHP, and am familiar with SQL. In my physics degree I've done some research that required a good deal of C++ programming, albeit in a format that is more procedural than OOP, as is common when scientists try to program. I'd like to convert my experiences to a career in some sort of lower level programming, embedded devices, drivers or scientific/mathematical programming and the like, as I don't particularly enjoy the idea of writing websites or other manner of CRUD applications for 50 hours a week. I've done enough LAMP stuff to know it doesn't really interest me. That said, I am flexible and have only a nebulous idea of what I want to do. So the question I pose is how to position myself well to start up such a career as a new grad in about a year or so? I certainly need to shore up some fundamentals as it has been a long while since I learned and am pretty rusty. Secondly, I don't have any sort of show-able portfolio as my physics research doesn't really lend itself to that, although perhaps there is an opportunity to parlay some of the stuff I've been doing into a more discreet project. Lastly, I am worried that my IT background on my resume will typecast me as a sysadmin type and not allow me to break into the more enjoyable, for me at least, world of programming. Thanks! TL;DR: Physics degree and IT work wants to convert to a career doing lower- level programming.


I want to draw class diagram, but I don't know how to put server and database inside?

I just started to draw class diagram, I think it is based on 3-tie architecture. I have mobile application, servers, database, and web interface. But I do not know if it should put the server in? I just want to write a high- level one.


Should the admin interface of a public-facing webapp be accessible externally?

I am working on an application right now that needs a way for employees to log in to the back-end of the public facing application for some basic reporting. If you were creating this, would you put the admin interface on the public side or on the intranet side? Update: It is the back-end of our eCommerce application. I am logging all of the transactions with the CC processor (NOT the sent data, just the response from the processor) and the processed transactions to aide in us being able to troubleshoot when a customer has a problem. Kind of a one-stop-shop instead of looking up in multiple places. They should be in the office when doing this. This is an ASP.NET MVC project if that matters.


Translating error messages from an external API?

If I am localizing a piece of software that uses an external API, how should I handle error messages that originate in this API? I do not control the API, I only consume it. The error responses are not very structured: some contain error codes, some contain verbose details in the text, others almost nothing. Some errors can be fixed by the user (incorrect configuration), some are caused by the external service (server overload), some could be caused by a bug in my software (of course, this would be very unlikely...). I would like to provide a smooth experience to my end-users, so they know what went wrong and what they can do to fix it. What is the best strategy to use here? _(This is a generalization ofa question from the WordPress Stack Exchange. I thought it would be worth re-asking here, because it is not limited to WordPress plugins.)_


What is the proper way to pass the parameters into a MVC system?

I am trying to learn java servlet/jsp with the MVC concept and built the simplest MVC application. Now I want give more detail to it to enhance my understanding. If I would need to register a new row in a table in the database, how should we pass the various value of column into the system? For example, the user might want to register a new event in his planner and the detail of the event involves the 'where', 'when', 'who', 'detail', etc. Should pass all this long value from the servlet's parameter, i.e: the http link?               String accNo = request.getParameter("account_number");     String a = request.getParameter("...");     String b = request.getParameter("...");     String c = request.getParameter("...");     String d = request.getParameter("...");      To illustrate my view that it is really unprofessional to show all the parameter on the link:               http://localhost:8080/domain1/servlet1?param1=55555555555555&param2=666666666666666666666666666666666666666666666666666666666666&param3='Some random detail written by user.........................'      Is there other way to pass them?


How do I demonstrate what I've learned outside of the workplace?

I consider myself a well-rounded developer. I read books, delve into technologies at home, go to developer meet-ups, frequent Stack Overflow, and so forth. But how do I show this to the prospective employer? If I read a book on Hibernate but we don't use it at work, how do I show it on my resume that I know Hibernate? Would having a side project that uses it and putting it on GitHub help? How do you all tackle this problem?


How do I tell if a Company is really serious about Agile and Scrum?

> **Possible Duplicate:**   >  Weeding out real agile from buzzword agile in an interview I went for an interview. The company really wants to take me on. However my sticking point is that I have not received clear information on whether they are using Agile and Scrum methodologies. I have arranged a telephone chat with the consultant there... what questions do I ask to test to see if they are really serious about agile and scrum? I was thinking:   * Can you build and release your software in one step?   * Do you use continuous integration? Can anybody give me advice to really get the truth out of them I will only get this one chance to quiz them. Regards, Pete


How to develop front end (UI) for my Django website

I am learning Django and new to web development. Please excuse me if you find this question too dumb. So, I am creating a Facebook application using Django which I would like to host in Google App Engine. The project would be focusing on reading RSS/ Atom feeds of any website (That's all I can say now). I am sure enough to process the RSS/Atom files but I am worried about the front end (User Interface) part - "The design part". I don't know HTML/ CSS/ JavaScript (I can handle simple HTML stuff but that doesn't lead to any designing thing). First, I thought of using tools like dreamweaver or any equivalent software for designing UI but when I really started learning django and getting into it, It seems to be a "not possible" thing. So,   * How should I design the UI part of my site? Can't I use tools like dreamweaver?      * If NO, what's the best way for guy like me who doesn't know JavaScript/ CSS     * If YES, what's the best open source alternative to dreamweaver?     * Can Google App Engine handle all this suff?   * How people who deal with Django edit those template pages. The Django mentions the it will separate the logical (views) and design (templates) parts so that different departments in a company can handle separately. But Considering the fact that the Django's HTML pages are filled with "tags" which are no way related to HTML (designing), how UI people handle it?


Documenting a programming language: Reference Manual

We are looking at revamping documentation across our product line. Part of that includes **reference manuals** for a **programming language** used as part of the system. When writing a reference manual for a programming language, what is the best way to structure it for maximum usability to those new to the language? What are the **key aspects** for each keyword documented?   * Syntax   * Description   * Arguments - if applicable   * Return values - if applicable   * Example of usage?   * Any others I'm missing? **Should concepts** (such as locking strategies, performance related details) be also documented in this reference manual, or is that a separate document? * * * This is for external consumption. We already have full doc sets (see: http://www.rocketsoftware.com/u2/resources/technical-resources). Working out what we should do different - I already have my ideas, but as always, I try not to rely solely my my opinion. Audience: Technical developers using our database(s) & tools to produce software across many industries.


Using ASP.NET 4 and Stored Procedures

How popular are **stored procedures** today, compared to 5 years ago? I ask this question because the book that I'm reading (an ASP.NET 4 book) has no stored procedures in it. Is it the ASP.NET 4 way now?


Web application development security best practices

I am looking for the current, state of the art, coding standards for web development (mostly PHP). Since I do not want to reinvent the wheel I would like to reuse libraries written by people much clever than I am. I know about OWASP which is a wonderful source of best practices and brilliant information. Their web site is however quite unorganized when it comes to libraries.   * On the one hand there is OWASP ESAPI with pointers to libraries.   * On the other hand there is OWASP AntiSamy, which also has libraries. It in turn points to HTMLPurifier or the MS Anti-XSS library. I did not find any links between these different solutions. Is there currently a consensus on the most recommendable libraries to use in order to mitigate the major security risks? Thank you


Does Parallel Inheritance Make for Good Code?

I'm writing a database interface in PHP and I have a base `dbTables` class, as well as a base `dbTableFields` class. `dbTables` has a function, `getFields()`, that instantiates `dbTableFields` objects, each of which carries essential data on each table field, and puts it into `dbTableFields->fields=array();` `dbTables` has several children. Now I've realized that the children need to use different versions of `getFields()`. But they only differ in one place: they need to instantiate `dbTableFields` children, rather than `dbTableFields` objects. I've solved this problem. I took advantage of PHP's ability to use variables to represent class names. All I had to do was, in `dbTables->getFields()` replace:               $this->fields = new dbTableFields();      with               $this->fields = new self::$field_model();      Where `self::$field_model = 'dbTableFields'; // string value for class` Now, in the child classes, I just have to override the `$field_model` property with the name of the appropriate `dbTableFields` descendents. Is this parallel inheritance scheme good form? Or am I creating an uncompromising mess? Is there some more-elegant and more maintainable method for achieving the same effect?


Emphasize Some Comments - but not Dirty the Code

I'm having trouble structuring my comments at the moment. I have major sections of the code that, when scrolling through the document, I want to be able to see those stand out. Examples: > This is a normal comment: > >> int money = 100; //start out with 100 money - > This is a comment to emphasize a certain part of the code: > >> / ** _*_ ** _*_ **** Set up all the money **_*_ ** _*_ ****/ But I don't like that this isn't very clean. Is there a standard way of setting up this type of a comment?


variable comparison without initialising

I am working with a project in VC++ which involves co-ordinate system having x,y,z axis.   I am trying to check for if a variable(Point with x,y,z values) is assigned on the coordinate system or its a default point(uninitialized) .   Since a coordinate system I cannot assign a default value to the variable to be either negative or positive or even zero since all these are valid values. My approach over here is to have a _Boolean variable_ associated with my _Point variable_. If the Boolean is set then Point assigned else not. Now I have to check for each and every statement where the value can be assigned and set the Boolean. Now I tried with this approach which is pretty bad and you may consider it as wrong. What I am doing here is taking an uninitialized float variable (since x,y,z members of Point are float) and comparing it with x,y,z members of Point variable.   Since in the case where Point is uninitialized both float variable and members of Point match and I can declare its uninitialized. I have tried to test this on different compilers and I get the result as expected.   Obvious I get a compiler warning for **uninitialized variable used for comparison** My question, Is the second approach really bad or is there any workarounds over this.


Let go yet again from another job, should I give up on programming?

I've been let go three times from three different jobs already in the past four years. The first job was doing seismic interpretation software in C++. It lasted nearly three months. The reasoning was that I had excellent C++ skills but I had serious communication issues. My second job was at a flash social games company. Again I lasted nearly three months, with the reasoning being that once again I had poor communication skills and was slow to pick up the pace. My last job was at a regular casual flash game company. I lasted 1 year and 9 months on this one. The reasoning for my dismissal this time being that they had to lay off staff due to the economy, so they picked two programmers. I was picked because even though I produced quality code, I could not finish it in a reasonable amount of time. My boss told me once more that he thought I was a good programmer and he wouldn't say no to rehiring me in the future if I managed to get some experience in IOS programming, given their interest in moving in that direction. My concern is that I somehow doubt if I'm even fit to be a programmer at all. Even though I can do some impressive stuff that few people can do (I was hired at my last job because I was able to create a pretty impressive 2D/3D demo in flash from scratch, even though they had already filled the role), it almost always takes me nearly twice as long as anybody else to achieve the same results. Even when I'm doing the simplest tasks, such as typical state machines for character behaviour in a 2D platform game, I feel like my brain somehow freezes for no particular reason. (It's been like that ever since I can remember for the past 12 years or so, but I thought it was something that happened to everyone.) I tried staying late pretty much every day, but still it wasn't enough for me to catch up. All of this was made worse by the stress that built up from knowing how slow I was, wondering if my boss was going to call me that day to give me the bad news. I'm naturally a very stressful person, so I recognize that stress in itself makes me even slower. I feel like I've lost all motivation and ambition to learn new things, and that I should just give up on programming and simply focus on doing simpler, less stressful things like working at a library or something, and just forget about having a career, because I simply cannot do anything else. Programming is all I know. So what I'm asking of you is a serious opinion on the matter, given the few details that I've given to you. I've already started looking for a new job, but I'm wondering if it's going to turn out the same. I know I have to be posititve about things, but how can you stay positive when you've failed so many times in such a short time?


At what stage of an Open Source project should you invite contributions from the community?

I've been wondering about getting contributions to a new open source product my team will be developing. There's encouragement for us to get as much support from the wider community as we're able, but I can also see this absorbing a lot of time making sure that 3rd parties located outside our office are on track regards things like code quality. Also at the start of the project we're likely to have a lot of informal discussions within the core team regarding design of the system, spikes etc. and taking these online to allow community involvement will be time consuming and I can imagine could make the discussion less effective. There is a more human side to this which probably needs to be considered: allowing community involvement in the design process may also have its benefits regards perceived ownership of the project, and there's always a chance that early involvement could pick up on problems that the core team haven't noticed. So the question: at what stage of an Open Source project should you invite contributions from the community?


How do I deal with analysis paralysis?

Very frequently, I am stuck when choosing the best design decision. Even for small details, such as function definitions, control flow, and variable names, I spend unusually long periods perusing the benefits and trade-offs of my choices. I feel like I am losing a lot of efficiency by spending my hours on insignificant details like these. Even though, I know in the back of my mind that I can change these things if my current design doesn't work out, I have trouble deciding firmly on one choice. What should I do to combat this problem?


Implementing base-10 floating point division

I'm implementing floating-point arithmetic, for a micro-controller which does not support floating point numbers, in either hardware or software. (Software being "written" in a sort of electrical diagram program.) I've finished encoding/decoding from/to integers, adding, subtracting, and multiplication. My "floats" are represented as `C * 10^E`, where:   1. C, the coefficient, is a 32-bit signed integer in the range 100000000-999999999, or 0.      * (Nine digits of precision, plus the special case of zero.)   2. E, the exponent, is a 32-bit signed integer covering the whole 32-bit range.      * (Yes, it's overkill.) I chose round base-10 numbers to make the verification of the math easy. My strategy for the multiplication was to split up the two numbers `AaaBbbCcc` and `DddEeeFff` into three pieces each (millions, thousands, and ones) and compute the multiplication as               (ABC * 10^Y) * (DEF * 10^Z) =       ((AD * 10^12) +        ((AE + BD) * 10^9) +        ((AF + BE + CD) * 10^6) +        ((BF + CE) * 10^3) +        (CF * 10^0))       * 10^Y+Z      Each `*` and `+` representing a normal multiplication or addition, and 10^N being faked with me hard-coding in a 1000, 1000000, etc. Also note that this neither recurses or loops, and any answer cannot recurse or loop. I've got access to integer addition, subtraction, division, multiplication, modulo, cos/sin/tan/arccos/arcsin/arctan, absolute value, and square root. ### Main Question: I can/will eventually figure out how to do division with a similar approach of splitting the coefficients into smaller numbers which will be better for 32-bit division. I haven't done my algebra in a long time, so multiplication took me about a day and a half. Since I presume division to be more complicated conceptually, it would be super handy if somebody on SE could do the hard math for me. So, _how do I do this?_


Is there a language more general than Lisp?

I've been programming for a long time, and writing in Lisp (well, mostly Scheme) for a little less. My experience in these languages (and other functional languages) has informed my ability to write clean code even with less powerful tools. Lisp-family languages have lovely facilities for implementing every abstraction in common use:   * S-expressions generalise structure.   * Macros generalise syntax.   * Continuations generalise flow control. But I'm dissatisfied. Somehow, I want more. Is there a language that's more general? More powerful? As great as Lisp is, I find it hard to believe no one has come up with anything (dare I say) better. I'm well aware that ordinarily a question like this ought to be closed for its argumentative nature. But there seems to be a broad consensus that Lisp represents the theoretical pinnacle of programming language design. I simply refuse to accept that without some kind of proof. Which I guess amounts to questioning whether the lambda calculus is in fact the ideal abstraction of computation.


Is the phrase "never reinvent the wheel" suitable for students?

I find myself constantly running into this expression "don't reinvent the wheel" or "never reinvent the wheel" when I ask some questions on SO. They tell you to use some frameworks or existing packages. I know where this attitude is coming from since it's unwise to waste time on something others have already solved. Or it that so? As a student, I find by using some code others wrote to solve my problem I can't learn as much as I'd like to, and I gain less insight. And sometimes I think that phrase is mainly for working programmers facing deadlines and not for students like me. Is it that bad to "reinvent the wheel"? Maybe I'm thinking it wrong? Maybe there is a way I can avoid reinventing the wheel and at the same time learn a lot?


How does minecraft use a seed to generate a completely unique world?

In minecraft, before creating a world you have an option to input a seed. The algorithm takes the seed and creates a completely unique world. How does this work?


Build a Platform API for public

I am looking for some advices, resources or articles about how to expose a Platform API to outside developers. My main concern is what is the standards or best approach to do that, basically I have a set of REST API services of the platform and need to understand how to address the following issus :   * API Hosting and Management in general (should we use online api management tools like apigee or mashrey?)   * Developer Keys, permissions   * Developer tools, documentations   * throttling   * Reporting   * Logging/Auditing   * Authentication and Authorization It is also great if you can point out to some articles that explain how Facebook or Twitter or Google are doing this, or abstract architecture and management best practices on how to open Platform API to the public users. Thanks,


What is "friend" keyword used for?

Can you explain to me why the `friend` keyword is preferred for giving access rights to private data of class?


UML Class diagrams with Java packages?

I am trying to model in UML 2.0 a Java servlet application that has three classes   * Servlet class; essentially a main class that acts as the controller   * DatabaseLogic; contains methods for database operations   * XMLBuilder; builds an XML from a query result string The classes use a variety of packages from the Java library. I am unsure how to model this in UML Do I have to create a package and show which libraries are used for each individual class or can I just have one large package in the diagram with all the libraries showing which classes have dependencies on which. As per this diagram ![enter image description here](http://i.stack.imgur.com/N05mW.png) This is my first time working with java properly (im a C++ guy) Apart from being a bit messy , is this a correct UML representation of the system I described? Does a Package in UML mean the same as a Package in Java?


How to handle different web root running in iis on locahost vs. web server (iis7)

I have several websites that I help manage. When running on my local machine (under iis7), the websites run on under a folder on my machine d:\WebRoot\TheWebsiteName and run as htt://localhost/TheWebsiteName, but when they are deployed they run as http://www.TheWebsiteName.com (also running under iis7) Currently I am handling the path to the website resources (images, javascript, etc) via code. But I was wondering if there was a better way to handle this rather than writing specialized code in the website. Thanks!


Multi-project multi-team Scrum

2 teams (A and B) in different geo locations are developing Project P. Both of the teams are also developing few other smaller projects: A has projects PA1 and PA2. B has PB1 and PB2. P is the only one common to the 2 teams. The Scrum design today:   * Each team has a PO, and they decide on the priorities together.   * One common Backlog that contains stories from project P and from PA1 and PA2. PB1 and PB2 are done off-scrum.   * Each team has its own sprint and SM. Team A picks stories from the backlog that are related to projects P, PA1 and PA2. Team B takes stories only related to P. The problem:   * I want to manage PB1 and PB2 in Scrum as well. Possible solutions:   * Add PB1 and PB2 to the same Backlog? - will complicate the backlog even more than now.   * Separate to 3 backlogs (P, PA1-2, PB1-2)? - There is a rule of "one backlog per team"... Should we break it? And is it even supported in TFS? Any idea how to solve the problem?


Working code and user needs

Programmers, like myself, often is too worried about if their code is really going to work, rather than how to communicate with the users. Scared of throwing an exception at the user, we test with different scenarios in different environment like development, staging and production. But when it comes to deliver a simple line of information to the user - we fail. We try to convey a message that explains to us what is really meant rather than a message, in plain english, easily understood by the user. And even more - we use a very strict and formal language. We spend 1% or less of our time to think about who receives the message, and what they think of it when they do. I use phrases like **"Not selected to the next step"** instead of **"We're sorry, but there where others with higher score than you who made it to the next step. But keep up the good work, we like to see you here again. Sometime soon it will be your turn"** I dislike this attitude that I seem to be adapting. I'd like this behaviour of mine to change. How do I keep myself out of the rabbit hole?


Database abstraction -- is it being overdone?

After being exposed to numerous database abstraction layers, I'm starting to wonder what the point is of every library inventing their own different paradigm to access data. Picking up a new DAL feels like learning a new language all over again, when usually all I want to do is just convince the layer to output an SQL query that I've already written in my head. And that's without even touching on readability after the fact:               # Exhibit A:  A typical DAL     rows = db(db.ips_x_users.ip_addr == '127.0.0.1')         .inner_join(db.ips_x_users.user_id == db.users.id)         .select(order=(db.ips_x_users.last_seen, 'desc'), limit=10)      ****               # Exhibit B:  Another typical DAL     rows = db.ips_x_users         .join(db.users, on=db.ips_x_users.user_id == db.users.id)         .filter(db.ips_x_users.ip_addr == '127.0.0.1')         .select(sort=~db.ips_x_users, limit=10)      ****               # Exhibit C:  A hypothetical DAL based on standard SQL syntax     rows = db('''SELECT * FROM ips_x_users                  INNER JOIN users ON                      (ips_x_users.user_id = users.id)                  WHERE ips_x_users.ip_addr = ip                  ORDER BY last_seen DESC LIMIT 10''', ip='127.0.0.1')      What's wrong with standard SQL syntax? It was created for a specific purpose, and it fits that purpose beautifully. Maybe it's just me, but I understand snippet C far more readily than the first two. The renamed keywords and syntax tricks are cute, but IMO, when it comes right down to it, they don't make retrieving rows any easier for the coder. This probably seemed like a long rant, but there **is** a real question here. Since every DAL seems to invent a new DSL for queries rather than just parsing tried-and-true SQL, there must either be benefits of using different syntax, or deficiencies in standard SQL syntax that I don't realize are there. Could anyone please point out what I'm overlooking here?


Product demo and .net

I have question about using .Net 3.5 or 4.0 I know that .Net is more productive then Qt but i am afraid of problems when my client leave my product because he cant run e.g demo of my app with lack of appropriate framework version. I wish to ask experienced persons in that matter. Is that many users that doesn't have .net 3.5? It worth to make app in .Net 3.5 or better use Qt c++ because .net is not that much productive and more important is that every could run app coded in Qt ?


How might the role of product owner go against the idea of open source, or work for it?

On a related questions about "Finding and/or becoming an open source product owner" -- the first comment to the question itself was "the idea of a product owner goes against the idea of open source."   * Is this true, and if so, why?   * If not, what circumstances and/or context would it make sense for open source project to have a product owner role? I've attempt to find an example of this role at Mozilla.org \-- but I've had no luck so far. (Just to be clear, I'm talking about a volunteer role, not a paid position at a non-profit.)


Why is the copying instruction usually named MOV?

In quite many assemblers, a value copying instruction is usually named "MOV" and its description in manuals usually also contains "move" (however, other words can be used, like "load", "store", "extract", etc.) It's uncommon to find an ISA ) which doesn't follow this convention. On the other hand, in other contexts, "move" differs from "copy" in sense that source is destroyed (for example, "mv" vs. "cp" in Unix, Move[F6] in Norton Commander and clones, etc.) Assembler's "move" really has semantic "copy", keeping the source value intact. I've found that this has started at least since IBM 1401 (1959), but, IBM 360 used this word only for in-storage copying, but not for operations between registers and storage (which used "load" and "store"). But why it's still widely used and not replaced with "copy" or "store"?


Why do some functional languages need software transactional memory?

Functional languages, by definition, should not maintain state variables. Why, then, do Haskell, Clojure, and others provide software transactional memory (STM) implementations? Is there a conflict between two approaches?


Idea for a domain specific language or DLR port?

I have my undergraduate final year project coming up and am very interested in lexers, parsers, compilers and so on. I would like to use the DLR (.NET 4.0 dynamic language runtime) for my undergraduate final year project, but am struggling to find a reason to use it! A domain specific language would be an idea, but most of the domains I can think of have already been done. A possibility was a primarily semantic web focused triple store query language similar to SPARQL, but the domain is rather complicated and the query engine would take quite a while to write and optimise. I am also thinking about different programming paradigms, particularly higher level ones such as array/collection programming languages rather than scalar. A language which is less _specific_ in terms of the domain, but with which it is 'easier to process X, which is commonly used or dealt with in situation Y' would be interesting. Another approach would be to attempt to port an existing language (or at least part of it, time permitting) to the DLR. Preferably not APL or Perl - I'm not a masochist. **Edit:** To clarify, by 'Port' I mean host an existing language on the DLR, such as IronJS, IronPython, IronRuby, etc. Does anyone have any ideas for a domain specific language, preferably but not necessarily suitable for the DLR?


How do you perform modeling in an Extreme Programming environment?

I know methodologies, like Extreme Programming (XP), which specifies its own specific practices for developing software. However, unlike Scrum where it focuses more on management aspects, XP specifies software practices that are required to be followed. From reading this article, these steps eliminate the explicit modeling phase using tools such as BPMN and UML. In another article from Martin Fowler, he further explains such discouragement. Personally, I prefer the model-driven methodologies I guess it's up to the preference of companies and people. One of Agile goal is to "free developers from document works". Methodology like XP seems to easily lead to under documentation. I think to achieve that goal, the solution is to implement the tool to help developer reduce the workload on writing document, not by writing less documents, by gathering information from existing diagrams and automatically generate reports (in RTF, PDF, HTML in the case of Enterprise Architect of Sparx System). Some software engineers also complain about drawing diagrams consuming their time. In my opinion, the solution is not to draw diagram, but using the tool. Modeling tools today support round-trip engineering, where you can synchronize between your code and your diagrams, thus eliminates the extra effort to manually correct the diagrams if the code base changes (specifically, class diagram). How does modeling fit into a team that is using Extreme Programming?


Are there jobs which are oriented towards optimisation programming or assembly

3D engine programmers have to care a little about execution speed, but what about the programmers at ATI and nVidia ? How much do they need to optimize their driver applications ? Are there jobs out there who only purpose is execution speed and optimisation, or jobs for people to program only in assembly ? Please, no flame war about "premature optimisation is the root of all evil", I just want to know if such jobs exists, maybe in security ? In kernel programming ? Where ? Not at all ?


Keeping an MVC model loosely coupled from the DB?

I like to keep my code testable and have decided to go with the Dependency- Injection strategy for my current MVC framework, which definitely has proven to be a great way to ensure loosely coupled code, testability and modularity. But as being far from a master at Design patterns, I have a hard time of figuring out a good way of keeping my Models as loosely coupled from the Database connector classes, as possible. **How can this done?**   As I haven't provided any physical code along with this question, I would really appreciate some logic/code examples or info that could point me into a direction to understand the above described issue.


test coverage reality

I am NOT doing test driven development and I write my test classes after the actual code is written. In my current project I have a test coverage (Line coverage) of 70% for 3000 lines of Java code. I am using JUnit, Mockito and Sonar for testing. But I feel that I am not actually covering and catching 70% of the problems that can occur. So my question is in theory is it possible to have a 100% Line coverage, but in reality it is meaningless because of low quality of the test code and maybe a 40% well written test code is much better than a bad 100% coverage? Or we can always say line coverage more or less gives the percentage of all covered issues?


Python threading vs. multiprocessing: Should I learn one before the other?

I'm looking to dive into multithreading or multiprocessing in Python. Question: should I be learning one before the other (for any reason)? If so, which one and why? I've read the pro's and con's in SO questions like this, but I'm not really sure how they relate to the pedagogical value of learning one or the other first.


What level of threat does selling an app on an app store present to a non-US company?

Can anyone point me to an article or an informed discussion about US software patents affecting a non-US company who is selling their products on an American app store/marketplace? My company has several products on both Apple's App Store and Android's Marketplace, all of which are available for sale in the US. We are however based in Europe and have no assets registered in the US. Assuming we had a product worth enough to attract patent trolls, should we be worried? We have not researched any relevant patents we might be infringing because such research would be too expensive for us. Reading articles about US patent law it seems that being able to catch all potential patents is unlikely anyhow. I realise this site is frequented by programmers and not by lawyers, but a good external reference would be much appreciated.


Ways to have a history of changes of database entries

What are ways to allow the versioning of database entries (data)? Think of the content-managment-systems abilities to revert back changes of articles. What are their pros/cons?


How do game programmers design their classes to reuse in AI, network and play and pass mode?

For a two player game where, your opponent could be on the network, CPU itself or near you where you would play turn by turn on the same machine. How do people design classes for re-use ? I am in a similar situation and have no experience in making such complex games. But here is what I have thought, If I am a player object , I should only be interacting with the GameManager or GameEngine Singleton , from which I will get various notifications about the game status. I dont care where and who my opponent is, this GameManager depending upon the game mode, will interact with gameNetworkManager , or AI tell me what the opponent played. I am not sure about the scenario where we play and pass [turn by turn on same machine]. Hoping for a brief but clear explanation or at least a link to a similar resource.:)


Why is the use of constructors discouraged when creating prototypes?

**Quick background:** In JavaScript, the constructor function for each object type has a `prototype` property. The `prototype` refers to an object that each constructed object uses as the next step up in its prototype chain. When you want one type to inherent from another type, you can set the `prototype` of the child type to a new instance of the parent type. For example:               var Parent = function() { /* constructor business */ }     Parent.prototype.parentProp = "some parent property";          var Child = function() { /* constructor business */ }     Child.prototype = /*** !! Some prototype object goes here !! ***/      My question asks about what code should go in the "`Some prototype object goes here`" spot in the above code. My first instinct is to construct an instance of the parent (i.e., `new Parent()`), but in a comment to an answer on Is this a safe way of copying one objects prototype to another?, one user writes: > No, do not use `new bar()` for the prototype object! (...which is an opinion I've seen in many SO answers and comments, but this is the only example I have on hand at the moment.) The other option is to use `Object.create(Parent.prototype)` as `Child.prototype`. As far as I know, this also creates a new `Parent` instance, but it does not run the `Parent` constructor. Can someone explain why running the constructor function should be avoided when generating a prototype object from a parent type? Is there some significant technical problem that arises (perhaps with multiple levels of inheritance)? Or is such a pattern a misuse of constructors that clashes with some prototypical best practice (e.g., running the constructor when creating a prototype violates some separation of concerns)?


Data structures for storing finger/stylus movements in drawing application?

I have a general question about creating a drawing application, the language could be C++ or ObjectiveC with OpenGL. I would like to hear what are the best methods and practices for storing strokes data. _Think of the many iPad apps that allow you to draw with your finger (or a stylus) or any other similar function on a desktop app._ To summarize, the data structure must:   * be highly responsive to the movement   * store precise values (close in space / time)   * usable for rendering the strokes with complex textures (textures based on the dynamic of the stroke etc)    * exportable to a text file for saving/loading


Of what significance is the solution to the game of checkers in AI research?

I have been doing some research into artificial intelligence and I came across a 2007 paper titled "Checkers is Solved" on the game of checkers being solved by AI techniques after more than 16 years of trial. A solution to the game is defined by the team as "determining the final result in a game with no mistakes made by either player". The search for a solution started back in 1989 and it was finally found in 2007. Of what importance is this to the field of AI?


What appears in your mind if someone asks for a module for application?

Non-technical people tend to say the word module instead of feature. But I always get annoyed if someone tells me to write a module when what they really want is a feature. In my opinion a module is more than just a feature. A module has no strong dependencies to the application. The application works without the need for any modules. This is why I get angry if someone wants me to write a module because it is not easy to write modular applications. It requires architecting. A feature can be a module or not to be. So I always prefer to understand module as a feature if a non-programmer asks it of me. What do you understand if someone wants a module? What is module in programming terms?


Should I include a selfdestruct-method to my applications?

I recently had a negative experience, where client bailed from the bill, but my middle-man already uploaded our software and design to the clients server. Client turned out be a known criminal, and of course he changed all possible passwords of the server. However, I can still access the admin-panel of the CMS. Sadly it turns out, that my software is very secure.. Tried to SQL-injection, fake the image- upload etc etc. However, I cannot hack my own software.. Anyways, I preparing to sue this person, so that is not the problem.. I'm just thinking now, that maybe there should be some backend selfdestruct-method. So, if similar case occur, I have the option to _kill_ the software. My own idea is to hide some function in the core files. Encode it with base64, so it wouldn't be obvious. So something like this:               eval(base64_decode('ZWNobyAnSGVsbG8gd29ybGQhJzs=')); // echo 'Hello world!';      And basically make a small script, that takes all the software's files, chmod's them to be sure and then deletes them.   My newer versions of the CMS, all have filemanagers that I could use for easier _hacking_. But what if the access to the admin-panel is limited. **To be very clear** , this is meant only for the development-stage software's, in my personal server or the clients server (last part being the ethically questionable.) So if my client should steal my software.. This wont be included inside a commercial-software.   **And to be even more clear** , we are talking about those _rare_ freelance jobs. I think its fairly logical, that contract-work doesn't need such methods. So we are talking about those jumprisk-clients, only in development mode -- when the project is ready, then obviously this would be a very very unethical _backdoor_ to have inside your software.   1. Ethically is this a good idea? (Keeping in mind, that obviously I will remove it, when project has been 100% and everything is paid for)   2. Have you guys ever had to _hack_ your own software, because of similar issues with the client(s)?   3. Any recommendations on this idea, code and method wise?   4. What may be the possible drawbacks or repercussions of selfdestruct-scripts? **My conclusion on this** Is a little bit sad, that all answers were targeted on the contracted cases. It was my fault really, that I didn't make it more clear in my question.. just thought, that it is fairly clear, that there is no point in the kill-switch.. when you are protected by the contract.   However, if you are doing a contract work.. then this should be stated in the contract -- this makes it legal, even inside the clients own server. However, having kill-switches inside my own personal server is really nobodies business (this is what I really wanted to know.) I decided to make the kill-switch script for my CMS. Mainly, because it seems an interesting challenge. But also, that I could use this for my non- contracted works where the client is a friend of a friend of a friend.. I probably wont use this on the clients server, but..for the cases, where the client or some middlemen have access to my server .. And my software gets stolen, or "moved without my knowledge", then I don't get paid and they cut the access to the software. I have read trough alot of topics here, where they recommend to send a warning and then take down the page. Well, I saw a problem in it, as when Im dealing with a person.. who will just copy it to somewhere else (maybe re-brand it and sell it) and tells me, that it has been taken down. And also, I wouldn't "turn the site off", but delete it. Though, I guess its still illegal to access my clients server and to delete it. Or at-least, access it trough backend and not from the FTP. For this I thank all of you, who answered.


What are the 'hot' topics in computer science?

I'm about to start my AQA EPQ - which is a 5000 word essay and presentation on a topic of your choice; I was looking for topics in which to research and report on. I believe this question is often asked by many university and sixth form students because often, chosen questions can lead to to many 'dead-ends'. I want to be able to go into depth with the topic and write-up a detailed report with a strong over-all conclusion. What topics within computer science are considered good topics to research and report on.


How do I pass data the object-oriented way in PHP?

I find that even when working with a MVC framework (e.g. CodeIgniter), I regularly resort to passing nested arrays rather than objects. This doesn't follow my understanding of object-oriented well. For example, if I were to port the code to Java then I wouldn't dream of passing arrays (or Vectors, or whatever) around like that. I was wondering if this is the appropriate way to handle data. Is there a reason why arrays are passed around like this in PHP, or why objects aren't used? What's the best way to pass data around?


Functions with side-effects in Delphi/Pascal

What is the proper approach to functions that have side-effects in Delphi/Pascal? For example, I could have a boolean function `DeleteFile` that returns `True` if the file was deleted and `False` otherwise. How do I collect the return value? 1) The very explicit form would be:               if DeleteFile(MyFilePath) then     begin       IsMyFileDeleted := True;     end;     else     begin       IsMyFileDeleted := False;     end;      2) Less bulky would be:               IsMyFileDeleted := False;     if DeleteFile(MyFilePath) then     begin       IsMyFileDeleted := True;     end;      3) Or even shorter, but discouraged by JEDI \- perhaps it is acceptable just to collect return values:               IsMyFileDeleted := False;     if DeleteFile(MyFilePath) then IsMyFileDeleted := True;      My problem with 2 and 3 is that I explicitly state something (`X := False`) that I may not know for sure. 4) I would rather not set the variable beforehand and have its value completely determined by the function:               IsMyFileDeleted := DeleteFile(MyFilePath);      Here the issue is that it is a bit misleading, because assigning a value to a boolean has a pretty serious side-effect. I'm not sure if this usage is desirable. Some argue that functions should never have side-effects, but I think some of Pascals internal functions violate that. 5) The alternative would be making it procedures with a result variable to be filled by the procedure:               DeleteFile(MyFilePath, IsMyFileDeleted);      That might go against the trend to keep parameter use to a minimum (Clean Code). 4 and 5 would be the only ways to collect a return value other than boolean, I suppose? Does that mean anything for boolean functions? Yes, there are many ways to do the same thing and maybe I'm just worried about nothing really, but I'm trying to develop a good style and I wonder if there are any best practices. For a beginner, many principles seem to be in conflict all the time.


What do you do when you feel stuck on a project?

When I am in a code or design rut, I tend to find a non-dev coworker to discuss the problem with. It forces me to explain the problem in great detail and I'll usually find something I missed in the process. What are your "unsticking" methods?


Should I use multivalued attributes in conceptual modelling?

My team and I have designed a simple, affordable conceptual modelling language as part or a larger research project. This language is aimed to end users with little or no training in information technologies. It allows them to create class models using basic constructs such as classes, attributes, associations, and the like. The language is working nicely, but we are considering whether we should add multivalued attributes to it. In the OO paradigm, attributes are usually considered to be single-valued, i.e. they can take a value on each instance of a class, or they can be null, but they can never take multiple simultaneous values. However, some situations in certain application domains call for multivalued attributes. For example, imagine a Garment class with a Colour attribute. That attribute may as well be multivalued, since garments can be multi-coloured: the shirt I'm wearing as type this is white and purple. However, very few approaches to OO conceptual modelling use multivalued attributes, and none of them are mainstream as far as I know. I seem to recall reading that multivalued attributes are not a good way to model things, but I can't recall a sound reason, and I can't think of one, and I refuse to accept this at face value. In addition, most of the work I know of about multivalued attributes is at the database level rather than at the conceptual modelling level. So, my question is: Do you think that multivalued attributes make sense in a conceptual modelling language? Can you point me to any books, papers or other sources that discuss this? Thank you.


Multi-user Configuration Settings design

I am designing a flexible and extensible way to store configuration settings for users. **Database Table Design:**               ╔═════════════════════════════╗      ║ ConfigurationItemDefinition ║      ╠═════════════════════════════╣      ║ ID                          ║      ║ Name                        ║      ║ Type                        ║      ║ DefaultValue (varchar)      ║      ║ ConfigurationItemAdapterID  ║      ╚═════════════════════════════╝                    |     ╔═══════════════════════════════╗     ║ ConfigurationItem             ║     ╠═══════════════════════════════╣     ║ ID                            ║     ║ UserID                        ║     ║ ConfigurationItemDefinitionID ║     ║ Value (varchar)               ║     ╚═══════════════════════════════╝      **Explanation:** The `ConfigurationItemDefinition` table holds the definition for configuration settings. `Type` is the .NET type which the value would be parsed/serialized into when queried in the code. The `ConfigurationItem` table is where configuration values are set _for each user_. If there is no value explicitly set for a specific user for some configuration item definition, then the `DefaultValue` value from `ConfigurationItemDefinition` is used. `ConfigurationItemAdapterID` is determines what technique is to be used to 'get' and 'set' the configuration value. For example, an `int` value would use a basic Parse (from string -> int). A `CultureInfo` object would need to use a serialization adapter. The way in which configuration values are get and set is determined by the adapter (examples below). **C# Code** In C#, a setting would be acquired like this:               // This would use the Parse adapter     int timeout = someUser.GetConfigurationValue<int>("TimeoutValue");           // This would use the Serialization adapter     CultureInfo cultureInfo = someUser.GetConfigurationValue<CultureInfo>("CultureInformation");      And set like this:               // This would use the Parse adapter     someUser.SetConfigurationValue<bool>("IsLive", true);      Please critique this design. Are there more standard ways of dealing with such a problem?


Unit Testing and "Fit"

I am reading Cristopher Alexander's "Notes on the Synthesis of Form", and he is describing a solution to a problem as having good fit, when there is an absence of bad fit; we can't describe all of the qualities of good fit because it's too complex, but we can identify the bad qualities that stick out. The complexity of software means that we can't understand all the possible relationships - the qualities of good fit, but we can identify when code isn't doing what it's supposed to - the bad fit. I'm wondering then, is the purpose of unit tests to identify a "bad fit" in the solution?


Keeping test and release version numbers in sync

I'm currently beta-testing an iPhone app. Right now I have sent out the first beta-test for my users and I have labeled that release as `1.0` for my testers. Now since the testers have tested the app we have discovered some bugs that I have fixed and I'm ready to send out a new beta-test for my users. Should I label the release as `1.0.1` then? Another question related to this is, when my testers have tested this `1.0.1` release and they do not find any bugs it would be a good time to release this version to the public in the App Store. What version number should I release this under in the App Store? First thought is that since it's the first release to the App Store it should have version number `1.0` but then it will be "out of sync" with the version that has been tested (`1.0.1`).


How do I dual license?

I'd like to open source a project of mine under GPL v3. Additionally, I'd like to sell a license for those who wish to use the code in a proprietary application. How do I go about releasing my source code under GPL v3, while also reserving the right to release it under another license of my choosing? Do I still put the GPL header at the top of each of my source files? I'm rather new to the legal side of software.


Suggestion needed to create a website that makes podcasts

I going to create a project that has the following features:   * Create Audio and Video Podcast    * Create & Browse Podcast Hoster's Profile   * Manage Hoster's Profile ( add podcast , remove podcast , archive podcast )    * Paypal Payment implementation   * Secure User Login system   * Able to expose data as a webservice. Can anyone suggest me the better PHP framwork or CMS ( if required ) and a multimedia server for the same purpose. Any other suggestions are also welcome.


What are the best ways to professionally increase your online presence?

I've been hunting around the job market for a little bit now and I've been shocked by some of the things I'm seeing. Software developers who make themselves more "known" online are getting far more career opportunities and far better positions than people competing against them who are not as well "known" online. After doing some reading on the subject I realized that I actually shouldn't be so shocked by this. We are living in the most fast-paced era of mankind and employers want to be able to learn as much as they can about a potential employee before they hire them. The easier we as software developers make it for us to be found the better our chances of landing that dream job become. In some cases, employers are even finding us in favor of traditionally choosing to let us apply to them. So what are some of the best ways for me as a software developer to increase my online presence? I already hang around stack exchange sites such as programmers and stack overflow increasing my rep whenever I can. I maintain many open source projects as both a committer and project owner on Google Code and Github. I have a Twitter account, a website, and a blog. What else can I do to give myself a bigger online presence? Additionally, are there any good do's and don'ts for handling your web presence? Bashing your employer is an obvious don't but I'm interested in everything from the most basic to the most subtle suggestions to give myself a more appealing online presence. Thank you very much in advance for your time.


Why do some projects have getters and setters for public instance variables?

I was looking into an open-source game framework project written in Java. It has several classes that:   * Have public instance variables.   * Have getter/setters for such variables. Generally, I write getters/setters when I want to encapsulate some behavior that occurs when a property is modified. However, looking at the code, it literally goes something like this:               public class Test {         public int value;         public void setValue(x) {             value = x;         }         public void getValue() {             return value;         }     }      Then I thought about checking out the rest of the framework and see how do they modify such value, which may give me a hint on why did they do the above. From what I've seen, they do it like this:               object.value = 100;      Without using the getters/setters. So now I'm not sure what was the point of creating getters/setters. * * * So, my question is, is there a reason I would want to create getters/setters for a public value, if such getters/setters don't even implement any kind of special behaviour?


Code mapping in .NET (or in general)

Does there exist a software solution of some form that has the ability to map out the actions of calling a function. So what I mean is, let's say that we have the following class.               public class Foo     {         public Foo()         {            if (this.SomeProperty)            {                DoSomething();            }         }              private void DoSomething()         {             var Bar = new Bar();             Bar.DoSomethingElse();         }     }          public class Bar     {         public void DoSomethingElse()         {             //call something else or whatever here.         }     }      Would there be something that would generate a flow chart (or some kind of map of sorts) of this if I were to say, what does creating a `Foo` do? I'm asking this because a large majority of our code base was written on the fly without any kinds of documentation, and I'm just trying to help map out some behavior and make sure that it is all understood.


What is a nicer way of describing the process of "Idiot Proofing" a piece of software

To me, Idiot Proofing just means making sure the user can't break a piece of software even if he tried. For instance, if a value is read from a text box, and is converted to a double, if the underlying software is idiot proof, it won't break if the user types in a non-double value. I recently wrote up a development schedule and one of the items was named "Idiot proof UI". The people I am building this software jokingly feigned offense to the term, but I can see where this term would actually make people upset. What's a nicer way to say this?


Any guidelines for correcting others technical inaccuracies?

How often do you correct others when they say something that is inaccurate? For example I recently corrected someone when they kept referring to a forward slash as a backslash. He made the reference several times so I knew it wasn't a slip of the tongue. Furthermore, I wasn't trying to " _Display my vast knowledge_ " I just thought he might like to know. A couple of guys here write code in VB.NET, for some reason the non technical people in charge got the term VBN or VBN.NET in their heads and no one corrected them. So now thats what they call it. Everyone here knows what they mean when they say VBN though, so I guess theres no real harm. I personally love to learn so I gladly welcome most corrections, so I can learn whats right. I feel like other people just get annoyed when corrected. Should some fallacies be left alone or is it always OK to simply say: > Actually its called VB.NET, I think maybe you were confusing it with VPN. Or am I just being pedantic? Correcting mistakes in someones code is always fine, but are there any guidelines to correcting people outside of code reviews? Are there different rules I should follow in correcting Technical vs Non Technical people? I don't want to be an information hoarder, but I don't want to be an annoying pedant either.


Are there any statically-typed Web scripting languages?

There seems to be two major ways to set up a web server backend. You can use a LAMP stack, with the server-side code in something like PHP or Python (or Ruby or JavaScript, which don't start with a P.) These scripting languages tend to be dynamically typed, with all of the disadvantages in performance, correctness and maintainabilty that dynamically typed languages bring, but it's easy to update the server because all the page generation logic is stored in external scripts. The other major architecture style in wide use is ASP.NET, where the page generation logic is written in compiled code. This tends to use statically typed languages, so you get code that's had the benefit of a compiler, but all of the page generation logic is compiled into the server, which means if you need to change something, you have to take the server down and replace it with a new build. So that makes me wonder. Are there any server-side scripting languages that use static typing, for the best of both worlds?


Testing loses its effectiveness if all programmers don't use them

Let's assume you are convinced that the extra time spent unit testing has merit and improves production. Does that still hold up when everyone working on the same code doesn't use them? This question makes me wonder if fixing tests that everyone doesn't use is a waste of time. If you correct a test so the new code will pass, you're assuming the new code is correct. The person updating the test better have a firm understanding of the reasoning behind the code change and decide if the test or the new code needs to be fixed. This much inconsistency in a team when it comes to testing is probably an indication of other problems as well. There is a certain amount of risk involved that someone else on the team will alter code that is covered by testing. Is this the point where testing becomes counter-productive?


Design pattern for data privileges

I'm designing a financial system that should grant access to data based on roles and privileges. For example, a manager can see the financial transaction of users under his domain but not information regarding other transaction. Although it's possible to implement ad-hoc I was wondering if there are patterns or guidelines for implementing such instrumentation.


Space complexity of Iterative Deepening DFS

We read on Wikipedia > Iterative deepening depth-first search that > The space complexity of IDDFS is O(bd), where b is the branching factor and > d is the depth of shallowest goal. Wikipedia also gives some decent pseudocode for IDDFS; I pythonified it:               def IDDFS(root, goal):       depth = 0       solution = None       while not solution:         solution = DLS(root, goal, depth)         depth = depth + 1       return solution          def DLS(node, goal, depth):       print("DLS: node=%d, goal=%d, depth=%d" % (node, goal, depth))       if depth >= 0:         if node == goal:           return node              for child in expand(node):           s = DLS(child, goal, depth-1)           if s:             return s            return None      So my question is, how does the space complexity include the branching factor? Does that assume that `expand(node)` takes up `O(b)` space? What if `expand` uses a generator that only takes constant space? In that case, would the space complexity still be a function of the branching factor? Are there situations where it is even possible for `expand` to be a constant-space generator?


Do I have to learn html and javascript to create web applications?

I am an experienced Java programmer, and I want to create a complex web application requiring dynamic pages, drawings, etc (take SO as an example). Do I have to learn javascript/html in order to create such an application? It is not that I don't want to learn another language (I've done this before), but technology on the javascript environment seems to change so fast that when you finish learning one framework it is already obsolete. I have checked a number of java framework for web development (spring, play), but not deeply. So can these frameworks (or other possible java frameworks that I'm not aware of) be used without learning html/javascript? I also have some python experience. So if I can do the app in python it is also an option.


Handling error message for a Spring MVC login form

This can apply to many error handling scenarios, but I'm curious about how to do it in a login scenario. Given this Spring controller method:               @RequestMapping(value = "/account/login", method = RequestMethod.POST)     public String login(@RequestParam("username") String aUsername,             @RequestParam("password") String aPassword,             Model model)      {             try {                 accountService.login(aUsername, aPassword);              } catch (LoginException e) {                 // log e                 // add an error to request scope                 model.addAttribute("error", e.getMessage);                 return "login"; // return to login page             }             // success, show profile             return "redirect:profile";         }      And a login.html form (I'm using thymeleaf, but just follow logic, similar to `jsp`):               <!-- This is saying, if ${error} is set, use it instead of the content of p, `No error` -->     <p th:if="${error}" th:text="${error}">No error</p>     <form method="post" action="#" th:action="@{/account/login}">         Username: <input name="username" type="text" />         Password: <input name="password" type="text" />         <input name="login" type="submit" value="Login" />      </form>      Is this how error handling is usually done in java web applications? Anywhere an error can happen, you branch out with different `if`s? Is there a cleaner, or more generic, way to do this?


How do you unit test an encoder?

I have something like this:               public byte[] EncodeMyObject(MyObject obj)      I've been unit testing like this:               byte[] expectedResults = new byte[3]{ 0x01, 0x02, 0xFF };     Assert.IsEqual(expectedResults, EncodeMyObject(myObject));      EDIT: The two ways I've seen proposed are: 1) Using hardcoded expected values, like the above example. 2) Using a decoder to decode the encoded byte array and comparing the input/output objects. The problem I see with method 1 is that it is very brittle and requires a lot of hard coded values. The problem with method 2 is that testing the encoder depends on the decoder working correctly. If the encoder/decoder are broken equally (in the same place), then the tests could produce false positives. These may very well be the only ways to test this type of method. If that's the case then fine. I'm asking the question to see if there are any _better strategies_ for this type of testing. I can not reveal the internals of the particular encoder I am working on. I am asking in general how you would solve this type of problem, and I don't feel the internals are important. Assume that a given input object will always produce the same output byte array.


FxCop / Code Analysis with VS2010 Ultimate

I've getting some information about this, but I still can find a proper answer, I was asked recently in my company for this : "run a fxcop analysis on that code and tell me the results". Ok, I have VS2010 Ultimate which has code analysis, but before making any comment, I browse it on the internet cause I want to implement the best choice... So, let's say I'm gonna use the same rules on both analyzers:   * Should I recommend using one above the other?   * Should I say "hey, thats kinda old, let's use code analysis!"   * Should I get the same results on different computers? (for what I undersand, fxcop gives you some "points" and for what I've read, sometimes it gives you diff points on diff computers, I don't know about this with code analysis Thanks, any help would be appreciated


Is it okay to have people with multiple roles in a Scrum team?

I'm evaluating some Agile-style methodologies for possible introduction to my team. With Scrum, is it allowable to have the same person perform multiple roles? We have a small team of four developers and a web designer; we don't really have a lead (I fulfill this role), QA testers or business analysts, and all of our development tasks come from the CIO. Automated testing is seen as a total waste of time, and everything focuses on speed and not quality. What will happen is the CIO will come up with a development task (whether a feature or a bug) and give it to a developer (not to the whole team, to an individual, often in private or out of the blue) who is then expected to get it completed. The CIO doesn't gather requirements beyond the initial idea (and this has bitten us before as we'll implement something only to find out that none of the end users can use the feature, because they weren't consulted or even informed about it before we developed it, and in a panic we'll be told to revert the change) but requires say in/approval of everything that we do. First things first, is a Scrum style something to consider to introduce some standards and practices? From reading, Scrum seems to rely on a bit more trust and communication and focuses more on project management than on development, which is something we are completely devoid of as we don't have any semblance of project management at present. Second, if it can work is it unreasonable for someone, let's say myself, to act as both ScrumMaster and a developer? Or for a developer to also be the Product Owner (although chances are this will be the CIO, who isn't a developer)? I realize the Scrum Master and the Product Owner should be different people but at the same time I don't think we have anyone who has the qualities of a Product Owner (chances are it would turn into a "I need all these stories, I don't care how but get it done" type of deal and/or any freeze would be unfrozen on a whim). It seems to me that I might need to pick and choose pieces of Scrum/XP/Lean to compensate for how things are done currently, as it's highly unlikely that the mentality can be changed; for instance Pair Programming would never fly (seen as a waste, you get half the tasks done if you need two people for everything), TDD would be a hard sell, but short cycles would be welcomed.


There are several products for tracking the usage of your application. I know at least 10 offers. They tell you which features were used more often than others. Thus, you can identify features that may not make into new versions. While with Google Analytics, or similar tools, this a standard tool for the web at the "page-level". I just wonder who is already using this analysis for desktop applications? Big companies like Microsoft of course do it, but do ISVs and small vendors (perhaps < 50 employees) use such tools? I currently don't know anybody, so I'm really curious about it: Is Usage Tracking esoteric or state of the art?


OS knowledge when learning a computer programming language

I am curious, has the knowledge of the inner workings of an operating system helped you in understanding a computer programming language? It may have helped you figure out programming faster than someone with less knowledge of the underlying concepts of the Operating System?


Testing of personal projects

I'm developing a web based personal project that will hopefully be used by thousands. Obviously prior to releasing it in the wild as Beta I was wondering, are there any communities out there that will test my web app and provide feedback? Free would be great, but I'm open to suggestions.


How to reconcile inner creativity with the corporate environment?

As programmers, many (most?) of us have an inner creative "spark". We love thinking of new, useful ways to accomplish tasks. Many of us have even dreamed a few ideas we thought could be viable businesses, or even change the way people go about their daily routine. However, many of us also work in a corporate environment where we are told which projects to work on and when to work on them. Personally, this can feel suffocating at times. If you have an idea you think could be world changing (or at least effect a lot of people), how do you get passionate about work that is dictated to you? Even if you don't have the next "big idea", many of us still want to unleash some inner creativity. How do you do this in an environment that seems to be counter-productive to that creativity?


How do you organize a large data layer in a project?

I have a data layer that strictly interacts with the database and returns the result into a model. I have an asynchronous connection with the DB so sometimes I have to chain results where I have to do many queries. I have about 1000 lines of code in a single class and It's getting hard to manage. My question is, how do you re-factor/organize something like this? Do you break it up into multiple classes, maybe by functional area? Do you have one parent class that calls sub classes with the code in it? Ie if you have DataAccess.class with everything in it would you break it up like this: DataAccess_FunctionalAreaA_Insert.class DataAccess_FunctionalAreaA_Update.class DataAccess_FunctionalAreaA_Delete.class DataAccess_FunctionalAreaA_Read.class DataAccess_FunctionalAreaB_Insert.class DataAccess_FunctionalAreaB_Update.class DataAccess_FunctionalAreaB_Delete.class DataAccess_FunctionalAreaB_Read.class I would probably use namespaces to break up the above, but I wanted to illustrate how one might break it up. What would you do?


Are Protected Auto-Cast Methods Ok?

I often have superclasses that contain a more abstracted form of a class as a member variable than my subclasses need. I find my code littered `((ClassName)variableName).methodName()`. Is the best way to solve this to create a protected/private method called something like `getVariableNameAsClass()`? It's not much shorter in letters, but an IDE can do that much faster than maneuvering around with the keys to add in parenthesis. Or is there a better solution? The reason I need to cast is because all of the subclasses of `Line` use an `Output` class, so I put the getters and setters that relate to the `Output` class in the base class. The issue is that an `AudioLine` uses and `AudioOutput`, and needs to define additional methods that use the more specific features. **So, here's my entire class design:** I have a `Line` class with two subclasses, `VideoLine` and `AudioLine`, which delegate some of their functionality to a internal `Output` class. `Output` class has a `AudioOutput` and `VideoOutput` subclass. I defined all the functionality for the `Line` class that relies only on methods from the `Output` class inside the `Line` class, in accordance with DRY. `Line`'s `AudioLine` and `VideoLine` both deligate additional functionality to `AudioOutput` and `VideoOutput`. Since they both set up the `Output` protected variable in their constructors (and therefor KNOW what subclass it contains), it seemed to make sense to caste it.