title: Fixing a bug that has never caused a problem until now

text: I recently made a change that caused some code to be run far more often than it used to. This lead to the discovery of a bug. This bug had the potential to happen any time that code was run but because it was run so seldom it never surfaced. When I brought this to the lead developer's attention he wanted me to undo the change that exposed the bug rather than fix the bug quoting the adage, "If it ain't broke, don't fix it". Its clear to me that we were just lucky up until now but he won't listen to reason. Should I fix it anyway? **Update** The lead technically doesn't have any authority over me. Just tenure. He's been the sole developer on the project for a number of years until a year ago and I think he doesn't take constructive criticism very well. For what's worth, I didn't criticize him. I just pointed out that just because the bug never showed up didn't mean it wasn't there.


title: Is writing software in the absence of requirements a skill to possess or a situation I should avoid?

text: I find that some software developers are very adept at this, and often times are praised for their ability to deliver a working concept with abstract requirements. Frankly, this drives me crazy, and I don't like "making it up" as I go. I used to think this was problematic, but I've started to sense a shift, and I'm wondering if I need to adjust my thought (and programming) process when given very little direction. Should I begin to acquire this ability as a skill, or stick to the idea that requirement's gathering and business rules are the first priority?


title: Why is it an issue that it takes 2 digits to represent the number 10 in decimal?

text: So we use hexadecimal which has the advantage of going up to 15 in single digits A-F, but why is it an issue that it takes 2 digits to represent the number 10 in decimal? I was reading up about hexadecimal and I came across these 2 lines: > Base 16 suggests the digits 0 to 15, but the problem we face is that it > requires 2 digits to represent 10 to 15. Hexadecimal solves this problem by > using the letters A to F. My question is, why should we care how many digits it takes to represent a number? - Is it slower for the computer to deal with a number with 2 digits compared to 1?


title: Is personal branding necessary as a programmer?

text: I work as a Ruby developer/dev lead at a small startup company. I end up splitting my time between writing code, helping the team use more agile methodology and working with the product manager to get stories ready for the dev team. I enjoy my work and generally rate my enjoyment of work on these criteria:   * Good boss (no pointed haired managers)   * time is allowed to maintain the codebase (refactor code/write unit tests/etc.)   * get paid competitive salary   * no stupid deadlines   * work normal hours I am in no hurry to change jobs, but at least in the Ruby community it seems that everybody and their brother has their own blog, open source projects, or some other form of personal branding. I can just not get into these things. I really enjoy my work but when I go home I am ready to do something else and not spend hours writing blogs or writing more software. Is a requirement to write, blog, or engage in other forms of personal branding to keep myself marketable?


title: Do MVC web frameworks favor anemic domain model in order to avoid duplication?

text: Binding directly the form to your model helps a lot to get rid of boiler plate code, but that means that your model must have a getter/setter for each property otherwise it wouldn't be possible. Another choice would be to create another layer (DTO) only to carry the data to/from the form and then you can have a rich domain model not necessarily with getter/setter for each attribute but that means duplication of fields and validation code. For instance, right now I'm doing a web mail application. We know that we already have the Java Mail API, a good rich domain model. However, the way it is designed makes it impossible to bind my web form to that model. I am forced to create a DTO to capture the data and then pass it to the Java Mail API. Just like this example if my domain model would be like this one, the same would happen. From Spring MVC documentation: > Instead, it is often preferable to bind directly to your business objects. > > Reusable business code, no need for duplication. Use existing business > objects as command or form objects instead of mirroring them to extend a > particular framework base class. Do MVC web frameworks such as **Spring MVC and Struts 2** , favor anemic domain model in order to avoid duplication?


title: C Equivalent of Perl Unpack & Pack

text: I have some perl code that uses pack and unpack to transform the data in a way that I don't understand.               $unpacked_data = pack('b*', join('', unpack('(b7)*', $packed_data)))      Where $packed_data = a Byte Array of say, 2341 bytes, and with the above perl statement, unpacks to 2048 bytes of data. Can someone explain this statement to me in terms of C? So far, I know this:   * b = A bit string (ascending bit order inside each byte, like vec()).   * If the repeat count is * , the offset is relative to the start of the packed string.


title: Maintaining log stream after file name change

text: I'm trying to log to a file and move it about every 30 seconds. I'm using the os.rename function (which I do from a supervisord process) in python to move the current log to a timestamped log (which will then be processed by another python script) and then I continue to log to the old stream from my uwsgi server. I've also tried the RotatingFileHandler and the timed version, but they don't seem to work properly. I wasn't sure if that was a function of using it with the uwsgi server or not. My question is, what is the simplest and most efficient way to continue logging to the same file name after the file it was "pointing to" has been moved?


title: Can anyone suggest a project for me write to help me understand threading

text: I am currently a C# developer with a pretty shaky understanding of threading. Both of these links have been suggested in other posts: http://www.yoda.arachsys.com/csharp/threads/ http://www.albahari.com/threading/ Should I go back to basics and maybe look at some computer science texts on the subject? I really feel that if I jump in and use the c# libraries I won't really have a solid foundation of knowledge to build on. I think I need to learn this subject from scratch like a com sci student, then use the C# libraries. Can anyone suggest an approach to learning threading, maybe some links and or project ideas? Thanks in advance! Edit, thanks for all the replies. Some people have mentioned that a book might be a good idea, can anyone suggest one? I'd prefer something language agnostic. Does anyone know what class would this stuff be covered in in a Computer Science degree? I'm trying to google for some free online notes and assignments.


title: How should I refactor so that responsibility for a geocoding service is shared appropriately?

text: First, some background. I have an application that requires the use of several external geocoding providers which I don't control. It uses a central service layer inside the application to dispatch to the appropriate provider. I have a number of classes that are arranged in this way:   * **GeocodingService** : Responsible for dispatching a request to geocode something to an appropriate provider.     * Has one public method, `geocode`, that accepts a **GeocodingService::Request** and returns a **GeocodingService::Response**.     * Each response includes: the latitude of the geocoded query, the longitude of the geocoded query, and a list of address components for the address where the query was found (e.g., an address component for "123", one for "Main Street", one for "Paris", and so on).   * **GeocodingService::AddressComponent** : A single segment of an address that contains the segment's name, its abbreviation, and its kinds. For example, France has a name of `France`, an abbreviation of `FR`, and is a `country` and a `political` segment.     * AddressComponent is responsible for checking that the types an instance is set with are not outside the boundaries of certain tracked types.   * **Address** : Domain model for addresses, containing both a preferred mailing address (a list of string lines) and a list of address components (a list of GeocodingService::AddressComponents). My question is: **where should AddressComponent live -- as a service class (like it does now), or with my other domain models?**   * If it lives **in the service** , then life is straightforward. But that seems wrong, because now a domain model has to depend on a service's definition of an address, and it seems like they should be independent.   * If it lives as a **full-fledged domain object** , then doesn't that mean that the service is now coupled to a domain object? That also seems undesirable. How do I resolve this impasse?


title: Do programmers need computer eyewear

text: I am an programmer with great eyesight who stares at multiple computer screens 8-10 hours a day, usually in deep concentration. A day would not go by that I my eyes did not burn and have redness in them. I knew it was from the daily exposure to lcd monitors that caused the issues because on the weekends I would not have the same experience. Does any one try computer glasses? Is that work?


title: Java or Python for Google App Engine not knowing either language?

text: I have a few project ideas that I'd like to deploy on GAE. I'm interested in developing a logging application for amateur radio contacts, shortwave, and utility monitoring. More complex projects include satellite tracking, audio streaming from multiple radios, and radio remote control including transmitting and receiving. I'm taking Java and Python languages through my local junior college, so I don't know which language is suitable for these projects. What are the strengths and weaknesses of each language for developing on GAE specifically, especially audio and number crunching for the tracking app? I'm not asking for a general comparison between the two languages, only as they are used on GAE. The end result is to tie them into my website which is hosted on Google, with some of the apps publicly available, some privately available to friends. If it helps, I have the most experience with Perl, bash, followed by C.


title: Learning Arlgorithms particularly graph algorithms (java)

text: I have a hard time learning algorithms (Particularly graphing algorithms). Do you know of any good free resources that make some of the more harrowing algorithm concepts such NP-Complete, Traveling salesman, and other algorithms, A* heuristics, particularly graphing algorithms, simpler to learn?


title: What percent of your college course work is unit-tested code?

text: As a college student do you write unit-test for the project code you write? Do you know how to properly use TDD? Have you been taught to use testing frameworks (jUnit for example)? I've just recently heard that a major company's project team was delivering software to User Acceptance Testing group that had only 7% line code coverage for unit testing. While that shocks me, it just tells me that this company's software engineering practice are immature. However I wonder if they could just hire a few recent graduates and raise the bar on the teams practices - assuming that these newly minted programmers were trained in the best practices. Are you 2008 - 2010 CS graduates using best practices of unit testing your code?


title: Resolving equivalence relations

text: I am writing a function to label the connected component in an image (I know there are several libraries outside, I just wanted to play with the algorithm). To do this I label the connected regions with different labels and create an equivalence table that contain information on the labels belonging to the same connected component. As an example if my equivalence table (vector of vector) looks something like:               1:    1,3     2:    2,3     3:    1,2,3     4:    4      It means that in the image there are 2 different regions, one made of elements that are labelled 1,2,3 and an other made of elements labelled 4. What is an easy and efficient way to resolve the equivalences and end up with something that looks like:               1: 1,2,3     2: 4      that I can use to "merge" the different connected regions belonging to the same connected component? Thanks a lot for the help!


title: Is it bad form to change multiple tables in a single Rails migration file?

text: I wrote a migration file with the following code:               class AddScheduleIdToPlayers < ActiveRecord::Migration       def change             add_column :players, :schedule_id, :integer             add_column :schedules, :coach_id, :integer       end     end      Is it bad form to not create two migration files, one for each change, or is this fine?


title: So, "Are Design Patterns Missing Language Features"?

text: I saw, here on Programmers, the answer to this question: How does thinking on design patterns and OOP practices change in dynamic and weakly-typed languages? There I found a link to an article with an outspoken title: Are Design Patterns Missing Language Features. But where I found snippets that to me seemed very catchy and that can be probably verified against experience given there is an incentive for that , like: > PaulGraham said "Peter Norvig found that 16 of the 23 patterns in Design > Patterns were 'invisible or simpler' in Lisp." or another sentence that confirms what I recently seen with people trying to simulate classes in JavaScript: > Of course, nobody ever speaks of the "function" pattern, or the "class" > pattern, or numerous other things that we take for granted because most > languages provide them as built-in features. OTOH, programmers in a purely > PrototypeOrientedLanguage? might well find it convenient to simulate classes > with prototypes... I am also taking into consideration that design patterns are a communcation tool. Because even with my limited experience participating in building applications I can see as an anti-pattern(ineffective and/or counterproductive) for example, forcing a small PHP team to learn GoF patterns for small to medium intranet App. I am aware that scale, scope and purpose can determine what is effective and/or productive, but still I didn't managed to find an technical overview about that. I saw small commercial applications that mixed functional with OOP and still be maintainable, and I don't know if many would need for example in python to write a singleton , but for me a simple module does the same thing. ### So are there studies, exhaustive articles or other form of exposition that takes into consideration design patterns vs. workarounds vs. simpler ways to do it, or replacements by language features ?


title: Metrics for architecture complexity

text: Just like we can measure complexity of code and algorithm, are there any metrics for measuring architecture/design/solution space complexity.


title: How to earn team members respect as team lead

text: If you were hired into a new company as a team lead (say a team of 10) one of the important things to do is to earn the respect of the members of the team. In the early days the new team lead may know nothing of the team culture, code base and business domain: in other words, is a complete neophyte. How does one go about this? What are the do's and don'ts?


title: ORM Tools and advantages of circular references in entities

text: Let me demonstrate a simple example, > Class Organization > >   * ID type Number, >   * Name type String, >   * HAS A -> Collection > > > Class Facility > >   * ID type Number, >   * Name type String, >   * Location String , >   * HAS A -> Organization > I am demonstrating a simple circular reference between two objects of an anemic data model. Assuming they are mapped to an ORM tool, a collection of Facility can be fetched lazily from an Organization, and likewise an Organization can be fetched lazily from a Facility. I understand the convenience of this, at least on the middle tier. With a single Facility I can immediately obtain information about its Organization from code. My question then is: _Are there ANY other advantages to circular references in ORM mapped entities?_ Despite my intense emotions on this subject right now, I am trying my best to not load the question... The prime infuriating disadvantage I am sufferring through at this moment is when I am trying to serialize these objects into XML and send them across a web service, far from the lofty comforts of its benevolent ORM session. I can't serialize them as is because the ORM proxies cannot be sent, I must either eagerly fetch the child entities and send a MASSIVE object tree, or strip out the proxies from the graph. Fair enough, so I wrote a utility to simply remove proxies, Great! It serializes and performance is salivatingly good, however when I get this object back from an UpdateEntity web service, it is missing the rest of the object graph, and now if I were to update this entity through the ORM, it thinks I have deleted all of these objects missing from the tree. No good. I can't help but feel that circular references present a massive disadvantage in this scenario and I can't really seem to think of a good way to overcome this problem and the crippling performance problems I am tasked with solving without a data model redesign and massive refactoring. What are your opinions on this? Is this indeed a design-smell?


title: What are some ways to reliably test for browser support for HTML5 features such as Geolocation?

text: HTML5 introduces a wide variety of tools such as Geolocation. Many browsers support them, but some do not yet. Should web developers rely on them to build professional applications for industry? The features are powerful, but not all browsers support these features. What are some ways (perhaps Javascript libraries?) to reliably test for browser support for HTML5 features such as Geolocation?


title: GPL and closed-source licensing for selling my script

text: I am working on a PHP script that I plan to sell without giving the user the ability to distribute it to anyone else. I have heard about GPL being viral and I have quite a few libraries that are being used in my script that are under the GPL. (for example : jquery, phpthumb etc) Does this mean that if a user who has bought my code can freely distribute it because a part of my code is under GPL so it becomes viral and my whole project becomes GPL ? **Can i not use any GPL code in my project ?** Thanks for any help.


title: What precautions should be taken when joining a software company?

text: I am joining a software company very soon as a fresher. But I am afraid that no one knows me and also every one there will be professional. So I want to know, what precautions should be taken in communication, behavior and other things?


title: Why do programmers use or recommend Mac OS X?

text: I've worked on both Mac and Windows for awhile. However, I'm still having a hard time understanding why programmers enthusiastically choose Mac OS X over Windows and Linux? I know that there are programmers who prefer Windows and Linux, but I'm asking the programmers who would just use Mac OS X and nothing else, because they think Mac OS X is the greatest fit for programmers. Some might argue that Mac OS X got the beautiful UI and is nix based, but Linux can do that. Although Windows is not nix based, you can pretty much develop on any platform or language, except Cocoa/Objective-C. Is it the applications that are only available on Mac OS X? Does that really make it worth it?   Is it to develop iPhone apps?   Is it because you need to upgrade Windows every 2 years (less backwards compatible)?   I understand why people, who are working in multimedia/entertainment industry, would use Mac OS X. However, I don't see what strong merits Mac OS X has over Windows. If you develop daily on Mac and prefer Mac over anything else, can you give me a merit that Mac has over Windows/Linux? Maybe something you can do on Mac that cannot be done in Windows/Linux with the same level of ease? I'm not trying to do another Mac vs. Windows here. I tried to find things that can be done on Mac but not on Windows with the same level of ease, but I couldn't. So, I'm asking for some help.


title: Long term plan of attack to learn math?

text: I am a web-developer with a desire to expand my skill-set to mathematics relevant to programming. As 2nd career, I am stuck in college doing some of the requirements while working. I was hoping the my education will teach me the needed skills to apply math, however I am quickly finding it to be too much easily-testable breadth-based approach very inefficient for the time invested. For example in my calculus 2 class, the only remotely useful mind expanding experience I had was volumes and areas under the curve. The rest was just monotonous glorified algebra, which while comes easy to me, could be done by software like wolfram alpha within seconds. This is not my idea of learning math. So here I am a frustrated student looking for a way to improve my understanding of math in a way that focuses on application, understanding and maximally removed needless tedium. However I cannot find a good long term study strategy with this approach in mind. So for those of like mind, how would you go about learning the necessary math without worrying too much about stuff a computer can do much better?


title: Mobile Development- Obtaining development hardware - best practices?

text: I'm looking to get into smartphone development, but there a quite a few options out there for platforms right now. (iOS/Android/WebOS/Bada/Symbian/MeeGo/WindowsMobile/JavaME) I'd like to have development hardware to test my code and the overall functionality of the devices. What is the best way to obtain and/or borrow hardware for development and testing? Are there rules of thumb to follow which apply to all companies and platforms? In this situation, I'm a single developer. Does this process change for a startup? A hackerspace? A small business? A large business?


title: Store Arbitrary values related to mysql record

text: I have created an app that manages a Data cleansing workflow. Each row imported needs to store an arbitrary number of key value pairs in addition to our standard mysql schema. The key values need to be searchable. I am using rails + mysql currently. What are my options? As of now, I am just adding a new fields to the rails schema as new requirements arise, I need a way to store extra data for each row that might not apply to any other rows.


title: MVC, WCF, EF, LINQ - Is it just me?

text: ...or are things getting more complicated? It seems to me that you need to know a lot of stuff to 'properly' develop an MS web app these days. In the bad old days when we didn't know any better we had database tables, ASP.NET, ADO.NET and you constructed a web app using relatively simple concepts. These days there seems to be a lot of framework around to 'help' you do it 'right', but I'm not convinced this makes it all easier and better. I've got a feeling I'll be in a pretty small minority with this sentiment, but is there anyone else out there who thinks that things have gone a bit mad?


title: Nulls in every type and checked exceptions in Java?

text: I know that null being added to every type in Java is a source of much frustration regarding the language's type system. At the same time I generally hear complaining about checked exceptions - that they clutter interfaces, encourage exception swallowing, etc. It seems to me like null inhabiting every type is a way around the language - like I want the type of this to be `X`, but it's actually `X or null`; it just doesn't look like that and is easy to forget. Don't checked exceptions provide a way for the type of something to be `X or throws Exception` instead of it appearing to just be `X`? It provides an in-code way to specify how something can fail. Nulls in every type and unchecked exceptions seem like they are dual concepts, but one is scorned and the other praised. Why is that?


title: What to learn to become freelancer?

text: I have around 8 years experience in software development. I have worked on application development all these years using C++ /win32. I few years from now I want to become a freelancer . I tried to look into some freelance sites and I am not able to find any projects on C++/win32. I feel C++/Win32 wont help me much and I need to learn new skills . But my job require me to still work on C++ , so I cann't learn any new skills. I can still learn some new skills but without good project , it won't make any sense. I have shortlisted few skills   1. php   2. jquery   3. perl   4. python   5. android I am still confused which one to start and how to get expertise in them.Any suggestions?


title: Keeping tech support on the latest software version

text: I'm the only software developer maintaining a subset of products at a small company. The main product I'm concerned with here is a web app which is installed on various clients' machines, with a database and background processes. I make changes on a need-to basis for this program. It's not the company's flagship product, it's not my main project, but it needs maintenance. I have 2 and a half support technicians who take in questions from customers. When they don't know how to fix things, I'm their support. Because I do some maintenance here and there, I release updates irregularly. However, the idea is that I'm fixing the software, and on a client's request, the support technicians can update said software to fix an issue or as good measure (there's no built-in update function). The support technicians also keep a copy on their machine, or rather, various copies of past versions. This is where it gets ugly. I get, irregularly, reports of bugs for things I might have already fixed on previous versions. When they find a bug, the support techs spend a lot of time going _backwards_ in versions, trying to get to a version where the bug isn't there. At this point they either throw it in my face ("Why did you break this?") or install older versions at the clients'. **Which can obviously break other things**. In order to resolve this I've:   * pleaded with them   * pleaded with their supervisor   * pleaded with the CEO   * refused to work on older versions until new versions are installed, even if they demonstrate the bug is still present   * threatened to remove support altogether (which is moot, since it's still my job) No dice. The last option I see is to setup something with SVN where they can only get the latest version and not revert (if that's doable)... And hope they don't learn to make copies. Is there some other approach, human, organizational, technical, or otherwise that can help me and keep these guys on the latest version?


title: Is it bad habit not using interfaces?

text: I use interfaces rarely and find them common in others code. Also I create sub and super classes (while creating my own classes) rarely in my code.   * Is it a bad thing?   * Would you suggest changing this style?   * Does this style have any side-effects?   * Is this because I have not worked on any large projects?


title: How secure is localstorage?

text: The question says it all really. I want to provide a service but I do not want to store any of the data myself in a database. With all the recent news of hacking etc it seems to me that it is nicer that clients have complete control over their data. The problem is that the data stored is potentially sensitive. What I was going to do was... when a client visits the website there would be a question asking 'are you on a personal computer or a public computer'. If they are on a public computer the site would refuse access. If they were on a personal computer it would then prompt them to set a password. All their data would then be encrypted with this password. Now obviously this is not too secure. The encryption method would be in JavaScript and their password in plain text so I assume it would be possible for a savvy user to locate the password in the localStorage and access the data. I feel though that this isn't too much of a problem. If you are using a personal computer the chances of this happening are remote as... someone else would need access to their specific user account on the computer, someone else would need to know about the site... someone else would need to understand localStorage and how to access it. The sensitive data isn't any that will compromise their identity or much else. It just records something most people wouldn't like publicly published. So really the question is, is localStorage secure enough? Additional question.. how difficult is to wipe your localStorage? I wouldn't want users to accidentally wipe their data. Finally - is it even worth encrypting / decrypting their data as if you have the password you can access the site..


title: Which algorithms typify Lisp's power?

text: Similar question here (but not the same) because I am interested in which specific algorithms work particularly well in Lisp. Lisp tutorials always give the example of finding factorials, but wanting to find factorials is not a good enough motivation to use Lisp. I've heard that Quicksort has a particularly elegant implementation in Lisp. Can you give examples (and code samples too) of examples of algorithms that are best implemented in a language like Lisp?


title: Where to save something between invocations?

text: The 2nd time I run this program I'd like it to start in the same HDD location as the previous instance. How should I save, or remember, where I was so the program starts in the same place? I'd like to persist my previous location the same way across MAC, Linux, Windows, ... Where is a good place to save my location so it's available to me the next time I run?


title: hosting website from home

text: If I want to host a website from my home, I buy a domain name. Then, I get a static IP from my ISP. Next, I point it to the IP address of my home system. I can even use the SQL server installed in my system and not worry about the size. I am not talking about piles of servers here. Just one server. I was wondering if it is that easy, why not do it? Is there something that I am missing here? I am talking about moderately simple website. But does it matter?


title: Databinding to an Entity Framework in WPF

text: Is it good to use databinding to Entity Framework's Entity in WPF? I created a singleton entity framework context:   1. To have only one connection and it won't open and close all the time.   2. So I can pass the Entity around to any class, and can modify the Entity and make changes to the database. All ViewModels getting the entity out from the same Context and databinding to the View saves me time from mapping new object, but now I imagine there is problem in not using the newest Context: A ViewModel databinding to a Entity, then someone else updated the data. The ViewModel will still display the old data, because the Context is never being dispose to refresh. I always create new Context and then dispose of it. If I want to pass the Entity around, then there will be conflicts between Context and Entity. What is the suggested way of doing this ?


title: Is Node.js correct choice for JSON parsing and IO driven

text: My program should perform following task: It listen on http port after getting request it does following things.   1. Connect to gearman    2. Parse gearman payload to JSON (Upto 100 bytes)   3. Connect to Redis    4. Parse redis payload to JSON (256 bytes to 10KB. 80% cases it will ~256 bytes)   5. Put some data in MySQL   6. Put data in Redis server  As my program seems to be IO driven. I have chosen nodesjs for developing. But after developing I am facing CPU hike related issue with nodejs. My program taking 70%-100% cpu with 20 parallel clients. First I thought JSON parsing could be the issue. I was targetting near about 1K-3K request. As my redis server is able to process that may request in one second. But for profiling I have started with one sample http server in node Example code:               var http = require('http');     var url = require("url");     http.createServer(function (req, res) {         var uri = url.parse(req.url).pathname;                   var body = "";              req.on('data', function (chunk) {             body += chunk;         });              req.on('end', function () {                  res.writeHead(200, {'Content-Type': 'text/plain'});                                 res.end('hi vivek');         });               }).listen(9097, "127.0.0.1");      **Now my concern is with this hello world http server. Node CPU usage is spiking b/w 17%-20%.**               My node version is v0.10.0     My OS is ubuntu 12.04      My cpu information is               processor   : 0     vendor_id   : GenuineIntel     cpu family  : 6     model       : 23     model name  : Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz     stepping    : 10     microcode   : 0xa07     cpu MHz     : 2992.491     cache size  : 6144 KB     physical id : 0     siblings    : 2     core id     : 0     cpu cores   : 2     apicid      : 0     initial apicid  : 0     fpu     : yes     fpu_exception   : yes     cpuid level : 13     wp      : yes     flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority     bogomips    : 5984.98     clflush size    : 64     cache_alignment : 64     address sizes   : 36 bits physical, 48 bits virtual     power management:          processor   : 1     vendor_id   : GenuineIntel     cpu family  : 6     model       : 23     model name  : Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz     stepping    : 10     microcode   : 0xa07     cpu MHz     : 2992.491     cache size  : 6144 KB     physical id : 0     siblings    : 2     core id     : 1     cpu cores   : 2     apicid      : 1     initial apicid  : 1     fpu     : yes     fpu_exception   : yes     cpuid level : 13     wp      : yes     flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority     bogomips    : 5984.96     clflush size    : 64     cache_alignment : 64     address sizes   : 36 bits physical, 48 bits virtual     power management:      My questions are:   1. Is node correct choice for my problem description?   2. If nodejs is not correct choice for my problem description. What will be better alternative? As thread based approach will not scale for IO driven application.    3. How to find out what is causing that much CPU hike in complete integrated application and simple http program?   4. According to some node blog, I can support upto 10K parallel request with nodejs. But with if with only simple http server node is spiking b/w 20% cpu. How I will be able to support 10K user?


title: how to convince team and project manager that post-launch deployments are okay for new features

text: We have a site that launched and is "feature-complete", we've done all that the client has asked for and fixed a few bugs post-launch. However, I noticed that our site's home page is using 100 SQL queries, and there's _no_ caching. I took half a day to add caching and did it in a branch. Now I'm wondering how I can convince the project manager and other team members and gain support for a post-launch deployment of this optimization. What reasons can I give that it won't harm the project to do this? Or do I just wait until the next project launches to make these sorts of improvements? More details:   * I can't very well tell future employers that I implemented caching and saw an increase in performance without actually deploying it and capturing the improvement (through google analytics or Page Speed or some other method), or can I?   * This is an agency environment, none of our projects use any caching or any other performance optimization   * The site has 50k visitors   * The site is only live with full functionality for 1 month, around the end of May it will be replaced with a static page (marketing campaign site)   * local testing reducing page load from ~3 seconds to ~700ms


title: Creating Set Subclasses or Allowing Outside Configuration

text: I have a `TriggerCaller` and a `TriggerAction` class. The Caller "calls" the `do()` method on the action, which is set with the `TriggerCaller`s `setAction()` method. The rest of the program should deal with the `Trigger` class, which contains the caller and the action. I have two options: 1) Give the `Trigger` class the methods `setAction` and `setCaller`. This seems to make sense because it means I won't have to redefine things for each subclass (see option 2) and I won't favor one object over the other (see option 3). 2) I can define `Trigger` subclasses for each Caller-Action combination. This seems to "feel" better for some reason I can't articulate, but is impractical. There are simply too many combinations of TriggerCallers and TriggerActions to make. 3) Define a `Trigger` subclass for each `TriggerCaller`, for instance `TriggerMIDI` for the `MIDICaller` and give that class a `setAction()`. This seems to make sense from a GUI perspective, because in the interface people select the `TriggerCaller` type from a "Create" menu and then config it with an action in a dialog (along with other things). I feel that (1) makes the most sense, but somehow it just feels... wrong. I think that I'm exposing too much of the classes inner workings. I'm also putting the burden on the GUI code of setting the class up (sort of). Is there a better solution? Which one should I choose?


title: Building a company and want to know how ethical to put samples from projects I did before on the new company website

text: I built a lot of websites and applications during my life, I can put them under the following categories:   * Did all the project as a freelancer -> For other companies    * Did part of the project as a freelancer -> For other companies    * Did all the project my self while was working for another company    * Did the project with team members while was working for another company    * Did all the project my self and for my self Now I am creating a company with a new brand and have my own employees, My question is: Is it ethical, and normal to put on my new company website, screenshots and info about these projects I created my self before? which to put and which not put from the previous categories?


title: Verification of requirements in a closed system

text: I'm on my first real software project following the whole SDLC and am a bit confused. We have a requirement that states something like "The battery will be monitored each second" which needs to be verified. This is something that can't really be checked in the system since it happens "inside", i.e. there's no output that would show that the battery was checked each second. It is my understanding that at this phase the verification is done on a closed system, so you can't just use a debugger to verify something like this. Is this assumption wrong? Or can the requirement be considered to be ambiguously defined.


title: In what areas of programming is algorithm run time actually an important issue?

text: Sometimes I hear people say that because of the speed of processors and the amount of memory available, algorithm efficiency and runtime aren't, in practice, of major concern. But I imagine there are still areas where such considerations do remain of paramount importance. Two that come to mind are in algorithmic trading, where thousands of transactions must be conducted in fractions of a second, and embedded systems programming, where memory and power are often scarce. Am I right about these examples ? and what other areas would also be examples?


title: Database Schema for Pricing Products (packages, promotions, qty based, limited time offer...)

text: I'm working on a new point of sale for a company that products for different prices depending on the product mix. All products have a base price. To explain my problem, I will use the following info:               Product         Category        Price     A               1               45     B               1               70     Q               2               20     R               2               27     S               2               15     X               3               17     Y               3               22     Z               3               16      The company has Packages, for example Package "Combo": for product A or B, if you choose 1 of Q or R and 1 of X, Y or Z you get a $20 discount. **Case A:** Sometimes customers add on to a base product when placing an order, for example: They wan't one of Product A, and they add Product Q and Product P to that to create a package that has a discounted price. Then they might add that they want 1 of product B with 1 R and 1 Z. **Case B:** Sometimes customers will add 1 A and 2 B, 2 Q, 1 S, 2 X and 1 Z. According to the rules set forth by "Combo" Package, only 2 combos would apply because S is not a combo item. Other promotions are dependent on quantity, so if you buy 2 of B you get 20% off and/or dependent upon time, it is only valid after 5 PM or before 10% off if before 10am. Another promotion might depend on when your last purchase occured or if you have purchase more than $X in Y timeframe. **My Problems:** 1) How do I structure the tables so I my create the different packages or promotions in a way that is very flexible to add different types of promotions with different requirements? 2) When they order like Case B (or a mix of Case A and Case B) how do I structure my query so that I can test to see what product mix(es) are in the order, and update the prices/descriptions accordingly? Ultimately, the best result for this query would return which packages and promotions have requirements fulfilled in order of which gives the most benefit to the customer (i.e. maybe what they ordered fulfills requirements for promotion 1 and 3, but promotion 3 is less expensive. This must work with multiple promotions). Thanks in advance for the help! **UPDATE #1** To better describe the problems at hand and to update the work done thus far to solve them I'm incluiding an ERD of the Product Model limited to the entities and attributes that affect the issue (i.e. inventory is not at play here, so no inventory entities are present). ![enter image description here](http://i.stack.imgur.com/JaKxi.png) I'm also including sample data from the entities and attributes that affect this question (to simplify reading the data, I'm putting in name/descriptions in place of Foreign Keys): Here is a link to a flow chart giving an example of a combo, a fast and visual way to understand the table structure.               PRODUCT     ---------     ID  Name     ================================     1   Hamburger     2   Cheeseburger     3   Bacon Hamburger     4   Bacon Cheeseburger     5   Orange Juice     6   Apple Juice     7   Coffee     8   Coke     9   French Fries     10  Onion Rings     11  Soup du Jour     12  Hamburger Combo     13  CheeseBurger Combo     14  Bacon Hamburger Combo     15  Bacon Cheeseburger Combo     16  Combo Side     17  Combo Beverage     18  Small Orange Juice     19  Large Orange Juice     20  Small Apple Juice     21  Large Apple Juice     22  Add Extra Patty     23  Add Avocado          PRODUCT COMPONENT     ------------------     productFrom                 productTo            ===================================================     Hamburger Combo             Hamburger     Hamburger Combo             Combo Side     Hamburger Combo             Combo Beverage     CheeseBurger Combo          Cheeseburger     CheeseBurger Combo          Combo Side     CheeseBurger Combo          Combo Beverage     Bacon Hamburger Combo       Bacon Hamburger     Bacon Hamburger Combo       Combo Side     Bacon Hamburger Combo       Combo Beverage     Bacon Cheeseburger Combo    Bacon Cheeseburger     Bacon Cheeseburger Combo    Combo Side     Bacon Cheeseburger Combo    Combo Beverage          PRODUCT FEATURE     ----------------     ID  Description     =======================     1   Combo Side Option     2   Combo Beverage     3   Juice     4   Orange Juice Size     5   Apple Juice Size     6   Extras          PRODUCT FEATURE APPLICABILITY     ------------------------------     product                     productFeature  ProductFeatureApplicabilityType     ============================================================================     Hamburger Combo             Combo Side      Required     Hamburger Combo             Juice Flavor    Required     Cheeseburger Combo          Combo Side      Required     Cheeseburger Combo          Juice Flavor    Required     Bacon Hamburger Combo       Combo Side      Required     Bacon Hamburger Combo       Juice Flavor    Required     Bacon Cheeseburger Combo    Combo Side      Required     Bacon Cheeseburger Combo    Juice Flavor    Required               PRODUCT FEATURE APPLICABILITY     ------------------------------     productFeature  product             ProductFeatureApplicabilityType     ============================================================================     Combo Side      Hamburger Combo             Required     Combo Beverage  Hamburger Combo             Required     Extras          Hamburger Combo             Optional     Combo Side      Cheeseburger Combo          Required     Combo Beverage  Cheeseburger Combo          Required     Extras          Cheeseburger Combo          Optional     Combo Side      Bacon Hamburger Combo       Required     Combo Beverage  Bacon Hamburger Combo       Required     Extras          Bacon Hamburger Combo       Optional     Combo Side      Bacon Cheeseburger Combo    Required     Combo Beverage  Bacon Cheeseburger Combo    Required     Extras          Bacon Cheeseburger Combo    Optional                         OPTIONAL FEATURE     ------------------     productFeatureFrom  Product             ProductFeatureTo             =============================================================     Combo Side Option   French Fries     Combo Side Option   Onion Rings     Combo Side Option   Soup du Jour     Combo Beverage                          Juice     Combo Beverage      Coffee     Juice                                   Orange Juice Size     Juice                                   Apple Juice Size     Orange Juice Size   Orange Apple Juice     Orange Juice Size   Orange Apple Juice     Apple Juice Size    Small Apple Juice     Apple Juice Size    Large Apple Juice     Extras              Add Extra Patty     Extras              Add Avocado      So, with the research and support provided by the community up until know, I have been able to solve Problem #1. In fact, I have done so with more flexibility than I thought I could do in the first deployment of the system. All though there have been advances with Problem 2, it is not solved to satisfaction. There have been some ideas on how to do this, Neil McGuilgan asked a great question leading towards a possible solution using Relational Division (dba.stackexchange.com/questions/45829/what-is-the-name-of-this-type- of-query-and-what-is-an-efficient-example) and this book (www.amazon.com/books/dp/0471380237) helped a lot. However this solution at present, and as I understand it, only works with "one" record (combo) at a time. If a customer Walks up and says he wants 2 cheeseburgers, 1 hamburger, 1 small Apple Juice, 1 Coke, 1 French Fries and 2 onion Rings, I need a way to detect that there is only one combo in the mix and add the other products at base price. If there are multiple combo combinations, I'm looking (ideally for an sql query) that can prioritize combo combinations by largest savings. One idea I've come up with to solve problem two is to add and attribute to PRODUCT COMPONENT flaggin the main product for the combo (i.e. hamburger). Then when running the pricing process, query what products in the order are main products in a "package", relating the query to the discount given by the PRICE COMPONENT table and ordering by that value (descending), and in that order of packages check to see if you can create a "package" with the remaining non-main products with a query and loop the process until there are no more main products or there are no more non-main products in the remainder.


title: Moving from a CVCS to a DVCS in a big company, what is the right way to do it?

text: **Major Edit: Added more info about how the devs are setup and how a DVCS would help, so you don't have to second guess the DVCS (but you are still welcome to do it =P).** I just started a new job and I'm currently at the process of trying to introduce a DVCS (mercurial, but the actual DVCS is not really a matter of discussion at this point, it could also be git) to the company (big, multinational). So far I've gotten nothing but positive attention, even at managerial and directive level, but I want to make sure I'm not at all disruptive to the organization or anyone's jobs. **The way the developers are setup is in a team room, so there's a lot of communication going on. There is also an integrator, that communicates on a daily basis two or three times with the team leader. Also, there are more dev teams on other parts of the world, maybe 20 offices in 6 or 7 countries.** Company culture is open and there would be no problem pilot testing the tool (thanks for the answer below, already +1d)... but **the real question is** (in capital letters): **HOW DO YOU CONVINCE MANAGEMENT _AROUND ALL THE OFFICES OVER THE WORLD_ THAT ITS A SANE THING TO DO AND WILL ACTUALLY BRING HAPPINESS AND PRODUCTIVITY TO DEVELOPERS?** (say pilot testing and showing it works is just one part of the answer). Elaborating on the context... Does it make sense to make the switch?, yes (note: current SCM is Perforce). I've witnessed several sources of frustration classic to centralized source control management, including:   * People accidentally breaking other's builds or stepping on each others' toes while submitting code revisions.  **This is not often as the responsible must wear a pink hat (hilarious stuff) until the build is fixed, but the hat is still there, and when builds get broken it affects the other offices around the world.** **DVCS to the rescue** : Builds are now broken in a single office, people lose the fear to use version control and can actually second-guess themselves after or check with a peer by sharing their changes easier and not necessarily with the rest of the group.   * Unnecessary bureaucracy when it comes to granting access (e.g. looks like everyone is granted access to most of the code). **There is a dedicated group of admins who take 1 to 3 days to grant access to the code, meanwhile other devs must ask their peers for the code just to look at it... but AFAIK, the often wait instead.** **DVCS to the rescue:** Administration does not have to be centralized on a little group of overwhealmed people, new employees get the code from the project's responsible (1st level) or a peer with repository access (2nd level) who could even review their code and submit it along with his/her changes.   * Complaints with regards to slowness due to network latency. **Not that directly, but sometimes a) The perforce server is down, b) Internet is down, c) Internet or perforce server is slow. Yes, not that often, but it is annoying enough to kick you off your train of thought sometimes.** **DVCS to the rescue** : When using the DVCS you obviously don't need a network connection. Worst case scenario?, share your changes over LAN or sneakernet (with patch queues).   * Trouble when trying to collaborate with external providers that do not necessarily belong to the organization. **This happens often enough and security is a concern here AFAIK, and clients suffer from the access bureaucracy**. **DVCS to the rescue** : So granting access to a subrepo here would be the ideal solution here... also, clients themselves could use version control among themselves without needing to setup their own server and they would be able to integrate better to the internal workflow as currently Perforce access access to the local network, and thus more bureaucracy which is not necessarily security here, as external collaborators still have access to thumbdrives and email. Actual security would be having externals work in situ... in a dungeon or something, and grope them à la TSA on their way out to make sure they are not getting the code out.   * Workaround to integrate modules from other repositories. Requires additional maintenance/effort from the developers. * _These guys actually wrote themselves (I think) a plugin to make perforce fetch files from other repositories in other parts *_ **DVCS to the rescue** : Their solution looks a lot like the mercurial subrepo feature, wich uses a file (.hgsub) to indicate what code goes where, but they have to maintain the other repositories' states in the same file (which is done separately and automatically by mercurial in the .hgsubstate file).   * Working with the source code requires to mark files for edit in advance. This adds an annoying extra step IMHO. **If you don't do this the file will be in read only mode and you will not be able to edit it on your IDE, also, this IMHO makes the local copy prone to low integrity. This trait of perforce makes me think there was a lazy developer that didn't want to make the client check the files against the repo before versioning the changes. It also makes me think/personify Perforce as an idiot paranoid that says** _**"DONT CHANGE THE FILES WITHOUT TELLING ME OR THE SQUIRRELS WILL COME AND EAT ME!!!"_**.  **DVCS to the rescue** : Well... I guess any other SCM software knows there are no carnivore squirrels.   * Little project integrity in developers' machines (see previous point; its harder to add changes without previously indicating them to Perforce). **You don't need a DVCS for this... but if you make changes locally and for some reason forgot to add them, you are going to have a hard time detecting it**. Once you detect it there is a two step command line instruction thing I saw somewhere to detect changes you did without telling Perforce. Given that context **what would you say is the best way to... ?** :   1. Know/demonstrate if the migration would actually benefit the employees and the company.   2. Ease the embracement of change, or at least make it look like its worth the effort   3. Not complicate others' jobs.   4. Convince management worldwide.   5. Avoid making the integrator's job a royal pain. My second question (and focusing on the last point) I've always been a DVCS evangelist mainly because it eases the work and collaboration between developers... but up to this point I've never been faced with having to consider the integrators' perspective (the one in charge of coordinating teams' source code, creating and releasing the builds... from across the globe) who at some point might have to face two SCM sources or at least the migration itself. Then, **how can the migration process affect integrators the least?**.


title: Develop secureness first or as a later step?

text: The question Do you actively think about security when coding? asks about security mindset while programming. Obviously, a developer does need to think about security while coding -- SQL injection, password security, etc. However, as far as the real, fully-formed security, especially the tricky problems that may not be immediately obvious, should I be concerned with tackling these throughout the development process, or should it be a step of its own in later development? I was listening to a podcast on Security Now and they mentioned about how a lot of the of the security problems found in Flash were because when Flash was first developed it wasn't built with security in mind (because it didn't need to) -- therefore Flash has major security flaws at its core. I know that no one would want to actively disagree with "think security first" as a best practice, but many companies do not follow best practices. **So, what is the correct approach to balance between needing to get the product done and developing it securely?**


title: Should my small software library avoid using other libraries?

text: I've just released a small Java library that offers only a few classes and methods. Since I built the project with Maven, I immediately used several third-party libraries to achieve my goals, specifically:   * **commons-lang3** (for some general Java stuff)   * **slf4j-api** (for logging)   * **commons-io** (for a tiny bit of file stuff - literally reading a file once, I think) I don't want my library to appear bloated in the eyes of others. Should I be trying to remove my reliance on these libraries to minimise my footprint? Any advice on what types of libraries would be best to avoid when considering using more in the future?


title: In MVC, can/should basic data retrieval from the Model be done in the View?

text:
Given the concept of _'skinny controllers, fat models'_ and the general acceptance that Views can directly call on Models when requiring data for output, should one consider handling the 'get and display' parts of requests within the Views and not the Controller? For example (attempted to keep code fairly generic): **Controller**               <?php          class Invoice extends Base_Controller {              /**          * Get all the invoices for this month          */              public function current_month() {                  // as there's no user input let's keep the controller very skinny,             // DON'T get data from the Model here, just load the view                  $this->load->view('invoice/current_month');              }          }      **View**               <?php          // directly retrieve current month invoices here          $invoices = $this->invoice_model->get_current_month();          // get some other display-only data, e.g. a list of users for a separate list somewhere on the page          $users = $this->user_model->get_users();          ?>
This month's invoices

     <?php foreach ($invoices as $invoice) { ?>
<?php echo $invoice['ref']; ?>
          <?php } ?>
      To me, this makes at least some sense in the cases where a request is essentially just a View. Why should the Controller have to collect and pass on the data to the View when it can just retrieve it itself? This leaves the Controller open for purely 'Application level' processing (e.g. handling GET/POST requests, managing access rights and permissions etc.) as well as keeping the Models reusable and all the other good stuff. If this example was extended to allow a user to filter the results, the Controller would just handle the POST from the form and pass the filters to the View, which would then request the data again, this time with the filters. Is this a valid approach to developing an MVC application? Or am I overlooking an important part of the role a Controller should play?


title: How to move ahead in Project/Product Management after 3 yrs of Programming Experience?

text: For being a better programmer there are ways to get started like:   1. Get some open source project and start contributing to it.   2. Solve some `Project Euler` or `Yodacode` Excercise. But if someone wants to move in the direction of `Project/Product Management` then in what direction he/she should move and what available options are out there to get started in that direction. Background: I mid level Programmer with 3 yrs of Programming Experience and I want to get started in `Project Management/Product Management` Role but my resume shows programming experience and so my question is how to break into Project/Product Management line with 3 yrs of Programming Experience. Do we have similar options available for `Project/Product Management` as we have for Programming like one's mentioned above ? _I know it's`chicken and egg` situation but what is the best way to get out of it ?_


title: Liskov principle: violation by type-hinting

text: According to the Liskov principle, a construction like the one below is invalid, as it strengthens a pre-condition. I know the example is pointless/nonsense, but when I last asked a question like this, and used a more elaborate code sample, it seemed to distract people too much from the actual question.               //Data models     abstract class Argument     {         protected $value = null;         public function getValue()         {             return $this->value;         }         abstract public function setValue($val);     }     class Numeric extends Argument     {         public function setValue($val)         {             $this->value = $val + 0;//coerce to number             return $this;         }     }     //used here:     abstract class Output     {         public function printValue(Argument $arg)         {             echo $this->format($arg);             return $this;         }         abstract public function format(Argument $arg);     }     class OutputNumeric extends Output     {         public function format(Numeric $arg)//<-- VIOLATION!         {             $format = is_float($arg->getValue()) ? '%.3f' : '%d';             return sprintf($format, $arg->getValue());         }     }      Why would this kind of _"violation"_ be considered harmful? So much so that some languages, like the one I used in this example (PHP), don't even allow this? I'm not allowed to strengthen the type-hint of an abstract method but, by overriding the `printValue` method, I _am_ allowed to write:               class OutputNumeric extends Output     {         final public function printValue(Numeric $arg)         {             echo $this->format($arg);         }         public function format(Argument $arg)         {             $format = is_float($arg->getValue()) ? '%.3f' : '%d';             return sprintf($format, $arg->getValue());         }     }      But this would imply repeating myself for each and every child of `Output`, and makes my objects harder to reuse. I understand why the Liskov principle exists, don't get me wrong, but I find it somewhat difficult to fathom why the signature of an _abstract_ method in an _abstract_ class has to be adhered to so much stricter than a non-abstract method. Why I'm not allowed to hind at a child class, in a child class? The way I see it, the child class `OutputNumeric` is a specific use-case of `Output`, and thus might need a specific instance of `Argument`, namely `Numeric`. Is it really so wrong of me to write code like this, when I _am_ allowed to write this:               abstract class Output     {         public function printValue(Argument $arg)         {             echo $this->format($arg);         }         public function(Argument $arg)         {             throw new RuntimeException(__METHOD__. ' Has to be overridden by child class');         }     }     class OutputNumeric extends Output     {         final public function format(Numeric $arg)         {             $format = is_float($arg->getValue()) ? '%.3f' : '%d';             return sprintf($format, $arg->getValue());         }     }      This sort of acchieves the same thing, but it's just hacky and, to my eye, horrid code...


Generally speaking, is it better to make all the functional parts or get UI working first - or a mix of the two? Assuming you're working on something large, is it generally accepted practice to get all the functional data harvesting blobs working before any UI, get all the UI working one piece at a time as you go, or something in the middle? We all know to break work down in to manageable pieces, but the question is ultimately whether UI is included in manageable pieces I suppose. For the case of the example, consider a GUI application with one root window, but over a dozen tabs in various docks to separate different data components. Each individual tab has a relatively complex set of moving parts behind it from a functional units perspective. The example application in this particular question is here with the accompanying blog and the original commercial product.


title: How to explain why design choices are good?

text: As I've become a better developer, I find that much of my design skill comes more from intuition than mechanical analysis. This is great. It lets me read code and get a feel for it quicker. It lets me translate designs between languages and abstractions much easier. And it let's me get stuff done faster. The downside is that I find it harder to explain to teammates (and worse, management) why a particular design is advantageous; especially teammates that are behind the times on best practices. "This design is more testable!" or "You should favor composition over inheritance." go right over their heads, and lead into the rabbit hole of me trying to clue everyone in to the last decade of software engineering advances. I'll get better at it with practice of course, but in the mean time it involves a lot of wasted time and/or bad design (that will lead to wasted time fixing it later). How can I better explain why a certain design is superior, when the benefits aren't completely obvious to the audience?


title: Is it possible to keep only one Database for both web and desktop applications?

text: I'm experiencing a trouble with my business model, let me explain better. I'm developing a software for 1 year and few months, it's for the food industry, more exactly a software to: _Delivery, Take Way, Table Reservation, POS, Accounts Payable and Receivable, Prints(receipt), Kitchen Monitors Orders, Customers Orders Control and Fiscal Area._ Well, I had separated the software mainly in two areas, one is web area and the other is desktop area (Used by Admins only) and local installed. 1 - Web Area (Basically do the follow:)   * Show Catalog with the products   * Customers Make Orders   * Customers Pay for the Orders   * etc ... as mentioned above 2 - Desktop Area   * Manage Orders   * Manage Customers   * Manage Suppliers   * Manage Accounts Payable and Receivable   * etc ... as mentioned above The web area is hosted in an online web server (scripts and database are online). The Desktop area is hosted locally in a Linux machine with a local database and local scripts files. My question is: Is it possible to keep **only one Database** for both applications? If YES, please what is the best approach? ## Follow my technical specification environment _Database: Actually I have two databases working and I would love to keep only one._ Operating System: Linux (Kernel 2.6.X and above) or Windows (XP and above) For the Web Area   * Apache, PHP, Python, Java Script, Shell Script and MySQL. For the Desktop Area:   * PHP-GTK2, Apache, PHP, MySQL and Shell Script. * * * ## Addtional Information about the system [EDITED] The main purposes to have a Desktop environment is:   1. I need to print and give out Tax Coupon on each new order.    2. I have the drawer.    3. I have a serial reader (Bar code).    4. I have a terminal to query for information.    5. and few other stuffs that is so hard if not impossible to do in the web environment. **Desktop relational schema: 104 tables. Web relational schema: 42 tables.**   1. Permissions is assigned based on: Deny all by default, and assigns as needed.    2. (Validation / Sanitization) has already been done in the web application.   3. Until now performance is not a problem, since every fiscal year part of my database will be archived. (Also customer, suppliers and all related data about them will be archived after 3 years of inactivity).  My real problem is I have 2 environments today and I would love to have only 1. Then "merge" the both worlds into one is an option, but not sure about. I would love to read here a lot of ideas about this matter. **Observation about the process:** Today it is in operation and it works fine, but I feel like waste time in some process. Take a look in the scenario:   1. The order is made in the internet, then stored in my Web database.   2. The "order" is sent to the kitchen and prepared.   3. Print a receipt (Tax Coupon), put it with the order and delivery to the customer.   4. A Tax Coupon is generated by my Desktop Environment and it need a call to the orders table, but it is not the Web Order Table but a Desktop Order Table. _In few words I need to generate again the order to fill up the Tax Coupon. The same happen to Customer Register, Supplier Register and few other stuffs._ I hope this information turn my question more readable. Thanks Again!


title: Will hand-written assembly disappear?

text: Last week I was wondering, with compilers getting better and better at optimizing, will there be a point when there is no need for hand written assembly? Are there still specialized fields where the compilers aren't smart enough to produce code that rivals hand-written assembly?


title: How can Scrum be adapted to allow for support obligations?

text: Scrum's great for new development and proactive tasks. But I've never been sure how to use it when the department's obligations also include analyzing/answering/fixing customer support questions, which come in unpredictably, typically have high enough priority to interrupt what we planned on doing, and whose complexity ranges from trivial to major. The books I've seen so far don't seem to cover that situation. So how are other folks handling it?


title: Is where a link goes part of a view use case?

text: Say I got a minimal use case such as "view home page" or "view banner ad". Should it be included or exluded in the use case actually following the link? What I mean is that whether it belongs to the use case "view page 1" if a report is that "The link from page 1 to page 2 is not working" in the common case of a "link not working".


title: What is the value of OOP in ASP.NET MVC?

text: As a C++ developer from the 90s during the great OOP wars, I put high value to OOP as a basis for hiring new C# developers into the company. However, there are plenty of frameworks today like ASP.NET MVC that handles most of the OOP heavy lifting. Programmers without deep knowledge of OOP can just as easily follow the paradigm and still be able to complete their projects. OOP may not be as compelling as it was before for us application developers, especially with a framework like MVC. I can see a few instance where OOP will be really handy, like for example developing a workflow type of a project. Or those with state-machine requirements. But really, most projects that really come by (at least to us here anyway) are just CRUD functionalities. Below is my list when hiring. Is it fair to have OOP there as the number one item?   1. OOP and Design   2. Server side programming: C#, ASP.NET MVC and EF   3. Client side programming: JQuery, CSS, HTML, etc.   4. Database design


title: HTML5 canvas performance and performance monitoring tool for Javascript

text: I have made a program in Javascript and HTML5 canvas and I am wondering what happens when you draw a shape on a certain location of canvas then draw another shape on top of that same object. Does it consume more memory because I am drawing new object on top of each others? (Currently, rendering process of my program is not that fast, I am assuming it is due to I am drawing new object on top of old object, is that right?). Also, I want to know what kind of performance monitoring tools available out there for Javascript programs. I want to figure out which fragment of my program consumes the most memory so I can optimise that particular process to be faster. Thank you.


title: Is there an analogue to "FizzBuzz" for choosing clients?

text: This is for the freelancers. In my past life as a full-time employee, I was involved in hiring and interviewed a good number of developers. I learned that it was much more valuable to see a developer work through a problem, however small, than to talk about experience, etc. Now I'm working as a freelancer/consultant. One of the nicer things is the freedom to choose what I want to work on. But now, a few years in, I've learned (the hard way) that some clients are not worth the money. They can be fickle, unreasonable, demanding, and difficult to work with in a very demoralizing way. So I've been wondering: is there a better way to "interview" clients? Obviously any method would have to be subtle, as the client probably isn't expecting to be tested. But is there an analogue to "FizzBuzz" that will tell me whether I should sign on, or back away slowly?


title: Can we illustrate a CPU pipeline with a UML sequence diagram?

text: I study multicore pipelining and the diagrams are not UML sequence diagrams for instance ![enter image description here](http://i.stack.imgur.com/WQrP1.png) Why not remake this diagram like an UML sequence diagram, would not that be more clear so that we can see both how time progresses as well as the data paths since I do not think it is clear distinction between data path and time? In UML time goes downward and the data path goes right and left. Can you comment or answer why pipelining generally is not illustrated with UML?


title: How does one meaningfully measure maintainability?

text: Context: I'm an enterprise developer in an all-MS shop. Can anyone recommend a good way of **objectively measuring maintainability** of a piece of code or an application? **Why maintainability** : I'm tired of "quality" metrics in my group revolving only around number of bugs and code coverage. Both metrics are easy to game, especially when you're not measuring maintainability. Shortsightedness and deadlines result in huge amounts of technical debt that never really get addressed. **Why the ability to measure objectively** : I work in a big enterprise group. If you can't objectively measure it, you can't hold people accountable for it or make them get better at it. Subjective measurements either don't happen or don't happen consistently. I'm looking at VS2010 code metrics, but I'm wondering if anyone has any other recommendations.


title: Interesting or unique types in programming languages?

text: We have all seen integer, floating point, string, and the occasional decimal type. What are some of the most strange or unique or useful types you have encountered, useful or not?


title: Code reviewing in the presence of strong type inference and basic editors

text: I’m curious to know how folks deal with comparative code reviews (version x against y of a file) in the presence of strong type inference, that is when ‘var’ (in C#) or ‘auto’ (in C++ 0x) is used in place of the older more verbose (explicit) type declaration. When IntelliSense is available one can just float the mouse over the keyword to determine (if necessary) the inferred type – but what do folks do when viewing such sources in Notepad or Code Collaborator etc. Of course strong type inference predates C# and C++ by decades, so how do folks in other languages that have had the feature for years cope? I’m inclined to think that the right hand side of the assignment expression is where most bugs are to be found.


title: Ambiguous program requirements

text: it seems that most of the programming exercises that I am currently doing, are a little bit ambiguous when it comes to specifying what should I do. When programmers work with clients, are the clients ambiguous as well about what they want and I should learn to guess?


title: Is there any place to find real-world usage-style tutorials for programming languages?

text: Let's face it. When you want to learn something completely new, be it mathematics or foreign languages, it's easiest to learn when you get real world scenarios in front of you, with theory applied. For example, trigonometry can be extremely interesting when applied to creation of 2D platform games. Norwegian can be really interesting to learn if you live in Norway. When I try to look at a new programming language, I always find these steps the hardest:   1. What tools do I need to compile and how do I do it   2. Introduction-step: Why is this programming language so cool? Where and how is it used? (The step I am looking for, real-world scenarios) The rest, deep diving into the language, pure theory and such, is often much easier if you have completed step 1 and 2. Because now you know what it's all about, and can just read the specification when you need to. What I ask is, do you have any recommendations for places I can find such material for programming languages? Be it websites or companies selling books in this style, I'm interested. Also, I am interested in all languages. (If I had found a "real-world usage" explained for even INTERCAL, I would be interested). In some other thread here, I found a book called "Seven Languages in Seven Weeks". This is kind of what I am looking for, but I believe there must be "more like this".


title: Small refactorings on a poor codebase?

text: In the last two years I have worked with a poorly written codebase of nearly 40K lines of code. Over that time I have made many small refactorings to improve it and made some bigger, as time permits. Unfortunately, I still view the codebase as poorly written. What's your experience? Do you think many small fixes can take me somewhere, or I have to stop and allocate a big chunk of time to fix things (of course, management won't be happy if I do this while we're working on the current "very important" new feature).


title: What's the best Open Source code you've ever seen?

text: Part of the value of Open Source is to provide great example code to people getting started with a new platform or language. What's the best Open Source code you've encountered, and why do you like your choice? Any language will do, but I'm particularly interested in the best examples of Objective-C you can point out. Obviously this is an open-ended question, so I'll leave the question open for a while and see what kinds of answers we get. Thanks! EDIT: For "best" I was thinking of code that follows the idioms in the given language or platform, as well as including the parts that make code "professional" - good documentation, a testing suite, etc. Code that is concise, but not overly clever is preferred to very terse or chatty code.


title: What are you thoughts on GWT?

text: Since I'm learning Java in this period and I just finished with the tutorials I think I'm ready to start contributing to a project (since I know from experience this is the best way to really learn). I've seen GWT, looks interesting so I thought I should give it a try. I'm thinking however, since GWT deploys Java applications in JavaScript why should I learn GWT when I could learn the actual thing instead (this being JavaScript). My question: is it worth it? Wouldn't someone be better of learning JavaScript if they want to build JS applications, instead of using Java and GWT? I realize that it might be easier to build certain things with GWT but in the end is it worth it? Thanks.


title: What is a class library?

text: I'm working on a lawsuit and I need a definition of a 'class library' that I can reference. Every book and all the documentation I can find seems to assume the reader already knows what a library is. Even the wikipedia entry on 'Library (computing)' is low on references. And the references it does have are from the 80s or earlier. So, in the context of C#, what is a class library? (with references) I have been getting a decent number of definitions from 'Design Patterns: Elements of Reusable Object-Oriented Software' but it also assumes the reader knows what a library is.


title: How to be a zero-bug programmer?

text: My boss has always told me that a good programmer should be able to ensure that the code he or she changes is reliable, correct, and thoroughly self- verified; that you should completely understand all the results and impacts your changes will cause. I have tried my best to be this kind of programmer—by testing again and again—but bugs are still there. How can I be a zero-bug programmer and know what every character of my code will cause and affect?


title: Coding to interfaces

text: I understand why it is a good idea to code to an interface rather than to a concrete class. I find it hard to implement though as other methods generally need to use properties of the given object. Have I got the wrong end of the stick?


title: Programming paradigms and the maintenance developer

text: I was reading, Facts and Fallacies of Software Engineering, which has a section of maintenance. Since, I'm have been a maintenance developer for years now, I was very interesting facts presented. Here's three.   * Fact 41: Maintenance typically consumes 40 to 80 percent (average, 60 percent) of software costs. Therefore, it is probably the most important life cycle phase of software.   * Fact 42: Enhancement is responsible for roughly 60 percent of software maintenance costs. Error correction is roughly 17 percent. Therefore, software maintenance is largely about adding new capability to old software, not fixing it.   * Fact 45: Better software engineering development leads to more maintenance, not less. This one was counter-intuitive, turns out that good software has more maintenance, because it's easy to change. Hence, it stays in use longer, leading to, yes, more changes. Which paradigm (such as functional, object-oriented, procedural) has the best maintainability, and is there any research to back this up?


title: Methodologies commonly used for embedded software development?

text: I am doing research on software development methodologies are commonly used for embedded software development, and how they differ from their non-embedded software development counterparts. I am having a hard time finding good resources on this topic so if you can recommend me some papers, websites or other material, I will be very grateful.


title: Given n distinct keys, how many different 2-3/Red-black trees can be constructed?

text: ## Memory refresher/My understanding: A 2-3 tree is a balanced search tree that allows two types of nodes.   1. 2-node: Normal node with two children.      * LChild < Parent and RChild > Parent   2. 3-node: Node with two parents and three children.      * Parent1 < Parent2     * LChild < Parent1, Parent1 < MChild < Parent2, RChild >Parent2 A 2-3 tree is always balanced, and grows when the root raises the height of the tree by one. http://en.wikipedia.org/wiki/2%E2%80%933_tree My question is then as follows, **given n distinct keys, how many different 2-3 trees can one construct?** My math skills are poor, so if anyone knows how I should "math" in order to approach an answer, then that would be awesome! :)


title: parsing terminology: comments+whitespaces vs actual code

text: In languages like c/c++ spacing and comments are ignored and only actual code gets into compiler. I'm interested if there is accepted way of naming these two things?   * comments & spacing   * everything else (actual code) Referring to comments & spacing as "comments & spacing" is quite annoying. Any ideas?


title: Are there mainstream general-purpose non-Turing complete languages available today?

text: Non-Turing complete languages offer a great advantage over Turing-complete languages as they are much more analyzable and, thus, offer much broader optimization possibilities. Yet they are barely used and Turing-completeness is actually sold as a good feature. Are there any mainstream non-Turing-complete languages available today that are made for general-purpose programming?


title: Implementing the Interface Segregation Principle

text: Does this `IConvertible` interface satisfy the Interface Segregation Principle (ie. the "I" in SOLID)? Here is the definition:               public interface IConvertible     {         TypeCode GetTypeCode();          bool ToBoolean(IFormatProvider provider);         byte ToByte(IFormatProvider provider);         char ToChar(IFormatProvider provider);         DateTime ToDateTime(IFormatProvider provider);         decimal ToDecimal(IFormatProvider provider);         short ToInt16(IFormatProvider provider);         int ToInt32(IFormatProvider provider);         long ToInt64(IFormatProvider provider);         sbyte ToSByte(IFormatProvider provider);         float ToSingle(IFormatProvider provider);         string ToString(IFormatProvider provider);         object ToType(Type conversionType, IFormatProvider provider);         ushort ToUInt16(IFormatProvider provider);         uint ToUInt32(IFormatProvider provider);         ulong ToUInt64(IFormatProvider provider);     }      So if I would like to have a class which will implements this `IConvertible` interface the I have to implement all of those methods, right? Or if I don't implement all of them, then I have to at least make an empty method or throw an Exception, right?. In my opinion, the better way is to make more interface with fewer methods, for example:               public interface IConvertibleInt     {             short ToInt16(IFormatProvider provider);             int ToInt32(IFormatProvider provider);             long ToInt64(IFormatProvider provider);     }      Or even:               public interface IConvertibleInt16     {             short ToInt16(IFormatProvider provider);     }          public interface IConvertibleInt32     {                         int ToInt32(IFormatProvider provider);     }          public interface IConvertibleInt64     {             long ToInt64(IFormatProvider provider);     }      Is my reasoning correct?


title: A good way of creating XML files at run time

text: Please stare at this structure for a second :) ![enter image description here](http://i.stack.imgur.com/uZaWg.png) I should create such a thing all at run time. What are the values that we pass in at run time? the string values you see after "#" are passed in so for example AnimalBio, ClinBio, HumanGenome,etc... So I am thinking of declaring some methods like               void AddDeclaration(string str) ;     void AddSubClass(string parent, string child);      such that when I call them they will create those XML-ish tags for me with the values I pass in such as HumnaBio. These are around 15000 items that I am gonna add... What is the best approach that you would suggest for doing this? Do you think using XMLDocument class is the best way of doing it? or do you think I should go with StringBuilder class and add these as strings, or other ways of doing it? Thanks.


title: What is a license and how may I use code under a license?

text: (Let me edit this question to try to better get across what I am asking.) I don't understand what a license is and how I may "use" it. From the little that I do understand, there are two situations:   1. One writes a program/source code and _puts_ a license on it. The license says how other people may (are allowed) to use the program/source code.   2. I find a program/source code and would like to use it. The program comes with a license and the license tells me how I am allowed to use the program/source code. It is this second point that I am confused about. I have no experience with "using" licenses. I see some previous questions about licenses being closed, so just to make it clear: I am not asking for legal advice. I just want to make sure that I am doing it "right". I just want to know how one can use a license. To given a concrete real world example of what I am asking: I want to use the library CryptoJS 3.1 to make a web page (to put online for the whole world to see) using this library, but I am uncertain about how I may do this. From what I understand: according to the page about the library, the the library is offered under a license called the New BSD License. But I don't understand what this license is telling me about how I am allowed to use the source code. Specifically, I would appreciate if someone could explain (as if I was a 12 year old): _What do I need to do to use this library on my web page?_ For example: Do I need to give tribute with a link or something like that? One specific thing that is confusing me is that on the page of CryptoJS 3.1 it actually doesn't tell me what the license is verbatim. It says that the license is the New BSD license. There is a link to this page. And one that page is a _template_ for a license. So how do I make sense of this? In summary: I would like to use CryptoJS 3.1, but I don't know how I may do that. * * * (I have figured out the export regulations requirement, so that isn't an issue for me.)


title: For csv database extracts, how do map keys not create a dependency?

text: A lot of my work is done with .csv extracts (reports) from databases. As I have been programming in Clojure, I've received comments that relying on vector indexes creates dependencies. I understand why, and concur. I am rewriting one of my programs to take advantage of the fact that each report's first row contain the column headings, and I could go after each row of data I want by map key. I am rewriting some code to zipmap the headings made into map keys and one row of data (at a time) so I can access the data I want. Here is an example.               (def bene-csv-inp  (fetch-csv-data "benetrak_roster.csv"))     (def bene-csv-cols (first bene-csv-inp))     (def bene-csv-data (rest bene-csv-inp))     (def zm1 (zipmap           (map #(keyword %1) bene-csv-cols)                              (first bene-csv-data)))     (zm1 :EmploymentStartDate)     "21-Jun-82"      Does a higher level of extraction exist, and if so, what is it that would allow my code not to have to have to hard-code `:EmploymentStartDate` ? If my code has to know these keys, then how is that also not a dependency like an index? Personally, I like going after the data with map keys, because it's less confusing and more informative than indexes. However, I believe I still have a dependency. Thanks.


title: S.O.L.I.D., avoiding anemic domains, dependency injection?

text: Although this could be a programming language agnostic question, I'm interested in answers targeting the .NET ecosystem. This is the scenario: suppose we need to develop a simple console application for the public administration. The application is about vehicle tax. They (only) have the following business rules: 1.a) If the vehicle is a car and the last time its owner paid the tax was 30 days ago then the owner has to pay again. 1.b) If the vehicle is a motorbike and the last time its owner paid the tax was 60 days ago then the owner has to pay again. In other words, if you have a car you have to pay every 30 days or if you have a motorbike you have to pay every 60 days. For each vehicle in the system, the application should test those rules and print those vehicles (plate number and owner information) that don't satisfy them. What I want is: 2.a) Conform to the S.O.L.I.D. principles (especially Open/closed principle). What I don't want is (I think): 2.b) An anemic domain, therefore business logic should go inside business entities. I started with this:               public class Person     // You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.     {         public string Name { get; set; }              public string Surname { get; set; }     }          public abstract class Vehicle     {         public string PlateNumber { get; set; }              public Person Owner { get; set; }              public DateTime LastPaidTime { get; set; }              public abstract bool HasToPay();     }          public class Car : Vehicle     {         public override bool HasToPay()         {             return (DateTime.Today - this.LastPaidTime).TotalDays >= 30;         }     }          public class Motorbike : Vehicle     {         public override bool HasToPay()         {             return (DateTime.Today - this.LastPaidTime).TotalDays >= 60;         }     }          public class PublicAdministration     {         public IEnumerable<Vehicle> GetVehiclesThatHaveToPay()         {             return this.GetAllVehicles().Where(vehicle => vehicle.HasToPay());         }              private IEnumerable<Vehicle> GetAllVehicles()         {             throw new NotImplementedException();         }     }          class Program     {         static void Main(string[] args)         {             PublicAdministration administration = new PublicAdministration();             foreach (var vehicle in administration.GetVehiclesThatHaveToPay())             {                 Console.WriteLine("Plate number: {0}\tOwner: {1}, {2}", vehicle.PlateNumber, vehicle.Owner.Surname, vehicle.Owner.Name);             }         }     }      2.a: The Open/closed principle is guaranteed; if they want bicycle tax you just inherit from Vehicle, then you override the HasToPay method and you're done. Open/closed principle satisfied through simple inheritance. The "problems" are: 3.a) Why a vehicle has to know if it has to pay? Isn't a PublicAdministration concern? If public administration rules for car tax change, why Car has to change? I think you should be asking: "then why you put a HasToPay method inside Vehicle?", and the answer is: because I don't want to test for the vehicle type (typeof) inside PublicAdministration. Do you see a better alternative? 3.b) Maybe tax payment is a vehicle concern after all, or maybe my initial Person-Vehicle-Car-Motorbike-PublicAdministration design is just plain wrong, or I need a philosopher and a better business analyst. A solution could be: move the HasToPay method to another class, we can call it TaxPayment. Then we create two TaxPayment derived classes; CarTaxPayment and MotorbikeTaxPayment. Then we add an abstract Payment property (of type TaxPayment) to the Vehicle class and we return the right TaxPayment instance from Car and Motorbike classes:               public abstract class TaxPayment     {         public abstract bool HasToPay();     }          public class CarTaxPayment : TaxPayment     {         public override bool HasToPay()         {             return (DateTime.Today - this.LastPaidTime).TotalDays >= 30;         }     }          public class MotorbikeTaxPayment : TaxPayment     {         public override bool HasToPay()         {             return (DateTime.Today - this.LastPaidTime).TotalDays >= 60;         }     }          public abstract class Vehicle     {         public string PlateNumber { get; set; }              public Person Owner { get; set; }              public DateTime LastPaidTime { get; set; }              public abstract TaxPayment Payment { get; }     }          public class Car : Vehicle     {         private CarTaxPayment payment = new CarTaxPayment();         public override TaxPayment Payment         {             get { return this.payment; }         }     }          public class Motorbike : Vehicle     {         private MotorbikeTaxPayment payment = new MotorbikeTaxPayment();         public override TaxPayment Payment         {             get { return this.payment; }         }     }      And we invoke the old process this way:                   public IEnumerable<Vehicle> GetVehiclesThatHaveToPay()         {             return this.GetAllVehicles().Where(vehicle => vehicle.Payment.HasToPay());         }      But now this code won't compile because there's no LastPaidTime member inside CarTaxPayment/MotorbikeTaxPayment/TaxPayment. I'm starting to see CarTaxPayment and MotorbikeTaxPayment more like "algorithm implementations" rather than business entities. Somehow now those "algorithms" need the LastPaidTime value. Sure, we can pass the value to the constructor of TaxPayment, but that would violate vehicle encapsulation, or responsibilities, or whatever those OOP evangelists call it, wouldn't it? 3.c) Suppose we already have an Entity Framework ObjectContext (which uses our domain objects; Person, Vehicle, Car, Motorbike, PublicAdministration). How would you do to get an ObjectContext reference from PublicAdministration.GetAllVehicles method and therefore implement the funcionality? 3.d) If we also need the same ObjectContext reference for CarTaxPayment.HasToPay but a different one for MotorbikeTaxPayment.HasToPay, who is in charge of "injecting" or how would you pass those references to the payment classes? In this case, avoiding an anemic domain (and thus no service objects), don't lead us to disaster? What are your design choices for this simple scenario? Clearly the examples I've shown are "too complex" for an easy task, but at the same time the idea is to adhere to the S.O.L.I.D. principles and prevent anemic domains (of which have been commissioned to destroy).


title: Handling array passed to object at creation

text: When creating my object I pass it an array of a row from my database. (everything in the array we will need, disregarding unnecessary elements at sql query level) When I need to access certain array elements from within my class, I do so like               $this->row['element']      However, As I continue development, I sometimes forget what exactly is in this passed array.(this itself doesn't seem good) I am wondering if their is a professional approach to dealing with this, Or am I the only one who has these "I wonder whats in the array" thoughts. One approach to tackling this could be that when we originally pass the array, in the constructor, we assign each element of the array to its own variable, but is this considered professional practice? Additionally by doing this, we could make those variables constants, in a attempt at immutability. Overall I am trying to adhere to good software craftsmanship. Regards.


I have a web service. Right now, I have passwords stored in plain text in a MySQL table on my server. I know this isn't the best practice, and that is why I am working on it. Why should passwords be encrypted if they are being stored in a secure database? I realize that if someone hacks in to my database they will get everyone's password. But I have other problems if someone gets in my database, for example, deleting data. The scenario I can think of is that you are hacked. You restore a database from a couple of hours ago and everything is well. However, if your passwords are plaintext... The thief has all the passwords and you have to reset them all. Hassle to your users. If the passwords were encrypted, you could just restore to previous database. Is this correct thinking?