Revisiting Learned Languages

I'm an aspiring programmer, I really wish to be great at multiple programming languages. I began programming from my school where they didn't teach me well, they didn't follow the standards, they didn't even tell the difference between an IDE and a compiler, they kept calling the Turbo C++ IDE a compiler, which sucked. And at that time I didn't have good internet access. But I do have internet, now I can learn new things and how to do them properly. The problem I'm having now is how to relearn everything and at the same time learn new things. I'm trying to do JavaScript and Ruby at this time but I can't concentrate on any of these because I'm worried about the one I am not learning (and also when I find something interesting, I get attracted to that and not the one I'm looking for, eg. attracted to C function pointer while I'm trying to learn callbacks in JavaScript) . How do I manage this? Make a routine? And many of us recommend practicing by making, but I have no idea what to make or making what would be better as a programming practice. Really need help. Edit: How is my question a duplicate? The mentioned question asks whether it "is" better to learn multiple languages simultaneously or not. What I'm asking here is how to be able to concentrate and manage on learning languages properly. Therefore it is not a duplicate, plus the answers I'm getting here are great (which are not there in that question, I'd like to point out the moderators to quit judging like that).


How can a beginner develop an algorithm for this problem?

Before I'm flamed, I'm just a beginner in programming. I have been learning Python for about 1 week by myself. I have a real problem to solve: **Goal:** The fastest route through a pathway. **Problem:**   * Walk forward to get to the goal. The pathway is 128 steps.   * Walking 1 step increases the danger value by 113   * If the danger value is over the limit then there is a fight. The fight takes 15 seconds to win.   * The limit is randomly assigned on each step.   * The danger value resets to 0 after a fight. **Here's the essence of the problem though:** There are two possible options if there is a fight:   * The fight can be escaped. Escaping takes 2 seconds. But does NOT reset the danger value.   * Accept the fight. Resets the danger value.   * The higher the danger value, the higher the chance of getting a fight. I've written the code to take one step. And I've written the code for the relevant randomness of the danger value, etc. I've even made a graph that shows exactly the pathway and potential fights, with the respective limits. This graph shows what happens when you accept every fight (don't escape): ![Fighting Pathway](http://i.stack.imgur.com/7p4Nv.png) **Being self-taught, I just don't know how to write a search algorithm for finding the quickest way through a particular route.** I believe I need to write a **backtracking algorithm** ; essentially a kind of **brute force**. I just don't know how to translate it from english into code. It's been around 4 days of just thinking about this, and I cannot write anything that expresses the even attempts to solve the problem. Any books or advice on how to even start solving this? As I've said, I have all of the code for what happens on each step (here: http://pastebin.com/LnV4h9NV). I just don't know how to even begin trying to brute force/search.


In IT companies employees are working in the same project mean how they will join these part of work (programs) together?

In IT companies employees are working in the same project mean how they will join these part of work(programs) together? I mean I am working in `.zul` file (client side), some of my teammates are working in server side or other Java files, in the end of the day how they can join those programs from different system to single system?


Chain-of-Command/Responsibility pattern for my simple API. A good idea?

I need to write a simple API for a project I'm working on. This API will be used internally to perform some server side actions that were triggered by AJAX calls. To make things easier for me, I thought of using the Chain-of- Command/Responsibility pattern. Here are more details about what I want to do: I am creating a "dashboard" where admins of my app will be able to update information (meta data) about items stored in a database. To make things easy and simple for the admins, I chose to use AJAX. So, if an admin wants to delete an item, (s)he clicks on the "delete button". A POST request is then sent to `edit.php` page with all the information needed to perform the deletion (action : delete, element : link, id : xx ...). Where `action`, `element` and of course `id` can change. This is why I opted for a mini-API that will, depending on the `action` and the `element` data, call a different function from a different class. Now, to implement the API, I decided to use Chain-of-Responsibility design pattern. Why? Because I can easily add, delete or update classes without having to modify the API itself. Is the Chain of Responsibility design pattern good fit for my case?


Rethinking testing strategy

Working on Plone projects our team tries to achieve full test coverage at least for important products. The kind of tests we write are unit tests, functional tests and integration tests. (Also stress-tests, but those aren't in the scope of this question). The goal is two fold at least: to facilitate upgrades and to catch bugs (sometimes it even happens in the process of writing tests). However, Plone/Zope is a complex system, and with years of experience I've noticed, that test strategy should be re-thought. First of all, unit tests, which often require to use a lot of mocking, are not that (cost)efficient. They are mostly easy and beneficial when some core, logic-heavy functionality is being written, like pure Python modules, which have negligible couplings with Plone/Zope, databases, etc. I rarely seen unit-tests catching any bugs at all, except while writing them. So, when doing the usual thing (writing views/portlets/viewlets), from my experience, it's much more efficient to write functional and integration tests. The rationale of it is that in case Plone/Zope changes (in an upgrade) we can catch the mishaps in our code. Views usually do not have a lot of "algorithmic" logic, they glue together several data sources (like catalog queries), maybe with some form handling and preprocessing for templates. It is quite often views call one or more tools to do some routine job (like getting navigation tree or looking up site root). Mocking it all seems unwise. For example, sometimes Plone/Zope changes some default to another type and all those mocked tests happily continue to work while code fails in the real instance. Functional/Integration tests may be at times fragile (HTML can change), but they are cheaper to produce too. They provide basic coverage, and trigger alarms when underlying system changes. Spotting the source of mishap is usually not an issue. ( **update** : Wrong: spotting where integration test fails can be a big issue, but **our** code's unit tests are usually of no help.) The question is, am I overlooking something of importance confining unittesting to functions and classes, which do not require mocking the environment heavily and are instead "purely" logic-heavy? I can't find any justification for writing unit-test "first", or even at all, for every piece of code in Plone/Zope (I do not mean the core of the system, just our own additions for our clients). To make the question less opinion based, are there other reasons, I have not mentioned or tackled above, which necessiate to consider writing more unit tests (and less integration tests) in a situation when code heavily depends on a complex (and somewhat hairy) framework, and code serves more as a glue for framework's subsystems?


Interview Coding Assignments… how much do they account for?

So I've ran into a couple of companies that requires completing coding assignments before they give you a phone interview. I'm curious, do these coding assignments account for anything after the interviews? Or are these assignments just there to see if you're worthy of their time to be phone- interviewed? I'm more interested in hearing from those who had involvement in an actual hiring process that included a coding assignment. I would appreciate if you can mention your involvement (e.g., you were the hiring manager or one of the people on the team that did the hiring). Thanks!


Should I close database connections after use in PHP?

I wonder if I should close any unnecessary database connection inside of my PHP scripts. I am aware of the fact that database connections are closed implicitly when the block stops executing and 'manually' closing the connections could kinda bloat the codebase with unnecessary code. But shouldn't I do so in order to make by code as readable and as easy understandable as possible, while also preventing several possible issues during run time? Also, if I would do, would it be enough to `unset()` my database object?


Data Access Levels of Abstraction

I'd like to describe this situation from two perspectives. I have a system called `Accounts`. This system is made up of subsystems which handle different account-based activities. For example:               Company.Accounts.NewAccounts     Company.Accounts.Loans     Company.Accounts.Transactions      **Perspective One** From this perspective, imagine I have a shared data access tier:               Company.Accounts.DataAccess      This subsystem is built seperately and each of my other Accounts subsystems reference the built assembly. This Company.Accounts.DataAccess subsystem connects to multiple tables. Some of the tables are specific to certain subsystems, and some of them are shared. There are separate modules for use by some specific subsystems, but also one or two common modules that multiple subsystems reference. The common modules include a lot of basic CRUD activities, but also a good number of low/medium complexity actions. So from this perspective, would it be fair to keep this architecture, but to pull out the subsystem-specific logic into a subsystem-specific data access layer? That way, each subsystem has their own specific Data Access piece, but also still references the original Data Access Tier for the common modules.               Company.Accounts.NewAccounts         Company.Accounts.NewAccounts.DataAccess          Company.Accounts.Loans         Company.Accounts.Loans.DataAccess          Company.Accounts.Transactions         Company.Accounts.Transactions.DataAccess          Company.Accounts.DataAccess      **Perspective Two** From this perspective, imagine I have existing Data Access Layers for each subsystem:               Company.Accounts.NewAccounts.DataAccess     Company.Accounts.Loans.DataAccess     Company.Accounts.Transactions.DataAccess      They are logical layers as part of each subsystem, and only each subsystem references its own data access piece. So there are no cross references here. Each of these Data Access Layers perform operations against their own specific Database Tables. However, each of them also has code to perform common operations against tables that are shared amongst all subsystems in the Accounts system. So from this perspective, would it be fair to keep this architecture, but to abstract the common operations into a subsystem-agnostic data access Tier? That way, each subsystem keeps its own logical layer for specific operations, but also references an externally built tier for the common operations.               Company.Accounts.NewAccounts         Company.Accounts.NewAccounts.DataAccess          Company.Accounts.Loans         Company.Accounts.Loans.DataAccess          Company.Accounts.Transactions         Company.Accounts.Transactions.DataAccess          Company.Accounts.DataAccess      **Conclusion** So as you can see, the ending is the same, but coming at the description from two different perspectives. My idea is to have two different levels for data access. So a subsystem references its Data Access Layer for its own data operations, but also references a common Data Access Tier for common operations. Is that legitimate? Is there already a pattern named for this?


Typing skills do developers need a formal training?

Developers key in lots of code, write bogs, write software designs and stuff. Do we need formal typing training? I have seen many developers struggling with keyboard thus slowing down development momentum. At least we can play around with a software typing emulator to begin with.


factors that are important for success when letting an agile framework emerge for the whole organisation?

I previously posted a question [link] on programmers.stackexchange.com asking when it makes sense to adopt an existing enterprise scale agile framework and when it makes sense to allow your own enterprise scale agile framework to emerge (e.g. through trial and error). This question takes the previous question a step further and asks for **the factors that are important for success** when you have decided to go down the route of letting your enterprise scale agile framework emerge? \-- Downvoters: down voting without adding a comment provides no opportunity for improving the question. Please let me know why you are down voting so that I can improve the question.


NoSQL Document Database as a Message Queue

I am considering using a NoSQL Document database as a messaging queue. Here is why:   * I want a client to post a message (some serialized object) to the server and not have to wait for a synchronous response.   * I want to be able to pull messages off of the "queue" based on some criteria, which may be more sophisticated than just a priority level (I am working on a hosted web app, so I want to give all of my customers a fair amount of "computing time", and not let one customer hog all of the processing).   * I want the queue to be durable - if the server goes down I want any remaining messages to be handled when it comes back up. So, I am considering using MongoDB or RavenDB as a message queue. The client can post the message object to a web service which writes it to the database. Then - the service doing the work can pull the various message types based on any criteria that may arise. I can create indexes around the scenarios to make it faster. So - I am looking for someone to shoot a hole in this. Has anybody successfully done this? Has anybody tried this and failed in some way?


Where do you go to read good examples of source code?

I have heard a few people say that one of the best ways to improve your coding ability is to read others code and understand it. My question, as a relatively new programmer, where do I go to find good source code examples that are not too far over my head?


Good introduction to artificial intelligence?

I have been told that as part of my degree year I will be learning about Artificial Intelligence. My lecturers have recommended a couple of books: Artificial Intelligence: A Systems Approach (Computer Science)   Artificial Intelligence (A Modern Approach) I've watched a couple of lectures hosted by Jeff Hawkins, they were good although a little advanced for me. Could someone recommend any other books or lectures that introduce the topic?


Is Power++ worth buying/learning?

I found Power++ and to my suprise it looks like a good alternative for Delphi and Visual Studio. Anyone used it? Can you tell me if it is worth it buying/learning it?


Hard-copy approaches to time tracking

I have a problem: I suck at tracking time-on-task for specific feature/defects/etc while coding them. I tend to jump between tasks a fair bit (partly due to the inherit juggling required by professional software development, partly due to my personal tendancy to focus on the code itself and not the business process around code). My personal preference is for a hard-copy system. Even with gabillions of pixels of real-estate on-screen I find it terribly distracting to keep a tracking window convienient; either I forget about it or it gets in my ways. So, looking for suggestions on time-tracking. My only requirement is a simple system to track start/stop times per task. I've considered going as far as buying a time-clock and giving each ticket a dedicated time-card. When I start working on it, punch-in; when done working, punch-out.


How can my team avoid frequent errors after refactoring?

To give you a little background: I work for a company with roughly twelve Ruby on Rails developers (+/- interns). Remote work is common. Our product is made out of two parts: a rather fat core, and thin up to big customer projects built upon it. Customer projects usually expand the core. Overwriting of key features does not happen. I might add that the core has some rather bad parts that are in urgent need of refactorings. There are specs, but mostly for the customer projects. The worst part of the core are untested (not as it should be...). The developers are split into two teams, working with one or two PO for each sprint. Usually, one customer project is strictly associated with one of the teams and POs. Now our problem: Rather frequently, we break each other's stuff. Someone from Team A expands or refactors the core feature Y, causing unexpected errors for one of Team B's customer projects. Mostly, the changes are not announced over the teams, so the bugs hit almost always unexpected. Team B, including the PO, thought about feature Y to be stable and did not test it before releasing, unaware of the changes. How to get rid of those problems? What kind of 'announcement technique' can you recommend me?


How does Telnet work?

**Is telnet just a simple socket connection?** I usually have a difficult time in the networking area so I use some code from the internet to help me out, but I can't seem to find a library for Telnet in Objective-C. The closest thing I've found is `CocoaAsyncSocket` I was wondering, _Is telnet just plain socket connections?_ _Do I just create a socket to the server and send the commands?_


need advice for building evaluation system in Java for the web

I have made a java program that allows to mark an exam made by one student. In the interface the student chooses between a set of options for each question, and by an array (that holds the correct answers) I get the score of the student. By the way this simple program is made using console java, no swing or applets at all. The information of which answers are correct are stored in a vector, so each answer of the students is compared with this vector for getting the final score. I would like to put his program into one domain that I recently got, so that one student at the moment of entering into the webpage could make the exam; and another program installed in the server will check the correct answers and give other questions, in case the student wants to practice. One friend told me that it is possible to wrap the console java application into java for web, but I just dont know the details for doing that. What would anybody suggest or if there is any online tutorial that could help me with that? My domain has the following extensions:   * FTP    * MySQL    * Apache    * SharedTomcat Please this is not a discussion to know which tool is better, I want just to use Java, but I am pretty lost with all the web technologies that one can use with this language.


Failed to allocate memory - What is it trying to say?

In my early days of programming I often used to get memory related fatal errors in the following format:               Fatal error: Allowed memory size of <some big number> bytes exhausted      (tried to allocate <some small number> bytes) in /path/to/filename.php      on line <some line number>      I'm a little embarrassed to state that even though I have figured out how to solve them and take steps to avoid them altogether, I'm still not quite sure what exactly does the message translate to in simple words. For example, if I get a message such as:               Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 4000 bytes)      in ........ on line 34      As things stand at the moment, I assume it to be stating that the script consumes 67108864 bytes of data, but only 4000 bytes are available during runtime.   * Am I right in my assumption?   * If not, what's the correct interpretation?


I want to learn to Design Hash table with simple hash function for better understanding. I understand that the hash table will work as long as the hash function maps each key to a non-negative integer less than the size of the hash table, but it will only perform well if it distributes different keys across different buckets. My question is : What's a alternative ways to implement hash function using ASCII code. I found ASCII code hash function implementation it's easy to build a hash function on the idea of treating each character of the string as a digit in a number. I try to represent a number is to use a radix-10 system with the Arabic numerals. For example, I could represent numbers using the letters "a" - "z" for the numbers 0 through 25 to obtain the Radix-26 system described in your text book. Characters in the computer are often stored using 7-bit ASCII codes (with values 0-127). So we can treat a string of ASCII characters as a Radix-128 number.


MVC Design Pattern to Combine Multiple Models for use

In my design, I have multiple models and each model has a controller. I need to use all the models to process some operation. Most examples I see are pretty simple with 1 view, 1 controller, and 1 model. How would you get all these models together? Only ways I can think of are 1) Have a top-level controller which has a reference to every controller. Those controllers will have a getter/setter function for their model. Does this violate MVC because every controller should have a model? 2) Have an Intermediate class to combine every model into a one model. Then you create a controller for that new super model. Do you know of any better ideas? Thanks.


Best practice for projects architecture - server side

The usual way (that I'm familiar with) to divide the server side is the n-layer architecture :   1. **DAL** \- data access layer, usually has the Entities and the context (and maybe include also a repository)   2. **BLL** \- business logic layer   3. **Contract** \- Interfaces   4. **Services** \- classes which implement the interfaces ( could be a Web API for E.G ) Of course there is also the n-tier Architecture which i don't want to discuss . lately I've seen more and more a "Modules" architecture and i was wondering about it ( I'm not familiar with the professional term of this architecture ) Where each module is not a table in the database but a group of tables that have a shared concept . something that looks like that : ![Modules and DAL architecture](http://i.stack.imgur.com/qPrqb.jpg) Is there any known good architecture that separate the layers by modules on the server side? if so, what is the professional term for this kind of architecture and what are the advantages / disadvantages of each of this architectures ?


What is the right way to parse HTML?

I've heard, that parsing HTML using the Cthulhu way is not very good. But what are the right ways to parse HTML? Or is it possible to parse it at all?


Is there a purely technical term for 'monkey patching'

**EDIT** The original title of the question was **Is there a non-derogatory term for 'monkey patching'**. As I have learned that the term is actually not derogatory, or is at least not meant to be, I changed the name to free it from mistaken implications. * * * I would like to describe a piece of software, and try not to use emotionally biased language. However I am not aware of an unbiased alternative to 'monkey patching'. The term is meant to be derogatory for a reason. Many see it as a useful but problematic technique. I am aware of an alternative, but it is equally derogatory: 'duck punching'. I see 'open classes' not as an alternative name, but as a prerequisite for monkey patching. 'Overriding' does not seem right either. I would like to differentiate between monkey patching and the regular overriding as part of inheritance-based polymorphism.


What should I know about C++?

I've recently started learning C++, and I enjoy it a lot. I've often read it's easier to write bad code in C++ than in most languages, and that it is a lot deeper than what it seems. As I'd like to avoid writing bad code, I was wondering what exactly I shouldn't do, and what I should do, to write good code in C++.


Selling middleware

I am close to completion of a useful suite of tools for 2D game development (with mobile platforms in mind), for working with sprites and animations. Can anyone advise the best way to sell and promote my product (without investing capital). I am aware that there are lots of websites that can market and sell software to end consumers, but I need to target game developers specifically as middleware is completely meaningless to your average joe. So, aside from using PayPal on my website, are there any marketplaces for game middleware? How can I promote the application outside my website without spamming developer forums?


How long of a trial period do you use with programmers - how quickly can you tell if they are talented and a good fit?

It seems most jobs that I've been exposed to come with a 3 month trial period, during which the employer decides whether the employee is doing good enough work, and is a good fit. 3 months seem like overkill to me, for most cases we've known much sooner whether someone wasn't a good fit. How long does it take you, on average, to evaluate whether a newly hired programmer is both talented and a good fit for your team?


What “Industry Classification” is Computer Programming?

Whenever I fill out a survey (especially, but not limited to trade- papers/mags/sites), there’s one question (or any derivation thereof) that always trips me up: > Which industry classification best describes your line of work This is usually followed by a list of things like _Retail_ , _Health_ , _Education_ , _Construction_ , _Manufacturing_ , etc. I can never figure out exactly what industry computer programming falls in. I usually just end up picking either _Manufacturing_ because I suppose in a way, I’m manufacturing something, _Retail_ since in a way, I am producing goods, or else whatever option happens to mention either “computers” or “electronics” (if any). I tried Googling it but came up empty. Does anyone know what the “correct” answer is? What do other programmers enter in these surveys?    * * *    ![enter image description here](http://i.stack.imgur.com/YOTmp.png)


PHP - How to Automatically Post Form in Another Website and Parse the Result

I am planning to create a website like what http://dohop.com is doing that will allow a user to pull the airlines price rate and date from the http://airasia.com website. Currently the site will only allow the user to view the flight schedule for one day and if they wish to view x days ahead they need to repost the data. I would like to collect the data in x days ahead and group them in table so that user can view all the flight prices & schedule variances in one screen without reposting. I have checked the `AirAsia.com` site and they currently don't have any API support which would allow me to extract their data. While they are using 'aspx' for their website and POST method. Can anyone give me some guidance on what is the method, approach or technique for me to harvest the data?


What is best practice on ordering parameters in a function?

Sometimes (rarely), it seems that creating a function that takes a decent amount of parameters is the best route. However, when I do, I feel like I'm often choosing the ordering of the parameters at random. I usually go by "order of importance", with the most important parameter first. Is there a better way to do this? Is there a "best practice" way of ordering parameters that enhances clarity?


Is a 1:* write:read thread system safe?

Theoretically, thread-safe code should fix race conditions. Race conditions, as I understand it, occur because two threads attempt to write to the same location at the same time. However, what about a threading model in which a single thread is designed to write to a location, and several slave/worker threads simply read from the location? Assuming the value/timing at which they read the data isn't relevant/doesn't hinder the worker thread's outcome, wouldn't this be considered 'thread safe', or am I missing something in my logic?


Is software innovation still primarily North American and European? Why, and for how much longer?

Since this site is read by a global audience of programmers, I want to know if people generally agree that the vast majority of software innovation - languages, OS, tools, methodologies, books, etc. - still originates from the USA, Canada, and the EU. I can think of a few exceptions, e.g. Nginx webserver from Russia and the Ruby language from Japan, but overwhelmingly, the software I use and encounter daily is from North America and the EU.   * Why? Is history and historical momentum (computing having started in USA and Europe) still driving the industry? And/or, is some nebulous (or real) cultural difference discouraging software innovation abroad?   * Or are those of us in the West simply ignorant of real software innovation going on in Asia, South America, Eastern Europe, etc.?   * When, if ever, might the centers of innovation move out of the West? Your experiences and opinions welcome, thanks!


Example cases for each data structure?

I've been looking all over the Internet for a page that lists **cases** for when to use each abstract data type. I expect that reading through a series of both surprising and obvious uses for each type will help readers recognize future opportunities for applying a particular ADT in their algorithms. For example: > **Trees** > >   * File System >   * HTML DOM tree >   * Family Genealogy >   * Syntactic Parsing of Strings >   * etc... > I'll provide a list of basic ADTs that should be included; feel free to add more, or to specify subtypes:               Arrays, Linked-Lists, Sets, Dictionaries/Maps, Stacks, Queues, Trees, Graphs.


Is it worth writing a unit test for a DTO with the most basic getter/setters?

The advantage is it protects your DTO against future "enhancements" ?


Java EE - Configuration over convention?

I'm a systems administrator and am also pursuing a more specific career in development. I started about a year and a half ago with Javascript and C#/.NET ... one day I decided I wanted to learn Java. Then I have found myself amazed with all of the options available and the community seems wonderful and I think the JVM is a great piece of technology and development platform. However...one thing about Microsoft is that everything is completely out of the box. If you want to build an infrastructure or just a simple app then you are dealing with one technology, one vendor, one IDE, one set of forums ... you just point, click, develop. I know there have been huge strides made with Java. More specifically I am spending most of my time with the Pivotal stack. Spring, Spring Boot, Grails, etc. But because there are so many options and everything is so open it seems that the tutorials on different sites are kinda hard to follow and because everything is changing so fast I finally find a good book or tutorial and the layout for everything just changes. I am able to build simple Java apps and I can also get a Grails project up and running in an instant. Also the Play! framework ... wow. But the point is .. just wanting a little bit of advice as someone who is new to Java development. I know that if I can just dig through all of these XML files and just figure it all out that I'll be able to really start taking advantages of these technologies. Just wanted to know if there is a de facto tutorial I should start with. Spring is pretty easy even though sometimes my stuff just ... doesn't work. Even when I'm following the guide on the site. And another part of this question is should I go with Maven or Gradle? I haven't used any of these tools. Is this supposed to make everything easier? All the projects I have created have come straight from the IDE (Spring Tool Suite). .. Ok this is getting long .. I really want to get an application up and running with Spring Data/Rest and start building an Angular JS frontend. Lots of options..a little overwhelming. But want to learn it well and the only thing I miss about .NET is the ease of use. Anybody feel anything similar when learning Java web development? Whats the best place to shut up and start?


How to map the english dictionary to UNSPSC codes?

Is there a db which maps the words from the english dictionary to the UNSPSC codes?(http://www.unspsc.org/) My problem is the following: I am building a search system. And the customer searches for 'pencil' and 'pencil sharpeners' are also returned. Each of the returned item has a UNSPSC code associated with it. So one possible solution would be to search only for those items in the categories the search word belongs to. But this solution would require a mapping from english words to the UNSPSC codes...


Redis & MongoDB for Metrics Platform

I'm in the process of writing an app that will ultimately display analytics to the user. I've written a service that collects data from an API. This data will then be processed, stored, then when the user requests the data, pulls it from the store and displays it. Fairly straightforward. We plan on using MongoDB for the app database (storing users, settings, etc.). I've read that Redis is good for storing metric information because of the key/value pair nature. My question is, what would be the best way to go about interchanging how the data comes from the API service to the user being able to request it? I've initially come up with storing the API data in another MongoDB store, seperate from the app. Then having another service that runs at a longer interval than the API service that aggregates the raw data in Mongo, moves it into Redis, then archives the parsed Mongo data into either some log file or something. The app would then be able to reach into Redis to grab the metrics based on predetermined keys. Is Redis even the right option for something like this? I've also considered swapping out MongoDB with Postgres or MySQL since operations like SUM run well on a relational platform.


Javadoc for a static "overloaded" method

My problem is the following: I have an interface that requires its implementations to implement a static method, namely `void load()`. However, until Java 8, it seems we won't get static methods in interfaces. I trust my users to still implement it correctly, but my problem is how to write a proper doc. There are up to 50 implementations of this interface and not being able to inherit the javadoc is a bother. What is the best way to proceed in my case? Should I document a random implementation and add `@see` annotations in the others? It seems dirty to me. Any suggestion is welcome.


Best design for Windows forms that will share common functionality

In the past, I have used inheritance to allow the extension of Windows forms in my application. If all of my forms would have common controls, artwork, and functionality, I would create a base form implementing the common controls and functionality and then allow other controls to inherit from that base form. However, I have run into a few problems with that design.   1. Controls can only be in one container at a time, so any static controls you have will be tricky. For example: Suppose you had a base form called BaseForm which contained a TreeView which you make protected and static so that all of the other (derived) instances of this class can modify and display the same TreeView. This would not work for multiple classes inheriting from BaseForm, because that TreeView can only be in one container at a time. It would likely be on the last form initialized. Though every instance could edit the control, it would only display in one at a given time. Of course, there are work-arounds, but they are all ugly. (This seems to be a really bad design to me. Why can't multiple containers store pointers to the same object? Anyhow, it is what it is.)   2. State between forms, that is, button states, label text, etc., I have to use global variables for and reset the states on Load.   3. This isn't really supported by Visual Studio's designer very well. Is there a better, yet still easily maintainable design to use? Or is form inheritance still the best approach? **Update** I went from looking at MVC to MVP to the Observer Pattern to the Event Pattern. Here is what I am thinking for the moment, please critique: My BaseForm class will only contain the controls, and events connected to those controls. All events that need any sort of logic to handle them will pass immediately to the BaseFormPresenter class. This class will handle the data from the UI, perform any logical operations, and then update the BaseFormModel. The Model will expose events, which will fire upon state changes, to the Presenter class, which it will subscribe (or observe) to. When the Presenter receives the event notification, it will perform any logic, and then the Presenter will modify the View accordingly. There will only be one of each Model class in memory, but there could potentially be many instances of the BaseForm and therefore the BaseFormPresenter. This would solve my problem of synchronizing each instance of the BaseForm to the same data model. Questions: Which layer should store stuff like, the last pressed button, so that I can keep it highlighted for the user (like in a CSS menu) between forms? Please criticize this design. Thanks for your help!


Are stand up meetings really useful?

My coworkers tell me stand up meetings are useless. My project manager also makes us end every morning meeting with a company chant.


Trade-offs of local vs remote development workflows for a web development team

We currently have SVN setup on a remote development server. Developers SSH into the server and develops on their sandbox environment on the server. Each one has a virtual host pointed to their sandbox so they can preview their changes via the web browser by connecting to developer-sandbox1.domain.com. This has worked well so far because the team is small and everyone uses computers with varying specs and OSs. I've heard some web shops are using a workflow that has the developers work off of a VM on their local machine and then finally push changes to the remote server that hosts SVN. The downside to this is that everyone will need to make sure their machine is powerful enough to run both the VM and all their development tools. This would also mean creating images that mirror the server environment (we use CentOS) and have them install it into their VMs. And this would mean creating new images every time there is an update to the server environment. What are some other trade-offs? Ultimately, why did you choose one workflow over the other?


What is the best way of storing date?

I am a new to storing dates based on time zones. Need to know the standard way to store the date in the datastore. My requirements are   1. Easy to query the date based on the date range.    2. show the date with the client appropriate time zone selected by him(I am having a table maintained for the timezone separately)    3. Able to query using the datastore Admin console also. Any suggestions/ideas regarding this will be a great help in proceeding further.


Discovered large security hole in someone elses website... What to do?

A chap I'm bidding to do some development for has a social network he wrote himself. Not the next facebook by any stretch. But a few thousand local users. I went to have a look at it to see what level of knowledge he had so I knew how to position myself for this potential job. I tapped a single quote into the login box on the front page and up pops a SQL error. So I tried a simple " a' or 'a'='a " in each box and was immediately logged in as the administrator. He had written a fairly comprehensive administration site by the looks of things. At the bottom of the page a "Download SQL Backup" button. This is where I stopped. My question is this. What do I do? As a developer myself I would appreciate the heads up. But as someone who's hopefully going to be paid to do some work for him I wouldn't want to throw all sorts of trust issues into the mix. Any ideas?


Why are there separate L1 caches for data and instructions?

Just went over some slides and noticed that the L1 cache (at least on Intel CPUs) distinguishes between data and instruction cache, I would like to know why this is..


Do I need to publish deployment scripts for deploying AGPL licensed work (MongoDB)

MongoDB is dual-licensed with AGPL (the engine) and ASL 2.0 (the drivers). In a nutshell, merely using MongoDB through the drivers does not dictate to release your source code (due to drivers' ASL 2.0 license). AFAIK, only if you directly call the mongo engine, you need to give out your code that's using it (but still not the _application_ code that talks to mongo via the drivers). Check this MongoDB blog entry: http://blog.mongodb.org/post/103832439/the-agpl What if you deploy (install, configure) mongodb in your deployment scripts. And then start/stop/restart those processes. And then maybe create some users via mongo shell. Do you need to publish your _deployment scripts_? (A bonus question: how can they publish the drivers as ASL 2.0 if those drivers use the AGPL-licensed part of MongoDB over the network? Because they are authors of both?)


How to design an IDisposable that unconditionally needs to be disposed?

Consider a class that implements `IDisposable`, and that has members in such a way that it will never become eligible for garbage collection when it is not disposed. And as it will not be garbage collected, it will not have the chance to use the destructor for cleaning up. As a result, when it is not disposed (e.g. unreliable users, programming errors), resources will be leaked. Is there a general approach how such a class can be designed to deal with such a situation or to avoid it? _Example_ :               using System;          class Program     {         static void Main(string[] args)         {             new Cyclical();             GC.Collect();             GC.WaitForPendingFinalizers();             Console.ReadKey();         }     }          class Cyclical     {         public Cyclical()         {             timer = new System.Threading.Timer(Callback, null, 0, 1000);         }              System.Threading.Timer timer;              void Callback(object state)         {             Console.Write('.');  // do something useful         }              ~Cyclical()         {             Console.WriteLine("destructor");         }     }      (Omitted `IDisposable` to keep example short.) This class uses a `Timer` to do something useful at certain intervals. It needs a reference to the `Timer` to avoid it is garbage collected. Let’s assume the user of that class will not dispose it. As a result of the timer, somewhere some worker thread has a reference to the `Cyclical` instance via the callback, and as a result, the `Cyclical` instance will never become eligible for garbage collection, and its destructor will never run, and resources will leak. In this example, a possible fix (or workaround) could be to use a helper class that receives callbacks from the `Timer`, and that does not have a reference, but only a `WeakReference` to the `Cyclical` instance, which it calls using that `WeakReference`. However, in general, is there a design rule for classes like this that need to be disposed to avoid leaking resources? * * * For the sake of completeness, here the example including `IDispose` and including a workaround/solution (and with a hopefully less distracting name):               class SomethingWithTimer : IDisposable     {        public SomethingWithTimer()        {           timer = new System.Threading.Timer(StaticCallback,              new WeakReference<SomethingWithTimer>(this), 0, 1000);        }             System.Threading.Timer timer;             static void StaticCallback(object state)        {           WeakReference<SomethingWithTimer> instanceRef              = (WeakReference<SomethingWithTimer>) state;           SomethingWithTimer instance;           if (instanceRef.TryGetTarget(out instance))              instance.Callback(null);        }             void Callback(object state)        {           Console.Write('.');  // do something useful        }             public void Dispose()        {           Dispose(true);           GC.SuppressFinalize(this);        }             protected virtual void Dispose(bool disposing)        {           if (disposing)           {              Console.WriteLine("dispose");              timer.Dispose();           }        }             ~SomethingWithTimer()        {           Console.WriteLine("destructor");           Dispose(false);        }     }        * If disposed, the timer will be disposed.   * If not disposed, the object will become eligible for garbage collection.


Is there a difference between the terms "Open Source" and "Open Source Software"?

Until today, I have always used the terms **open source** and **open source software** interchangeably. But then I read Phil Haack's blog post in which he suggests that the two terms are not necessarily referring to the same thing. He proposes the following definitions: **Open Source Software** is source code which is licensed under a license that meets the Open Source Definition. **Open Source** is a development methodology which includes certain characteristics:   * Developed in the open with community involvement   * The team accepts contributions that meet its standards   * The end product has an open source license. This encompasses open source software, open source hardware, etc. So Phil argues that the end product of open source development is open source software, but open source software is _not necessarily_ the product of open source development. Since he also mentions that there are many different understandings of what open source means, what do you think about these definitions? Do you agree with the distinction he has made?


RDF and OWL: Have these delivered the promises of the Semantic Web?

These days I've been learning a lot about how different scientific fields are trying to move their data over to the Semantic Web in order to "free up data from being stored in isolated silos". I read a lot about how these fields are saying how their efforts are implementing the "visions" of the Semantic Web. As a learner (and from purely a learning perspective) I was curious to know why, if semantic technology is deemed to be so powerful, the efforts have been around for years but myself and a lot of people I know have never even heard of it until very recently? Also, I don't come across any scholarly articles deeming "oh, our inferencing engine was able to make such and such discovery, which is helping us pave our way to solving...." etc. It seems that there are genuine efforts across different institutions, fields, and disciplines to shift all their data to a "semantic" format, but what happens after all that's been done? All the **ontologies** have been created/unified, and then what?


In MVC, what is the difference between controller and router?

Do they mean the same thing (attaching URLs to actions, or actions to URLs) or is there any difference I'm missing? Example: http://github.com/dannyvankooten/PHP-Router vs. http://konstrukt.dk


How do I (tactfully) tell my project manager or lead developer that the project's codebase needs serious work?

I just joined a (relatively) small development team that's been working on a project for several months, if not a year. As with most developer joining a project, I spent my first couple of days reviewing the project's codebase. The project (a medium- to large-sized ASP.NET WebForms internal line of business application) is, for lack of a more descriptive term, a disaster. There are three immediately noticeable problems with the coding standards:   1. **The standard is very loose.** It describes more of what not to do (don't use Hungarian notation, etc..) than what _to_ do.   2. **The standard isn't always followed.** There are inconsistencies with the code formatting **everywhere**.   3. **The standard doesn't follow Microsoft's style guidelines.** In my opinion, there's no value in deviating from the guidelines that were set forth by the developer of the framework and the largest contributor to the language specification. As for point 3, perhaps it bothers me more because I've taken the time to get my MCPD with a focus on web applications (specifically, ASP.NET). I'm also the only Microsoft Certified Professional on the team. Because of what I learned in all of my schooling, self-teaching, and on-the-job learning (including my preparation for the certification exams) I've also spotted several instances in the project's code where things are simply not done in the best way. I've only been on this team for a week, but I see so many issues with their codebase that I imagine I'll be spending more time fighting with what's already written to do things in "their way" than I would if I were working on a project that, for example, followed more widely accepted coding standards, architecture patterns, and best practices. This brings me to my question: **Should I (and if so, how do I) propose to my project manager and team lead that the project needs to be majorly renovated?** I don't want to walk into their office, waving my MCTS and MCPD certificates around, saying that their project's codebase is crap. But I also don't want to have to stay silent and have to write kludgey code atop _their_ kludgey code, because I actually want to write quality software and I want the end product to be stable and easily maintainable.


What is the best design pattern for asynchronous message passing in a Chrome extension?

I have a background script that is responsible for getting and setting data to a `localStorage` database. My content scripts must communicate with the background script to send and receive data. Right now I send a JSON object that contains the command and the data to a function. So if I'm trying to add an object to the database I'll create JSON that has a `command` attribute that is `addObject` and another object that is the data. Once this is completed the background scripts sends a response back stating that it was successful. Another use case of the function would be to ask for data in which case it would send an object back rather than a success/fail. The code gets kind of _hacky_ once I start trying to retrieve the returned object from the background script. It seems like there is probably a simple design problem to follow here that I'm not familiar with. Some people have suggested future/promise design problems but I haven't found a very good example. Content Script               function sendCommand(cmdJson){     chrome.extension.sendRequest(cmdJson, function(response){         //figure out what to do with response     });     }      Background script               if (request.command == "addObject"){       db[request.id]= JSON.stringify(request.data);          sendResponse("success");     }     else if(request.command == "getKeystroke"){       var keystroke = db[request.id];       sendResponse(keystroke);     }


Why don't inherited methods use child properties? (PHP)

I'm trying to get the code below to work in child classes. But it keeps failing because it is checking the `basicDbClass` rather than the child class. For those complaining and voting my question down because of my use of static methods and variables, the static getBy method serves the purpose of returning an array of matching class objects. If you have a complaint about that methodology, then rather voting down every question that uses code you don't agree with, look for the next question about that subject and then give them your brilliant answer. If you're really antsy, I'll even do you the favor of asking that question so that you can get this out of your system. The main problem is in `static::$data_table`. When I do the following, I get a fatal error: > access to undeclared static property: basicDbClass::$data_table * * *               $obj_array = childClass::getBy('id',5);               class basicDbClass {              public static function getBy($property,$value) {             if(!property_exists(get_called_class(),$property) ) {                 debug::add('errors',__FILE__,__LINE__,__METHOD__,$property . ' is not a valid property.');                 return false;             }             $obj_array = array();             dbConnection::connect(MAIN_DB);             $sql = sprintf('SELECT `id` FROM `%s` WHERE `%s` = \'%s\'',static::$data_table,mysql_real_escape_string($property),mysql_real_escape_string($value));             $result = mysql_query($sql);             if($result === false) {                 return false;             }             while($row = mysql_fetch_assoc($result)) {                 $obj_array[$row['id']] = new static($row['id']);             }             return $obj_array;         }     }          class childClass extends basicDbClass {       protected static $data_table = 'child_class_table';       protected $name;       protected $id;     }


How do large-scale applications handle GUI creation?

I'm interested in developing GUI-based Windows applications in C++, but I'm not sure how it's done in professional or large-scale settings. It seems it would take a lot of development time to describe all the elements (e.g., dimensions and such) within code. Presumably it's not all done visually, right? How is it normally done? What methods are used to prevent a lot of time wasted on defining each and every property a UI control might have?


I have been programming for many years but I am still not comfortable with the concept of "Interfaces". I try to use interfaces but many times I don't see a mandatory use for it. I think this is probably because the projects weren't so big, or because interfaces are more useful when teamwork is involved. So, making another attempt to understand the importance of interfaces, here is my question: What problems will I face if I remove the concept of interfaces from my code?


Java-style package naming and second-level country domains

I own a .co.uk domain, and I whenever I've dealt with Java-style package naming, I've gone with `uk.co.domainname`. Once I encountered package that did the following: `co.uk.domainname`. Is one of these right, or is it something that's up to the developer's discretion? Is there some sort of convention that deals with this?


Were the first assemblers written in machine code?

I am reading the book The Elements of Computing Systems: Building a Modern Computer from First Principles, which contains projects encompassing the build of a computer from boolean gates all the way to high level applications (in that order). The current project I'm working on is writing an assembler using a high level language of my choice, to translate from Hack assembly code to Hack machine code (Hack is the name of the hardware platform built in the previous chapters). Although the hardware has all been built in a simulator, I have tried to pretend that I am really constructing each level using only the tools available to me at that point in the real process. That said, it got me thinking. Using a high level language to write my assembler is certainly convenient, but for the very first assembler ever written (i.e. in history), wouldn't it need to be written in machine code, since that's all that existed at the time? And a correlated question... how about today? If a brand new CPU architecture comes out, with a brand new instruction set, and a brand new assembly syntax, how would the assembler be constructed? I'm assuming you could still use an existing high level language to generate binaries for the assembler program, since if you know the syntax of both the assembly and machine languages for your new platform, then the task of writing the assembler is really just a text analysis task and is not inherently related to that platform (i.e. needing to be written in that platform's machine language)... which is the very reason I am able to "cheat" while writing my Hack assembler in 2012, and use some preexisting high level language to help me out.


Given some code, how can I learn where it loads resources from if the developer failed to document?

According to this tutorial OpenNI does not support custom gestures. However, Youtube has videos of people doing just that. Now, clearly this thing loads gestures from somewhere. How can I find out where if they've managed to obfuscate the code successfully?


Entity Component System Coupling

Lately I've been working on a small personal project which is basically an Entity Component System framework with autoupdated Systems. While I have a pretty good idea on the way the framework should work, because of lack of experience I am having trouble with actually keeping everything decoupled. Some details on the framework: Each entity is defined by it's components. Systems are responsible for the actually modifying the entities by changing their components. In order to improve locality of reference, instead of keeping each component in the appropriate entity, all components are stored in homogenous vectors and each entity keeps a list of indices to each vector. Since each System modifies specific components, it should keep a list only of the entities with the corresponding components. How I dealt with all of this until now was to have a ComponentManager, an EntityManager and a SystemManager. These classes however have very tight coupling with each other. The EntitManager needs to have access to the ComponentManager in order to handle the size of the the index lists and the mapping of each component type to them. It also needs access to actually add the components in the appropriate vector. Another coupling is between the EntityManager and the SystemManager. Whenever an entity is created, it needs to be added to the list of the appropriate Systems. A general event bus would appear to help but I am not sure how to implement it without making it global. How do I improve this design by removing coupling while still maintaining the system's functionality?


How to enter flow experience for SW development?

What are your strategies to improve the flow experience when doing work?


Where you are both the Authorization Server and Resource Server does it make sense to use OAUTH2 for security?

I'm curious if there are any use cases where it makes sense to use OAUTH2 where you are both the protected resource and the authorization server. In this case you have the passwords already for example so are protecting your own resource. Seems pretty heavy handed - is this a common practice or would it make sense to look at simpler solutions?


Can sequence alignment algorithms be used for search implementation?

Hi I want to implement a search on a website which includes imperfect search results. Meaning, if the search term is misspelled or slightly different from a 100% match, the function should still return results which are sorted by similarity in terms of the search keyword. I already have implemented algorithms like Smith-Waterman and Needleman-Wunsch which also can be used for database searching. So my idea was to run those algorithms against every keyword in the database and sort them by the score of each result. Is this a good idea? I am using ASP.NET in C#. Are there any tools or tricks which can accomplish this for me without using my own methods? My biggest concern is performance, after all those algorithms create at least one two dimensional matrix, calculate its values and perform a traceback. Any suggestions?


Managing debug information of C program for Debugger

I am not sure if the title is appropriate. I have written a parser for CDB files in C# and ANTLR that creates runtime objects for me such that I can pass it to the TCF Agent which takes care of everything that needs to be taken care of on the side of Eclipse. Such a CDB file consists of Symbol Records, Function Records, Module Records and also Type Records and so on. It describes a C program compiled with SDCC. I already have a good structure for local variables which debug information I can retrieve by resolving an ID that consists of   * **scope_flag** Indicates the scope of the symbol: `L` local, `G`global, `F`File, ...   * **module_base** The address of the modules where the local variable is declared   * **level** and **level** A tupel that points to a node of a tree where each node is a scope `{ .. }`. It doesn't matter if it is a function scope or a control command (`if`, `for`, etc.)   * **index** The index of the symbol inside a node (Therefore it is an ordered list) This works and should be fast enough even for large programs. If Eclipse wants to know anything about a symbol wheter it's the name, type or value it sends me an ID that looks something like this (values in hex):               L@C415.E.1.1      and I can identify the symbol in my parser. The main problem I got now are global symbols like global variables, function names and so on. At the moment I have a `Dictionary<T>` that maps the name of a symbol to its runtime object:               /* Dictionary that holds all global-scoped symbols. */     private Dictionary<String, CDBSymbol> m_nameToGlobalSymbolDict = new Dictionary<String, CDBSymbol>();      Now consider a very large program where a lot of global symbols may occur. Is such a large hash-table the best I can do? At the moment a global symbol ID looks like these:               G@function_name1     G@global_integer1     G@function_name2      The only thing that I might could do would be to add identifiers for functions, variables etc. like               G@C.function_name1     G@E.global_integer1     G@C.function_name2      where `C` means code and `E` internal RAM but that would only allow me to split the hash-table and nothing else. Can anybody suggest me a solution or tell me if this is already okey the way I'm doing it? I hope it is clear what I am asking for. If not please let me know.


How should I design a correct OO design in case of a Business-logic wide operation

**EDIT:** Maybe I should ask the question in a different way. in light of ammoQ's comment, I realize that I've done something like suggested which is kind of a fix and it is fine by me. But I still want to learn for the future, so that if I develop new code for operations similar to this, I can design it correctly from the start. So, if I got the following characteristics:   * The relevant input is composed from data which is connected to   several different business objects   * All the input data is validated and cross-checked   * Attempts are made in order to insert the data to the DB   * All this is just a single operation from Business side prospective, meaning all of the cross checking and validations are just side effects. I can't think of any other way but some sort of Operator/Coordinator kind of Object which activates the entire procedure, but then I fall into a Functional-Decomposition kind of code. so is there a better way in doing this? **Original Question** In our system we have many complex operations which involve many validations and DB activities. One of the main Business functionality could have been designed better. In short, there were no separation of layers, and the code would only work from the scenario in which it was first designed at, and now there were more scenarios (like requests from an API or from other devices) So I had to redesign. I found myself moving all the DB code to objects which acts like Business to DB objects, and I've put all the business logic in an Operator kind of a class, which I've implemented like this: First, I created an object which will hold all the information needed for the operation let's call it InformationObject. Then I created an OperatorObject which will take the InformationObject as a parameter and act on it. The OperatorObject should activate different objects and validate or check for existence or any scenario in which the business logic is compromised and then make the operation according to the information on the InformationObject. So my question is - Is this kind of implementation correct? PS, this Operator only works on a single Business-wise Operation.


PHP MVC error handling, view display and user permissions

I am building a moderation panel from scratch in a MVC approach and a lot of questions cropped up during development. I would like to hear from others how they handle these situations.   1. **Error handling** Should you handle an error inside the class method or should the method return something anyway and you handle the error in controller? What about PDO exceptions, how to handle them? For example, let's say we have a method that returns true if the user exists in a table and false if he does not exist. What do you return in the catch statement? You can't just return false because then the controller assumes that everything is alright while the truth is that something must be seriously broken. Displaying the error from the method completely breaks the whole design. Maybe a page redirect inside the method?   2. **The proper way to show a view** The controller right now looks something like this:              include('view/header.php');     if ($_GET['m']=='something') include('view/something.php');     elseif ($_GET['m']=='somethingelse') include('view/somethingelse.php');     include('view/foter.php');      Each view also checks if it was included from the index page to prevent it being accessed directly. There is a view file for each different document body. Is this way of including different views ok or is there a more proper way?   3. **Managing user rights** Each user has his own rights, what he can see and what he can do. Which part of the system should verify that user has the permission to see the view, controller or view itself? Right now I do permission checks directly in the view because each view can contain several forms that require different permissions and I would need to make a seperate file for each of them if it was put in the controller. I also have to re-check for the permissions everytime a form is submitted because form data can be easily forged. The truth is, all this permission checking and validating the inputs just turns the controller into a huge if/then/else cluster. I feel like 90% of the time I am doing error checks/permissions/validations and very little of the actual logic. Is this normal even for popular frameworks?


Automated Qt testing framework

Can someone recommend a good robust "Free" testing framework for Qt? Our requirements:   1. Should be able to test basic mouse click / mouse move events   2. Should be able to handle non-widget view components   3. Should have "record" capability to generate test scripts.   4. Should be automatable for running it daily. We looked at:   1. Squish - this solves all our problems. But it is just too da** expensive.   2. KD Executor - the download page now links to the squish page and says that's what they recommend for testing. Not sure what they mean by that.    3. TDriver - from nokia.qt. Super difficult to install. Very little documentation. Having a hard time to just install. I wonder how much harder it would be to write tests.   4. qtestlib - Could not handle non-widget components. Everything has to be a widget to be tested. No "record" feature.  Can someone help with any other alternative?


Saving all hits to a web app

Are there standard approaches to persisting data for every hit that a web app receives? This would be for analytics purposes (as a better alternative to log mining down the road). Seems like Redis would be a must. Is it advisable to also use a different DB server for that table, or would Redis be enough to mitigate the impact on the main DB? Also, how common is this practice? Seems like a no brainer for businesses who want to better understand their users, but I haven't read much about it.


Programming language features that help to catch bugs early

Do you know any programming language features that help to detect bugs early in the software development process - ideally at compile-time or else as early as possible at run-time? Examples of well-known and effective bug-reducing features are:   * Static typing and generic types: type incompatibility errors are detected by the compiler   * Design by Contract (TM), also called Contract Programming: invalid values are quickly detected at runtime (through preconditions, postconditions and class invariants)   * Unit testing I ask this question in the context of improving an object-oriented programming language (called Obix) which has been designed from the ground up to 'make it easy to quickly write reliable code'. Besides the features mentioned above this language also incorporates other Fail-fast features such as:   * Objects are immutable by default   * Void (null) values are not allowed by default The aim is to add more Fail-fast concepts to the language. If you know other features which help to write less error-prone code then please let us know. Thank you.


Why have minimal user/handwritten code and do everything in XAML?

I feel the MVVM community has become overzealous like the OO programmers in the 90's - it is a misnomer MVVM is synonymous with no code. From my closed StackOverflow question: Many times I come across posts here about someone trying to do the equivalent in XAML instead of code behind. Their only reason being they want to keep their code behind 'clean'. Correct me if I am wrong, but is not the case that: XAML is compiled too - into BAML - then at runtime has to be parsed into code anyway. XAML can potentially have more runtime bugs as they will not be picked up by the compiler at compile time - from incorrect spellings - these bugs are also harder to debug. There already is code behind - like it or not InitializeComponent(); has to be run and the .g.i.cs file it is in contains a bunch of code though it may be hidden. Is it purely psychological? I suspect it is developers who come from a web background and like markup as opposed to code. EDIT: I don't propose code behind instead of XAML - use both - I prefer to do my binding in XAML too - I am just against making every effort to avoid writing code behind esp in a WPF app - it should be a fusion of both to get the most out of it. UPDATE: Its not even Microsoft's idea, every example on MSDN shows how you can do it in both.


What's wrong with circular references?

I was involved in a programming discussion today where I made some statements that basically assumed axiomatically that circular references (between modules, classes, whatever) are generally bad. Once I got through with my pitch, my coworker asked, "what's wrong with circular references?" I've got strong feelings on this, but it's hard for me to verbalize concisely and concretely. Any explanation that I may come up with tends to rely on other items that I too consider axioms ("can't use in isolation, so can't test", "unknown/undefined behavior as state mutates in the participating objects", etc.), but I'd love to hear a concise reason for why circular references are bad that don't take the kinds of leaps of faith that my own brain does, having spent many hours over the years untangling them to understand, fix, and extend various bits of code. **Edit:** I am not asking about homogenous circular references, like those in a doubly-linked list or pointer-to-parent. This question is really asking about "larger scope" circular references, like libA calling libB which calls back to libA. Substitute 'module' for 'lib' if you like. Thanks for all of the answers so far!


Using a Directory Service instead of a Database

I've just started working on an existing application that uses an LDAP directory service as its object store instead of a database. Many of my coworkers have been commenting how an application should never use a directory service instead of a database as its object store. I've got to work on it regardless, and won't be able to change it from LDAP to a database anytime soon. That said, my coworkers comments brings up the question in my mind: _Why is it bad to use a directory provider instead of a database as an object store?_ Could there ever be cases where this would not only acceptable, but even better than using a database?


Visual Design implementation timing in Agile

We work in Scrum with the caveat that we don't have a potentially shippable product at the end of each Sprint, instead requiring several hardening/stabilization Sprints before release. One of the reasons for this is that our chief UX designer prefers that we'll complete all the visual work (such as colors, fonts, exact layout and controls) at the later stages of the project. On one hand it makes sense because a feature with decent UI based on a wireframe is usually good enough to receive feedback from the users, so working too hard on the final visuals and styles is not necessary for risk reduction. It might even be wasteful if the feature fails at usability tests or if after further user feedback we'll decide to change the visual design for the entire system, including features that were already implemented. On the other hand with this approach we will have a list of features that are not completely developed, and with the final polishes being left out until the final Sprints. What do you think we should do? Should we go with the recommendation of the chief UX designer or should we go for a potentially shippable product? Thank you.


Programming as a career option for a computer science graduate vs other fields?

> **Possible Duplicate:**   >  Why does a computer science degree matter to a professional programmer?   >  Do I need a degree in Computer Science to get a junior Programming job? There are various kinds of professions like : doctors - various degrees are required for this and you become a doctor or a surgeon after you complete it. engineers - electrical engineer, civil engineer, electronics engineer and many more. now when I see programmers working in companies, they have different degrees like a civil eng. degree, biotechnology degree, Mcom degree, mechanical eng degree.... and many more. It seems rather pointless that those people got those degrees but anyway but does your degree matters when you are a good programming. say somebody is good at C++ and is a civil engineer .... **what about stackoverflow or any other companies, would you consider such people for an interview or you would strictly mention that computer science is a must for applying.**


Visual Studio 2010 SP1 Performance

I've noticed since installing Visual Studio 2010 SP1 that I'm having huge performance issues. It will randomly freeze up on me quite a bit. I had no performance issues with Visual Studio 2010 before the upgrade. The only add-on I have running is ReSharper. I'm wondering if anyone else is experiencing performance issues? If so have you found a way to fix them?


Is ok to leave untranslated advanced log?

I just had a little fight with my boss over this topic (well, the boss always wins so I will do what he wants to be done) but I'd like to have the opinion of others about this: We are making a complex application that will be used by expert users (like the one who manages the company backups). I made an **Advanced log** , which contains 3 types of log:   * messages   * alerts   * errors Every error is translated and handled by the GUI, so the user will always know why something went wrong. My concern is about the **messages** : The main goal of those messages is to have a detailed idea of what is happening and help the expert user to solve problems by himself without calling for assistance. To do this I log a message (that will remain in RAM only, with a max message count) for every little kind of stuff, like               Connecting to server     Connection successfully     Request file list from path XXX     Starting receiving file list     File list successfully received      This can help to know **when** a problem occurred and to determine who is guilty for it. The main problem is: Our program is translated in more than 10 languages! Translating that HUGE amount of little messages will be expensive and it will be used only by some users. You can access to this messages list using an **Advanced console panel** , so it's clear it's for **Advanced** users. My boss wants those messages to be translated, but he doesn't want to spend a lot in translation, so he asked me to limit myself in using those messages. If I limit myself this message log can become useless, but if we don't translate it our program loses its " _friendly, translated approach_ ". What is the best thing to do? Pay more and translate everything? Limit message usage? Try to convince my boss that Advanced Users **SHOULD** know English?


Why (not) logic programming?

I have not yet heard about any uses of a logical programming language (such as Prolog) in the software industry, nor do I know of usage of it in hobby programming or open source projects. It (Prolog) is used as an academic language to some extent, though (why is it used in academia?). This makes me wonder, why should you use logic programming, and why not? Why is it not getting any detectable industry usage?


Using IIS as a server for non-http server

I am developing a system that is designed for multiple forms of interfacing. There is a website, but that is connected through an SDK, as well as an HTTP query interface to access data. But to improve speed and quality, I was thinking of creating a system inside IIS that get any message sent to the server, any response, but still let IIS manage SSL and normal socket connections. Is there a way to host my project in IIS without ASP or any other kind of script with extra behavioral events?


Uses of WCF Binding

From MSDN, we have the following definition of WCF Binding > Bindings specify how a WCF service endpoint communicates with other > endpoints. > > At its most basic, a binding must specify the transport (for example, HTTP > or TCP) to use. You can also set other characteristics, such as security and > transaction support, through bindings. I am looking for practical uses of WCF. The scnearions in which people tweak the abilities of WCF Binding. Some of them are listed below.   1. **Exporting Metadata** : - Custom policy assertions are exported by implementing the IPolicyExportExtension interface on a BindingElement class. What are the other practical uses of Binding that you usually use?


Making LISPs manageable

I am trying to learn Clojure, which seems a good candidate for a successful LISP. I have no problem with the concepts, but now I would like to start actually doing something. Here it comes my problem. As I mainly do web stuff, I have been looking into existing frameworks, database libraries, templating libraries and so on. Often these libraries are heavily based on macros. Now, I like very much the possibility of writing macros to get a simpler syntax than it would be possible otherwise. **But** it definitely adds another layer of complexity. Let me take an example of a migration in Lobos from a blog post:               (defmigration add-posts-table       (up [] (create clogdb                (table :posts (integer :id :primary-key )                  (varchar :title 250)                  (text :content )                  (boolean :status (default false))                  (timestamp :created (default (now)))                  (timestamp :published )                  (integer :author [:refer :authors :id] :not-null))))       (down [] (drop (table :posts ))))      It is very readable indeed. But it is hard to recognize what the structure is. What does the function `timestamp` return? Or is it a macro? Having all this freedom of writing my own syntax means that I have to learn other people's syntax for every library I want to use. > How can I learn to use these components effectively? Am I supposed to learn > each small DSL as a black box?


Active Record library with support for both SQL and NoSQL?

I'm looking for a PHP Active Record library that supports both SQL and NoSQL drivers (mongodb in particular). It doesn't matter if it actually has the NoSQL driver, I can write it myself, as long as the library itself supports it. In particular I'd need one that supports writing custom AR methods in the driver, in case they are methods that simply cannot be transferred to other drivers. The reason I want this is because I'd like to be able to talk to my databases the same no matter the driver, this will allow me to fairly easily transfer my data between different databases for performance testing. I'm not sure if this is the right place to ask for this, if not I apologize and would love to know what stackexchange site would be appropriate. For the record, I HAVE googled it, and all I can come up with is AR libraries for SQL databases, I haven't found a single one that combines SQL and NoSQL. Thank you.


Why would anyone invest time in Microsoft "Roslyn"?

I have just been reading through some of the white papers & examples from Microsoft "Roslyn" and the concept seems very interesting. From what I can tell, it opens up the black box that is the compiler and provides an interface that we can use to get information and metrics about code written in Visual Studio. Roslyn also appears to have the ability to "script" code and compile/execute it on the fly (similar to the CodeDom) but I have only come across limited uses for that type of functionality in my experience. Whilst the code analysis & metrics element is an interesting space...it is something that has been around for a very long time and there are numerous providers that have already invested a lot of money into code analysis & refactoring tools (e.g. ReSharper, CodeRush, nCover, etc) and they do a pretty good job of it! Why would any company go out of their way to implement something that can be provided at a fraction of a cost through buying a license for one of the existing tools? Maybe I have missed some key functionality of the Roslyn project that places it outside the domain of the mentioned tools...


How modularized should my interfaces be?

I stumbled upon a specific instance where it seems that modularity and simplicity are at conflict with each other. Usually that's not the case, so I was really unsure how to resolve it. Suppose I would like to make a `queue` interface:               template<typename T>     class queue {      public:       virtual ~queue() {}       virtual void enqueue(const T& t) = 0;       virtual void enqueue(T&& t) = 0;       virtual T dequeue() = 0;     };      As I was making a couple implementations (some of which are atomic), I noticed that I could really save time by having an "abstract class" which called on `empty()` or `full()` methods to help implement condition variables. That way any synchronized class I implement could also just extend that "abstract class." The abstract class, in turn, implemented an extended interface:               template<typename T>     class bounded_queue : public queue<T> {     public:       virtual ~bounded_queue() {}       virtual bool full() = 0;       virtual bool empty() = 0;     };      But wouldn't it be simpler if I just shoved those methods into `queue`, perhaps returning `false` by default? The answer to this question is not immediately obvious to me. If it is, then consider the other end of the spectrum. I'm not even sure the above design (in the link) works as expected! How do I decide on something simple, yet modular?


Were method cascades ever considered for C#?

Smalltalk supports a syntax feature called "message cascades". Cascades are being adopted by the Dart Programming language. As far as I know, C# doesn't support this. Were they ever considered during the design of the language? Is it conceivable that they could appear in a future version of the language?


Domain model for a notification system

I'm trying to build a modular notification service in a ASP.NET MVC web application. The application generates notifications and the service is responsible for delivering the notifications to the right users. When creating a domain model for the notification service, inheritance naturally comes to mind. ![Notification domain model](http://i.stack.imgur.com/jXxy3.png) One of the requirements for the notification service is that users can be subscribed to particular notification types. For example, **User** can subscribe to receive **NewMessage** notifications but not **ProfileNotification** notifications. How would one represent a relationship where a User has a Subscription to a notification type, but the notification type is represented through inheritance. Of course, this could be possible via reflection, but I was wondering if there was a domain model that came naturally from my requirements since I couldn't think of one. ![User has subscription](http://i.stack.imgur.com/XqX4g.png) I'm using ASP.NET MVC and Entity Framework Code First, but I think the question is general enough for any object oriented programming language.


How should I implement permissions?

I am using cppcms to create a blog like application and I'm trying to write a permission system, although I'm confused as to what would be the most efficient and manageable method. At the moment, I have a table with permission id, user id, permission type (int) and permission value (an optional parameter, of sorts). For each separate permission, a row must be added. Which method would you recommend? If you want any clarification or extra information, feel free to ask.


Does this BSD-like license achieve what I want it to?

I was wondering if this license is:   * self defeating   * just a clone of an existing, better established license   * practical   * any more "corporate-friendly" than the GPL   * too vague/open ended and finally, if there is a better license that achieves a similar effect? I wanted a license that would (in simple terms)   * be as flexible/simple as the "Simplified BSD" license (which is essentially the MIT license)   * allow anyone to make modifications as long as I'm attributed   * require that I get a notification that such a derived work exists   * require that I have access to the source code and be given license to use the code   * not oblige the author of the derivative work to have to release the source code to the general public   * not oblige the author of the derivative work to license the derivative work under a specific license Here is the proposed license, which is just the simplified BSD with a couple of additional clauses (all of which are **bolded** ). > Copyright (c) (year), (author) (email) > > All rights reserved. > > Redistribution and use in source and binary forms, with or without > modification, are permitted provided that the following conditions are met: > >   1. Redistributions of source code must retain the above copyright notice, > this list of conditions and the following disclaimer. >   2. Redistributions in binary form must reproduce the above copyright > notice, this list of conditions and the following disclaimer in the > documentation and/or other materials provided with the distribution. ** >   3. The copyright holder(s) must be notified of any redistributions of > source code. >   4. The copyright holder(s) must be notified of any redistributions in > binary form >   5. The copyright holder(s) must be granted access to the source code > and/or the binary form of any redistribution upon the copyright holder's > request.** > > > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" > AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE > LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF > SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS > INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN > CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) > ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE > POSSIBILITY OF SUCH DAMAGE.


Why would he say "We don't want to support MVC3"?

I work in a small shop at a fairly big company doing intranet web applications. By small, I mean there is 1 other guy in my position... and he graduated with me last December. (we aren't the only IT, but the only ones in our field) We are switching out an old COBOL system and converting it's only used application suite to a Web App. My company has contracted to a Web Application firm to help with this process who has chosen ASP.NET MVC, during one of the important meetings I asked if they will be using MVC2 or MVC3. Their lead developer said: > "MVC2, we don't want to support MVC3. haha" My question is, why is this? This was several months ago and I've been doing extensive and self training gearing up for the MVC switch. From everything I am understanding, MVC3 is just like MVC2 if you don't use Razor and it fixes a number of smaller bugs that MVC2 had. So in my eyes, I can't see any reason to **NOT** use MCV3. There has to be something I'm missing. Since I don't really have any mentors to turn to in the real world, I'm coming here. What problems are there with MVC3 that might possibly lead him to say this that I'm missing?


How to handle demanding clients?

Frequently, I have been finding myself overloaded with contracts. Most of the time, I find myself juggling with at least 2 projects, in addition to the numerous websites I have to upkeep and perform maintenance on. Unfortunately, many of my clients will expect updates constantly - are constantly adding more to the to-do list than any one programmer could keep up with, and freaking out because the deadline was already overdue when I started on a project. I constantly run into the fact most clients do not really understand the amount of work that can be involved behind the scenes, especially if it is non-visually-impacting. Does anyone know of good ways to handle these situations I might be overlooking?


Insert grammatical mistakes in a correct sentence

I'd like to insert grammatical mistakes (not typo) in a correct sentence, to make a small game. For instance:               My name is John     -> My name are John     He leaves the room     -> He leave the room      I only found some tools to detect languages but nothing about verb/noun/adjective detection/transformation. Is there a tool that could help me ?


How do you maintain productivity outside of work? (Programming Schedule)

I enjoy programming, but programming at work is just that, work. I would like to further develop my own personal interests in programming. Throughout the week I imagine myself completing a small project on the weekend or finishing up a programming related book. However, in reality I often fall short of my expectations. I often will get just one or two chapters of reading done and even less coding. In reality I will spend time surfing the net, watching television, or visiting friends and slacking off... because it is the weekend. But when Sunday evening rolls around I often reflect on my weekend and I am sorely disappointed with my use of time. So my question is how do you maintain your productivity outside of work? I am sure some programmers could care less about programming on their free time. Although, I think the majority of programmers, especially on stackexchange, are passionate about programming.   1. Should I spend the weekend programming, or will I burn out and resent programming if I dedicate that much time to it?    2. How should I go about programming on my free time? Should I set a schedule? How much time should I dedicate to it? **Most importantly how do I follow that schedule?** Its only human nature to procrastinate.  I know there is a lot of questions here. Feel free to answer the ones that relate to how you remained focused outside of work. I am passionate about programming but after 40 hours of programming it can be difficult to maintain that enthusiasm.


How do delegates fit into ASP.NET?

A developer told me they used delegates to bind most of their events in ASP.NET. Until then, I did not even know it was possible to use delegates in ASP.NET in a meaningful way. My understanding is that ASP.NET/MVC3 works via HTTP verbs, not events/delegates. Is it even possible to have an event fire from the client to the server? This strikes me as an invalid form of IPC.


What are the tradeoffs involved in referencing Context in a library?

`Context` is one of the core classes of Android, and many functions it contains are useful in Android library projects, particularly accessing configuration. What are the trade offs involved in accessing the `Context` in a library, either by injection or by subclassing `Application` in the library, and subclassing that in the application. Does this make the application brittle or introduce inappropriate coupling?


Updating password hashing without forcing a new password for existing users

You maintain an existing application with an established user base. Over time it is decided that the current password hashing technique is outdated and needs to be upgraded. Furthermore, for UX reasons, you don't want existing users to be forced to update their password. The whole password hashing update needs to happen behind the screen. Assume a 'simplistic' database model for users that contains:   1. ID   2. Email   3. Password How does one go around to solving such a requirement? * * * My current thoughts are:   * create a new hashing method in the appropriate class   * update the user table in the database to hold an additional password field   * Once a user successfully logs in using the outdated password hash, fill the second password field with the updated hash This leaves me with the problem that I cannot reasonable differentiate between users who have and those who have not updated their password hash and thus will be forced to check both. This seems horribly flawed. Furthermore this basically means that the old hashing technique could be forced to stay indefinitely until every single user has updated their password. Only at that moment could I start removing the old hashing check and remove the superfluous database field. I'm mainly looking for some design tips here, since my current 'solution' is dirty, incomplete and what not, but if actual code is required to describe a possible solution, feel free to use any language.


Authenticate native mobile app using a REST API

I'm starting a new project soon, which is targeting mobile application for all major mobile platforms (iOS, Android, Windows). It will be a client-server architecture. The app is both informational and transactional. For the transactional part, they're required to have an account and log in before a transaction can be made. I'm new to mobile development, so I don't know how the authentication part is done on these platforms. The clients will communicate with the server through a REST API. Will be using HTTPS ofcourse. I haven't yet decided if I want the user to log in when they open the app, or only when they perform a transaction. I got the following questions: 1) Like the Facebook application, you only enter your credentials when you open the application for the first time. After that, you're automatically signed in every time you open the app. How does one accomplish this? Just simply by encrypting and storing the credentials on the device and sending them every time the app starts? 2) Do I need to authenticate the user for each (transactional) request made to the REST API or use a token based approach? Please feel free to suggest other ways for authentication. Thanks!


Code Generation and IDE vs writing per Hand

I have been programming for about a year now. Pretty soon I realized that I need a great Tool for writing code and learned Vim. I was happy with C and Ruby and never liked the idea of an IDE. Which was encouraged by a lot of reading about programming.[1] However I started with (my first) Java Project. In a CS Course we were using Visual Paradigm and encouraged to let the program generate our code from a class diagram. I did not like that Idea because:   1. Our class diagram was buggy.    2. Students more experienced in Java said they would write the code per hand.    3. I had never written any Java before and would not understand a lot of the generated code.  So I took a different approach and wrote all methods per Hand (getter and Setter included). My Team-members have written their parts (partly generated by VP) in an IDE and I was "forced" to use it too. I realized they had generated equal amounts of code in a shorter amount of time and did not spend a lot of time setting their CLASSPATH and writing scripts for compiling that son of a b***. Additionally we had to implement a GUI and I dont see how we could have done that in a sane matter in Vim. So here is my Problem: I fell in love with Vim and the Unix way. But it looks like for getting this job done (on time) the IDE/Code generation approach is superior. Do you have equal experiences? Is Java by the nature of the language just more suitable for an IDE/Code generated approach? Or am I lacking the knowledge to produce equal amounts of code "per Hand"? [1] http://heather.cs.ucdavis.edu/~matloff/eclipse.html


What do you call an interface with no defining methods used as property setters

In ASP.NET and C# I've ran across this before. Your class needs to implement interface `ISomething` in order for something in the super class to supply something to you. I can't remember the details, as I ran across it quite a while ago, but it had something to do with session variables in ASP.NET C#. It was part of the .NET framework. At first, I thought this practice was rather silly and could be more gracefully implemented. However now I'm finding myself implementing this in the architecture of a home-grown project I'm working on. Using reflection, I detect the toggle a behavior on or off based on if it implements ISomething. Just an empty interface with no methods at all. What is the technical name for this and is it good practice?