Tuesday, January 24, 2012

Strange Facts about Smart MobilePhones

iPhones and Androids and various Blackberry devices are everywhere, and the revolution has just begun.

We never know these facts about smartphones. Just have a look at these....

1. The first camera phone was released in Japan in 2000: the Sharp J-SH04.

2. Porn helped drive popularity, with a phone-cam-enabled up-skirt photo subculture emerging online.

3. Japan and South Korea require phone cameras to make noise when pictures are taken in order to prevent unwanted photography.

4. A recent study by ComScore found that of 234 million wireless subscribers in U.S., 45.5 of them own smart phones.

5. Coda Research Consultancy forecasts that the number of smartphone owners in the U.S. will rise to 194 million by 2015.

6. Smart phones made up 17 percent of cell phones sold worldwide in 2009; that's expected to jump to 38 percent by 2014.

7. Ericsson was the first company to market a device as a "smartphone" in 2000 with the launch of the R380.

8. The first working smartphone was introduced eight years earlier by IBM, which debuted the Simon at COMDEX.

9. Simon had a calendar, address book, world clock, calculator, note pad, e-mail, fax and games, plus a touch-screen keyboard.

10. The Nokia Communicator line in 1996 was one of the first mobile devices built on an open platform.

11. The QUALCOMM pdQ, introduced in 1999 and built on the Palm OS, had full PDA capabilities and a CDMA phone.

12. Salomon Smith Barney deployed 2,500 devices connected to BlackBerry Enterprise Server in 2000.

13. In 2002, the deluge of devices began, including the first HTC smartphone and the Palm Treo.

14. Also in 2002, Sony Ericsson unveiled the P800, with an MP3 player, camera and color touch screen.

15. By 2003, BlackBerry said it had over 10,000 corporate customers on its enterprise smartphone bandwagon.

16. The use of mobile Web grew 110 percent last year in the U.S., according to the Quantcast Mobile Trends report.

17. Still, Quantcast estimates that mobile Web usage only makes up about 1.26 percent of all Web consumption in the U.S.

18. Forrester says mobile accounts for up to 25 percent of e-mail for info workers who use a smart phone at least once a week for work.

19. Microsoft's Steve Ballmer admitted that the computing giant missed a whole generation of smartphone evolution.

20. Microsoft's highly-touted Kin phone was yanked from the market after just six weeks of availability.

21. Enterprise-connected mobile device penetration will grow from 10-15 percent in 2010 to perhaps 80 percent five years from now.

22. A Symantec survey showed just under two-thirds of enterprises have no formal device management policies.

23. Monsanto is supporting its 4,700 smartphone users through the device management solutions from Zenprise.

24. Monsanto's deployment helped reduce outage time for VIP users by 95% and reduced Level 1 support tickets by 34%.

25. Gartner says iPhone and Droid platforms made up 25 percent of smartphone sales worldwide in first quarter of 2010.

26. Increasing consumerization makes management harder; unlike BlackBerry devices, iPhone and Droid are not enterprise-focused.

27. Clothier Patagonia enabled iPhones and Droids in its environments using management tool Good for Enterprise.

28. "People want to use these devices, and they want to use them at work." — Alex Yanez, telecommunications engineer, Patagonia.

29. Gartner expects mobile application downloads to increase tenfold between 2009 and 2013.

30. Compass Intelligence predicts U.S. businesses will spend $11.6 billion on mobile app development by 2012.

Source: BaselineMag

Saturday, January 21, 2012

Android - How to set the wallpaper image

AIM: To set wallpaper from your program

If you have Image path. like /sdcard/image1.jpg

FileInputStream is = new FileInputStream(new File(imagePath));
BufferedInputStream bis = new BufferedInputStream(is);
Bitmap bitmap = BitmapFactory.decodeStream(bis);
Bitmap useThisBitmap = Bitmap.createScaledBitmap(
    bitmap, parent.getWidth(), parent.getHeight(), true);
    System.out.println("Hi I am trying to set wallpaper");
    wallpaperManager = WallpaperManager.getInstance(this);
    wallpaperDrawable = wallpaperManager.getDrawable();
Add this in Manifest file 
<manifest xlmns:android...>
 <uses-permission android:name="android.permission.SET_WALLPAPER" />


Software is all about..........

  1. The most important factor in software work is the quality of the programmers.
  2. The best programmers are up to 28 times better than the worst programmers.
  3. Adding people to a late project makes it later.
  4. The working environment has a profound impact on productivity and quality.
Tools and Techniques
  1. Hype (about tools and technology) is a plague on the house of software.
  2. New tools and techniques cause an initial loss of productivity / quality.
  3. Software developers talk a lot about tools, but seldom use them.
  1. One of the two most common causes of runaway projects is poor estimation.
  2. Software estimation usually occurs at the wrong time.
  3. Software estimation is usually done by the wrong people.
  4. Software estimates are rarely corrected as the project proceeds.
  5. It is not surprising that software estimates are bad. But we live and die by them anyway!
  6. There is a disconnect between software management and their programmers.
  7. The answer to a feasability study is almost always "yes".
  1. Reuse-in-the-small is a solved problem.
  2. Reuse-in-the-large remains a mostly unsolved problem.
  3. Reuse-in-the-large works best in families of related systems.
  4. Reuseable components are three times as hard to build and should be tried out in three different settings.
  5. Modification of reused code is particularly error-prone.
  6. Design pattern reuse is one solution to the problems of code reuse.
  1. One of the two most common causes of runaway projects is unstable requirements.
  2. Requirements errors are the most expensive to fix during production.
  3. Missing requirements are the hardest requirements errors to correct.
  1. Explicit requirements 'explode' as implicit requirements for a solution evolve.
  2. There is seldom one best design solution to a software problem.
  3. Design is a complex, iterative process. Initial design solutions are usually wrong and certainly not optimal.
  1. Designer 'primitives' rarely match programmer 'primitives'.
Error removal
  1. Error removal is the most time-consuming phase of the lifecycle.
  1. Software is usually tested at best to the 55 to 60 percent coverage level.
  2. 100 percent test coverage is still far from enough.
  3. Test tools are essential, but rarely used.
  4. Test automation rarely is. Most testing activities cannot be automated.
  5. Programmer-created, built-in debug code is an important supplement to testing tools.
Reviews and Inspections
  1. Rigorous inspections can remove up to 90 percent of errors before the first test case is run.
  2. Rigorous inspections should not replace testing.
  3. Post-delivery reviews, postmortems, and retrospectives are important and seldom performed.
  4. Reviews are both technical and sociological, and both factors must be accommodated.
  1. Maintenance typically consumes 40 to 80 percent of software costs. It is probably the most important software lifecycle phase.
  2. Enhancements represent roughly 60 percent of maintenance costs.
  3. Maintenance is a solution-- not a problem.
  4. Understanding the existing product is the most difficult maintenance task.
  5. Better methods lead to more maintenance, not less.
  1. Quality is a collection of attributes.
  2. Quality is not user satisfaction, meeting requirements, achieving cost and schedule, or reliability.
  1. There are errors that most programmers tend to make.
  2. Errors tend to cluster.
  3. There is no single best approach to software error removal.
  4. Residual errors will always persist. The goal should be to minimize or eliminate severe errors.
  1. Efficiency stems more from good design than good coding.
  2. High-order language code can be about 90 percent as efficient as comparable assembler code.
  3. There are tradeoffs between optimizing for time and optimizing for space.
  1. Many researchers advocate rather than investigate.
If those are the fifty-five facts, then these are the ten fallacies presented at the end. Fallacies have the ring of truth, but upon closer inspection, turn out to be problematic when applied to a real live software project.
  1. You can't manage what you can't measure.
  2. You can manage quality into a software product.
  3. Programming can and should be egoless.
  4. Tools and techniques: one size fits all.
  5. Software needs more methodologies.
  6. To estimate cost and schedule, first estimate lines of code.
  7. Random test input is a good way to optimize testing.
  8. "Given enough eyeballs, all bugs are shallow".
  9. The way to preduct future maintenance costs and to make product replacement decisions is to look at past cost data.
  10. You teach people how to program by showing them how to write programs. 

Tips for Enjoying the Software Development


The Enjoyable Profession of Software Development

Software development can be a tremendously rewarding, enjoyable career.
Few careers offer comparable opportunities to weave intricate, complex structures that, while virtual, have such a positive impact on the world around them. Few offer the freedom and creativity that software development does, or the very real potential for entrepreneurial riches.
Whether it's building a new peer-to-peer application, control software for a massive power generator, or improving the workflow of the corporate scorecard system, done right this can be a very fulfilling, enjoyable, challenging pursuit.

A Passion for Software Development?

Are you really passionate about software development? Be honest with yourself.
A desire to outshine a teammate isn't passion. Nor is a motivation to impress the boss. Neither is a combination of the two worn as a magic defensive cloak against downsizing spells. These are second-rate, artificial passion substitutes: Mixed into the recipe, they yield sub par results, often leaving a nasty aftertaste of burnout and dissatisfaction.
Instead I'm talking about a bona fide interest and enjoyment of the craft and challenge of software development, even outside of career or job security issues (though it benefits the same). This isn't a job ad demanding that you're "passionate about business reports!", but rather is just a moment for sober reflection on whether you're over-clocking life, or running idle instructions in a tight loop.
If you're like many software developers in the industry today, a feeling of enthusiasm and enjoyment for the pursuit is just a distant memory (often during the happy days of university and your first job). Instead it has become a career, and is just something you do from 9-5 (or more when passion is replaced by sacrifice). Skills have likely stagnated, moving just enough to compete with coworkers, or to avoid obsolescence.
Of course there are those who've never enjoyed this career, and they probably will never enjoy it -- it just isn't their thing. The only advice I can offer to those people is a suggestion that life is too fleeting to spend so much time doing something you don't enjoy.

Software developers who truly love what they are doing are the ones creating the most innovative code. They're the ones with productivity rates multiples of their peers. They're the ones that feel a little guilty getting paid to do something they enjoy so much

The Tips to be a  Productive, Happy Software Developers

1. Be Marketable - Keep Up To Date Skills and Network Contacts

109_0924 Most of us will work for over a dozen different firms over our careers.
We'll leave for better salaries and working conditions. We'll relocate to accommodate a spouse's career. We'll be laid off during corporate mergers and spin-offs, or even when the company goes bankrupt. We'll get turfed out because we're over-skilled, and thus overpaid, relative to the needs of the position. We'll be downsized because we aren't compatible with the new boss' empire building schemes. Maybe we'll get bored of a position and seek out something new.
This is the employment reality of most careers in the 21st century.
To some professionals this represents an exciting journey, and each transition is met with anticipation and enthusiasm. These people feel confident in their abilities, have a network of peers in the industry communicating interesting opportunities, and their skillset is up-to-date and marketable (they have the appropriate laundry list of abilities, credentials and certifications, and upgrade as needed), and while the possibility of their current employer closing shop tomorrow is something they'd prefer not happen, and they probably love the great group of people that they work with, it isn't something that they fear.
To less prepared professionals, however, the idea of losing their cushy job hangs over them like a black cloud. Their lack of apparent opportunities, and the feeling that they couldn't find an equivalent job, is enormously destructive of both motivation and job satisfaction. Paradoxically, job protectionism (such as making one "indispensable" through obscurity, by denigrating coworkers, and so on) often becomes a more likely activity of people in such positions than legitimate contributions.
This is incredibly destructive to morale, not just for the individual in question, but for everyone on their team: Often the malcontent, contagiously demotivated member of the team is the least employable, and it can be debated which condition led to the other.
SUMMARY:  No matter how much you love your current job, you should keep your CV current, and you should always keep up-to-date on industry opportunities. Know what skills are in demand, and try to gain experience in them (even if it means pursuing formal or self-training during your own time), and attain a level of comfort that you could transition to a different opportunity with minimal discomfort.
MANAGER SUMMARY: You should do everything in your power to make your group feel confident in their abilities -- ensure that everyone gets a chance with marketable technologies; encourage the pursuit of desirable certifications; and build skills through internal resources, workshops, and seminars. Unless you're running a sweatshop, this is unlikely to lead to a feared exodus of employees, but instead will empower and motivate your group to more openly contribute, and to demand more of each other.

2. Be The Master of Your Domain

The control we have over our environment can have a tremendous impact on our happiness.
Something as simple as a sporadically malfunctioning key on our keyboard can ruin an entire day, for instance. Similarly, when you're nearing a deadline and your network connection starts flaking out, it can make an enjoyable jog to the finish line a frustrating exercise of physical restraint (in this case restraining yourself from tearing the wiring out of the wall). At least we have optical mice now, eliminating one of the primary causes of environmental control frustration.
Many times our work habits inevitably bring a feeling of "lack of control" into our work lives: By failing to fully read the documentation for our tools, investigating their behaviour, APIs, and nuances, we often create a situation where much of our development is basically crap-shoot trial and error, reacting as things don't work as planned.
I've witnessed development groups, not to mention that I've demonstrated this unsavoury trait myself, unhappily fighting with perceived technology deficiencies (usually as a deadline rapidly approaches), moaning and complaining about what seems to be faults in the language, technology, or platform, forever building workarounds under a fog of uncertainty, when in reality it was actually a fault in the understanding of the same.
More often than not it's simply that they haven't spent the upfront time to understand the language (I remain amazed at the number of C# developers who have no idea what the using keyword is for, or why seemingly out-of-scope file objects are still locking files until some magical, indeterminate time in the future. Or the Delphi developers who needlessly nulled variables at the end of scope in a futile misguided attempt to fight mystery bugs), the technology, or the platform. Their frustration is created out of ignorance, and a small up-front investment would have sped up development, increasing the sense of control that the developers have over their domain.
SUMMARY: The next time something seems mysterious or unknown, take the time to properly investigate it. Classic lack-of-control approaches such as hacked workarounds or "reset the server daily" lead to a feeling of losing control, reducing job satisfaction and adding to the natural daily frustrations. And get your keyboard replaced if it starts malfunctioning.
MANAGER SUMMARY: Identify and investigate "easy-outs" proposed by your development team. While most software has faults, and products and technologies often work differently than we might imagine, many times such excuses are due to a lack of investigation and analysis. Even when things don't work as advertised, which is frequently the case, formally investigating and empirically determining behaviours is vastly superior to each developer endlessly fighting with and then hashing out strategies on a need basis. And make sure your developers have functioning keyboards.

3. Accommodate Your Financial Needs

I've worked in some great positions at the wrong times in my life, sapping my motivation until eventually I moved on. These positions were for great firms, with great working conditions and great coworkers and management, but it couldn't realistically adapt to accommodate my evolving financial needs. I invented dissatisfactions with the situation, turning an ideal situation into a daily torture.
After getting married and planning for our first child, for instance, the financial risk/reward that worked when I was living alone in a $600 apartment eating Ramen noodles was no longer satisfactory. Demands of owning a home, a car with infant carseats, education funds, daycare (for two children costing more than it would cost to lease two (2) BMW 750i's), and boxes and boxes of diapers, required more financial returns than I needed years before.
I moved on.
While the resulting role superficially wasn't as satisfactory, from a life perspective my mood brightened dramatically, and my day was much more enjoyable.
Of course this seems like cheap advice: Make more money! And Fast! Yet the reality is that developers often do make choices to the detriment of their financial condition, and if they go too far they will hate their job no matter how perfect it otherwise is. Working for equity of a start-up is great when you're just out of university, but it is destined for failure when you're more established.
SUMMARY: If your financials are out of balance, it will unavoidably sour your mood during the workday, making you resent your employer and your workplace. When life goals exceed the income of your position, immediately begin investigating alternatives (be it asking for a raise, looking for a more senior role in your organization, or seeking employment elsewhere). No motivational boost or cool company games room will overcome this basic life need.
MANAGEMENT SUMMARY: Be aware of the goals and needs of your group. Sometimes someone's needs grow beyond the possible return of a position, and it is important to appropriately communicate this (rather than giving vague hints of unseen raises and super-bonuses at some future point).

4. Have A Life Outside of Work

125_2505 This is a rule that works for all professions -- having accomplishments providing satisfaction outside of work will smooth the inevitable downs of our professional lives, often providing one with a much better perspective. Without this, often minor workplace failures can explode into seemingly momentous events.
These accomplishments can even be in the same domain: A professional coder by day, and an open-source coder by night, for instance.
SUMMARY: There will be periods when everything seems to go wrong in the workplace. Having the cushion of achievements outside of work can avoid it spiraling into a workplace disaster, keeping spirits up through the tough times. Often non-work experiences benefit the workplace as well, whether it's techniques learned from nighttime projects, or delicious coffee courtesy of the nighttime barista classes.
MANAGER SUMMARY: There is a world outside of work.

5. Properly Manage Expectations

Developers, as a general rule, are terrible at managing expectations: Many of us are prone to overpromising deliverables, assuring stakeholders that we'll deliver these amazing results sooner than is reasonable. I've fallen victim to this syndrome myself, and I've seen it occur rampantly across the industry.
When D-day comes we convince ourselves into believing that the users built their own unrealistic expectations, and managers forced us into untenable timelines. While often that is the case, just as frequently the developers were the origin of misinformation.
While there is a temporary sense of satisfaction wowing users and management with an exaggerated declaration of our abilities (we've likely even convinced ourselves), as time wears on this misinformation can be enormously destructive and debilitating. With every day closer to the deadline we get a little more desperate for a silver bullet, hoping that some magic technology or component will deliver us from damnation.
It seldom works out that way.
Users are unhappy. Management is dissatisfied. Employees are demoralized and devastated.
The best option is always to manage expectations, to ensure that we can reasonably deliver promised results without heroic effort.
SUMMARY: Plan for the long term, realizing that promises that aren't delivered on will cause you great workplace unhappiness later. Manage expectations to ensure that you can satisfy your "customers" with reasonable effort, and with a reasonably high probability of success.
MANAGER SUMMARY: Never demand unrealistic deadlines, and question employees when provided with the same. Encourage your troops to be more reasonable with their promises, especially to stakeholders outside of the group, and they'll have a much greater probability of meeting external expectations, leading to increased motivation for everyone.


This is an amazing, expansive career full of incredible innovation and endless opportunity. Ensure that you don't diminish your enjoyment through simple mistakes, such as pigeon-holing into a position, or endlessly setting up yourself for failure.

Best Habits of Highly Effective Programmers

As a software engineer, you might want any number of things out of your job - a steady paycheck, the opportunity to work on interesting projects, a springboard to the next better job, or maybe you just like hanging out with other programmers. But by "effective", I mean the ability to complete projects in a timely manner with the expected quality. After working on dozens of software releases, I believe the following practices will bring you there, and while they may involve sticking your neck out, I'd like to think they will also advance your professional reputation, career longevity, and personal satisfaction.

Understand Your Requirements

The first step in becoming an effective programmer is to ensure that you are spending your time wisely. And there is no greater waste of time than in working on something that is not useful or never shipped.

Build Early

Get a demonstrable system working as early as possible. This means establishing the interface first, whether it's an API or user interface, and stubbing the encapsulated functionality as necessary. This allows your "customers" to check it out, by exercising the user interface or writing code to the API, and any inconsistencies or omissions in the initial spec can be detected early. Chances are, you will notice problems or potential improvements even before releasing this first deliverable.
There is a classical school of thought that believes if you design everything up front, then all you have to do is write the code and you're done. That works great if you've done the exact same project before. Otherwise, it's more likely you'll run into a point where you're just guessing or operating on questionable assumptions.
  • Upon joining an early-stage wireless internet startup, I found myself in two months of design meetings for a wireless portal and gateway due to launch in six months. Eventually we got tired of meeting and finally started coding. Within two weeks, my part of the project had no resemblance to the original design, and the first wireless connection test two months later revealed a fundamental misunderstanding of the wireless protocol.
This is not to say that design is unnecessary. But after a certain point, design is just speculation. Design should be validated with implementation, and better to do that early and continuously than late and, well, too late.
Even if the original design is sufficient, once you have something you can tweak, you can improve upon it. Hardware products (who designed this VCR?), buildings, and large-scale software projects suffer from interfaces that were frozen in "preproduction", but with software, you have an opportunity early in the project to refine your understanding of the requirements and produce a suitable interface. But it must be done early.
Getting something ready early is also good for your occupational well-being. Your boss will appreciate seeing evidence that something is actually getting done and having something available to demo. On the other hand, a drawn out period with nothing to show is a recipe for anxious management.

Deliver Often

Once you have something working, don't just leave it as a "proof of concept". Let people play with it, see their reactions, and let this guide and prioritize your development. There is no substitute for watching how people use your software. Customer questionnaires and focus studies might provide some useful input but run the risk of transferring feature and design decisions from the developer to the customer.
In particular get the software into the hands of the QA staff as soon as possible and feed them regular builds, preferably at scheduled intervals. Having them test automated daily builds is ideal, but even a weekly build is pretty good. This will help them feel involved in the full life-cycle of the project and they should be best-trained at identifying and reporting problems. The highest priority should be given to issues that prevent them from using the product, e.g. crashes or dead-end paths - you want them to cover as much as possible as soon as possible and get a feel for the whole product so design issues can be identified early.
  • At a small 3D graphics software vendor, I was put in charge of porting the flagship product from SGI workstations to Windows NT. After six months, the port was so incomplete and crash-prone that I was reluctant to give the first "alpha" build our test group. Fortunately, the QA manager insisted, and the resulting bombardment of bug reports forced me to immediately focus on the problems that prevented the testers from exercising the application in any meaningful way. Left to my own devices, I would have worked on what seemed to be the harder and more important core 3D issues, and probably delayed too long on seemingly mundane issues like the user interface, load-save functionality, and compabilility with all the varieties of consumer hardware we were planning to support.
Programmers often don't want to release code to testers early - they don't want to hear about a bunch of bugs they already know about, and quite possibly the testers don't want to test something that barely works. But it's the testers' job to find these problems and programmers need to realize bug reports are a good thing, if they arrive early enough.

Keep It Real

Keep your software running in as close to a shipping state as possible. You never know when you'll have to demo the system, send out an evaluation copy, or even deliver ("OK, time to wrap things up!")

Use Real Data

If you just test with sample data, that big iceberg of real data out there is going to sink your program.
  • One of the leading semiconductor fabs evaluated a supply chain management product I was working on. After crunching out a milestone delivery to them, we got word back that the first batch of data they fed it from their own operations was still processing - for two days. I sympathized with the lead programmer, who had to dig down and emergency-optimized everything he could for two weeks with both management and client breathing down his neck. I'm just glad it wasn't me on the line.

Use Real Builds

Remember the development build on your machine is not the real build.
  • On a recent game development project where I worked on the user interface, I got intermittent reports from QA that some colors were not correct. Eventually, I realized the problem only showed up in release builds and another programmer used the special console debugging hardware to track down the bug. Which turned out to be a silly mistake I'd made two months previous, failing to specify an initial color value in a few cases. The debug build always selected a specific default value, while the release build optimized that away and the result was less determinate. If I'd made a point of running the release build frequently, I would have spotted my mistake immediately, instead of losing it in the sands of time.

Merge Often

Don't procrastinate on merging your code with the main code base - the longer you wait, the harder it gets.
  • I worked with a programmer who "couldn't be bothered with" all the new code and data changes that showed up in the repository every day. And certainly, daily merges did take up some time for all the other programmers, and this programmer was able to run some impressive standalone demos with a snapshot of the code and data. But every time we had a milestone delivery, it took days to get the isolated code reattached to the current codebase again, sometimes compromising the milestone delivery and risking the funding for the entire project.
Keeping your code out of the official build means that programmers cannot evaluate your code and testers cannot spot bugs early. Maybe you don't want people picking on your code or bugs, but it's better to identify those issues early than later - suck it up.

Understand Your Code

Life is full of wonderful mysteries, but your code is not the place for them. You don't have to know how your car works - if the engine starts making strange noises, you drop it off the mechanic. When it comes to your code, if you don't understand how it works, or doesn't work, no one will.

Code with Style

My childhood piano teacher once commented to me, "Your sister has a good sense of timing, and your brother has a good feel of the keyboard." Then he paused. "You, uh, you work hard."
Programming is one of those things that a lot of people are more or less competent at, but some in particular have a flair for it. I'm a lousy piano player despite years of lessons, and I'm a mediocre basketball player although I enjoy playing it immensely. But I do like to think I have a flair for programming and writing. And not surprisingly, I think good programming is like good writing. Both prose and code are textual, have grammar, syntax, spelling and semantics and spelling. For most coders and writers, this is enough, but the best writers and coders have an esthetic and their work features structure and style that can often be identified with the author.
  • Many Windows programmers wonder why grumpy old Unix/Mac/Amiga/Lisp programmers rail against Win32/MFC/.NET, but if all the API's you've seen are from Microsoft, you probably don't know there's anything better.
Perhaps not everyone is capable of writing stylish code - I've heard it said that good object-oriented programmers, in particular, are born and not made. But like fine music, wine, and literature, you can learn to appreciate good code.


The opposite of stylish programming is cut-and-paste. Grab some code from somewhere that is supposed to do something like what you want, tweak it until it sort of works, stir, repeat, and voila, you have the software equivalent of mystery meat.
  • A few months after leaving one company, a former coworker emailed me a single function consisting of ten pages of cut-and-paste code and asked why it wasn't working. I could have very well asked why it should work at all. If you can't explain how your own code is supposed to work, how can you expect anyone to help you with it? (He has since moved on to a management position at Microsoft)
I've even had trouble diagnosing my own code that was cut-and-pasted from sample code. It's a reasonable way to start new code, but you can't just leave it alone when it seems to work - you have to go back and make sure you understand it line by line and clean it up for your own purposes.

Keep it Clean

The key to keeping your house/condo/apartment clean is to spend a little time cleaning it every day, or at least every week. If you wait until your abode is an unsightly mess, it's just too much damn trouble to clean it all up and you end up just doing a halfhearted job. Or your hire a cleaning service.
Assuming you don't have the luxury of hiring someone to come in and clean up your code every week, you should periodically inspect your code, sweep up accumulated hard-coded numbers, outdated comments, misleading function names, or you'll inevitably end up with uninhabitable code that's embarrassing to show anyone else. And if you're not embarrassed, well, you should be.
  • One programmer I supervised kept reporting to me that her code was "done". This is what management normally likes to hear, but it drives me crazy. Code is never done - you have to debug it, maintain it, evolve it until it's put out to pasture.

Questions? Comments?

Some like to think of programming as a craft. Others, engineering. More often than not, it's archaeology. You dig through sediments of code and wonder what purpose all these strange artifacts served. Do future generations a favor and leave some clues.
  • I asked the aformentioned engineer whose code was "done" to add comments. The result, a function named GetData was prefaced by the comment "Gets data." That's not just useless - it's insulting. What data? (factory automation schedules) In what format? (a proprietary XML format) From where? (an in-house server, using TCP/IP) Not to mention little details like what happens when the server is unavailable or the transmission is broken.
Document your code as if someone else might have to take it over at any moment and know what to do with it. That person might actually be you - how often have you had to revisit your own code and thought to yourself, what was I trying to do here?
  • On a contract with a previous employer, I was asked to look over a piece of code that no one else had time to attend to. At first, I thought it was a mess and didn't know what was going on in there. Then I gradually figured out what the code was doing, and I grudgingly admitted the code wasn't too bad. And then I eventually realized that I had written the code two years ago. Note to self: need more comments.
With that in mind, annotate your code as you write it, instead of waiting for a convenient cleanup phase in "post" - annotating as you code can even clarify your thoughts while you're programming. You can be your own pair-programming buddy.
As a bonus, these days you can generate nice HTML or otherwise-formatted documentation from source code comments, using javadoc, doxygen, whatever. Ideally, the doc-generation is part of your nightly build and available via your intranet.

Full Warning

Ignore compiler and runtime warnings at your own peril. They are called "warnings" for a reason.
  • I shipped one Unix-based application that had a problem linking some functions successfuly - we worked around it by relinking those functions at runtime. When we performed a clean rebuild six months later for the next release, it was revealed that we had turned off linker warnings which would have alerted us of a known linker bug. In our defense, we had swept the linker problems under the carpet at the Unix vendor's suggestion, (thanks, SGI!) but it turned out we could get the link to work just by reordering our libraries.
Crank up the warning levels on your compilers, sprinkle your code with assertions, and log the build and test-time warnings. Better yet, include a count of those warnings in your build metrics so you know if you're dealing with them or letting them accumulate.

Optimal Programming

Code with Purpose

On the other extreme from cut-and-pasters are those who change code just to make it look prettier (at least to them). While it's laudable to have a programming esthetic, it's a waste of time (and a useless risk) to change code just so it looks better to you. It's aggressively annoying to go through and change code that other people have written just so it looks better to you.
  • A fastidious coworker of mine went through our codebase and removed all the expletives. Probably no one would have complained if he had just cleaned up the code written by the entry level employees, but the expletives belonged to the technical lead of our group who was also one of the few distinguished Fellows at the company.

Do No Harm

"Refactoring" is all the rage, now, but programmers often take it to mean any code cleanup or redesign. The trick is in reorganizing code for the better without breaking anything. If you break existing functionality in the name of progress, you're sending one of two messages: 1) your time is more important than everyone else's, or 2) you're incapable of touching code without breaking it.
  • I had one particularly contentious coworker who decided to reimplement the parser in our system but left the code in an unbuildable state by everyone else. I asked him to revert his changes and then found the code was buildable but not runnable - asked about it, he replied that he removed the parser entirely "per your request". Not a team player.
Keeping the code functioning takes some patience and extra work - you have to be diligent about regression-testing your work and chances are you'll need to keep old code and interfaces around for a while as you migrate functionality to your new code. But for everyone to work with the same codebase, that's what you have to do.

Find the Bottleneck

People always talk about "optimization", but that isn't really a correct word. We're rarely shooting for the optimum - instead, we make improvements and tradeoffs to achieve good-enough performance.
  • I was asked in a phone interview with Google how I would search for a number in an array of ordered numbers. Obviously, the questioner was asking for a CS 101 answer - binary search. But in real life, I would probably do the "wrong" thing - search the array from beginning to end. There's no point in taking twice the time to write twice as much code that has to be maintained and debugged if the application performance is good enough, and in particular if that piece of code is not the bottleneck in the application. (And I seriously doubt you'd have that data laid out linearly in a fixed array like that if it was the bottleneck)
If you do need to optimize for speed or space in you application, attacking anything other than the bottleneck is a waste of time.

Manage Thyself

You probably have a lot of complaints about your boss being a lousy manager, and you're probably right. So you have to be your own manager. Even if you have a decent boss, he's not going to stand behind you telling you what to type and how fast (although I'm sure many would like to).

Are We There, Yet?

Programmers are notoriously inadequate at providing useful schedule estimates. I think this is a bad rap, since management, left to their own devices, often make even worse predictions, and unwelcome news from engineers is often ignored. (A common theme in any engineering disaster). But still, awareness of the schedule is critical to actually getting the project done on time.
  • On one commercial software project, some of my coworkers were blissfully unaware of the product release date - one inquired whether it had been released already, another was surprised to find it was going out in a few days.
The worst, and most common, schedule estimate that a programmer can give is "it should just take a couple of days". Every time I hear that, even from my own mouth, I wince.
  • The president of a graphics software company really wanted support for VRML (at the time it was the Next Big Thing) included in the product we were releasing in two months. He probably figured (correctly) that I would resist starting a new feature, so he went to another engineer and got the answer he wanted: "a couple of days". Two days later, I told the president we-just-wasted-two-days-of-his-time-and-mine-while-there-are-two-hundred-high-priority-bugs-to-fix, which he found to be a persuasive argument. (postscript: VRML didn't exactly take off like gangbusters)
And then there are programmers who are unable to come up with time estimates at all. But there's no need to get thrown off by the fuzzy nature of the request - it is an estimate after all, and in fact you should avoid using formulas. If you're an experienced engineer, you know how long comparable tasks have taken you before, and if you're not experienced, you can ask someone who is.
  • A smart friend of mine who was often assigned to developing experimental prototypes asked me, "how can you schedule research". I think it was a rhetorical question, but even pure researchers have schedules. Someone is paying them and expects results, even if it's a number of demos or published papers in a certain timespan. And if you really don't have the foggiest idea how long something will take, then you're the wrong person for the task.
Sometimes programmers are reluctant to commit to a schedule because they're afraid of the accountability. It is true, in this imperfect world, managers will try to bargain you down on schedules, political factions may saddle you with tough or unrealistic schedules in the hopes that you will fail, and it is a sadly common story that after you commit to a schedule, you don't get everything you need.
  • I had one boss who after asking for an estimated completion time would say, "do you promise?" But ask for a commitment on the required hardware and other dependencies, and it was "I'll try."
All I can say is, stick to your guns and give a realistic prediction. Any concessions should be based on pragmatic tradeoffs between features and resources. Be clear about the assumptions, dependencies and resources on which the schedule is based, and get it written down somewhere so you can jog defective memories later.

Plan Your Progress

You wouldn't just hop into your car before deciding where you want to go, right? And probably you have a route in mind before you start driving, too. Similarly, before you sit down at our computer, you should know what you want to accomplish that day and have some idea how.
Distractions will come up day-to-day, so you won't always be able to accomplish what you want. And contrary to those who treat software engineering groups as vending machines (they would probaby shake us vigorously if they could) some tasks take more than a day. So think about what you want to accomplish by Friday, and if you do, then you can enjoy the weekend that much more.

Continuous Education

A corporate soccer team member once asked me, as we were lacing up our cleats, "what's the secret to C programming?" If there was such a secret, I'd be hawking it on late night TV along with ab machines and how to get rich in real estate. Sorry, there's no shortcut - you have to learn and practice and make some mistakes. And you don't necessarily have to rely on corporate training or going back to school - there are plenty of (inter)national and local professional groups, books, and of course, the Internet.

It's Science

It's called "computer science" for a reason. It's easy (maybe too easy) for anyone to to start programming, without a formal computer science education. In particular, those from other engineering and science disciplines can pick up programming quickly and make a good living. But to effectively tackle non-trivial tasks, you need to know the inherent capabilities and limitations of software and recognize prior work, so you don't waste time reinventing the wheel, badly. You don't have to know everything under the sun, but you should have at least a cursory familiarity with many areas and be prepared to do some additional research as necessary.
For example, anyone who creates a new file format should know something about compilers. I don't mean all the code-generation optimizations like loop unrolling, but the basic issues and various phases of compilation and most of all the importance of specifying the tokenization and grammar. Nowadays, most people by default will use XML, and that's a good thing, but before then it was typical to cobble up some text format, point to some generated sample files as documentation, and then everyone else who wrote another parser would cobble something up that would read in some files but not all. In the problematic cases then you could point fingers either way - either the reader is bad or the writer is bad. Whichever product is more popular wins.
  • One of my pet peeves with the 3D graphics industry is the plethora of ill-defined file formats. When I implemented an OBJ file parser for a 3D content creation product, each exporting product that I tested against generated markedly different files, using different whitespace and newline conventions, for example. In refreshing contrast, a coworker of mine fresh out of school designed a new game interchange format using a grammar and lexer specification. (These days, it's not much of an issue anymore - most new graphics file formats seem to be based on XML.)
And if anything differentiates programmers who can just put together simple scripts and user interfaces and those who can tackle real problems, it's an understanding of computational complexity, i.e. how algorithms scale with the size of the problem. Every programmer should know basic complexity terminology and have a general knowledge of the complexity of common problems.
  • My first job was in computer-aided semiconductor design, which has a lot scalability issues, including some NP-complete (essentially intractable) problems. But some of the engineers would run around excitedly saying "it's the traveling salesman problem!" every time they saw a problem that couldn't be solved in linear time, and in other cases we boasted of "linear-time" algorithms which probably meant linear-time most-of-the-time. Or some of the time.

Free Beer, Free Speech, Free Software

OK, there's no free beer, but this is a good time to be a programmer (well, recession and outsourcing controversy notwithstanding) - just about everything you need is on the Internet tutorials, discussion lists, and free software. All you need is the hardware and a broadband connection.


One requirement for being an effective software engineer is to be taken seriously. You need to have the respect of your peers and managers, at least for your technical capabilities, to have control over your own work and influence over others.

There is Such a Thing as a Stupid Question

Really, there are lots of stupid questions. Asking intelligent questions that enhance others' respect for you is a professional skill. A good question that exposes unresolved issues tells people that you know your stuff and you're sharp enough to catch all the implications. Asking for clarification about a specification shows you know how to find and read the spec and your ability to detect ambiguities.
If you don't get any answers to your question, chances are there's something wrong with the question, so don't just repeat it. Ask the question differently, with more specifics, or more background. If you've been on the other end of a technical support line or even just spent time on discussion lists answering newbie questions, you'll appreciate the consideration.
  • I pride myself on cultivating good relations with developer support staff by submitting elaborate bug reports and precise questions. But I do remember one lapse where I tossed out something along the lines of "What's the deal with that issue that came up several weeks ago?" You can imagine the prickly response - "What do you mean by what's the deal, and what issue are you talking about?"
It doesn't pay to be rude, especially if you're essentially asking for free tutoring or consulting on a discussion list. Even if you're asking under the auspices of a support contract, irritating your support contact isn't going to help you in the long term.
  • I used to take pains to explain to belligerent newbies why their questions didn't make sense or what they were fundamentally doing wrong. Now, the bozo filter kicks in quickly - one "All I want to know is....", and they're ignored.
Let everyone know that you read the documentation and googled the subject. Besides avoiding the inevitable "RTFM" and "Google is your friend" responses, this shows you've done your homework and those who want to be of assistance don't have to search through the same resources. If you do expect them to search through those resources for you, then you're saying your time is more important than theirs, and you are just one more perpetrator of the "tragedy of the commons".

There is Such a Thing as a Stupid Answer

If you're going to act like you know what you're talking about, you really better know what you're talking about. Engineers sometimes communicate more to show off their own knowledge rather than to inform (although, if you can do both, kudos to you). This is often inflicted in employment interviews, under the guise of "finding out how you think" the candidate is asked inane puzzle questions. This can backfire, though, if the candidate has any self respect.
  • One CTO interviewed me over the phone by asking me to sketch out the resulting stack frame from a C++ compilation and then report the result back to him verbally. We went through it step by step and every time I gave him a correct answer he asked me to give a wrong answer instead so we could go over why that choice wouldn't work. I couldn't tell if we were trying to demonstrate how smart I was or how smart he was.
There's also the blame game. As an engineer, you can't rely on your money and looks - all you've got is your credibility. So if you make a mistake - 'fess up.
  • I had the privilege of working with a senior engineer who was never wrong. When his Java code was crashing on multiprocessor systems, it was Sun's bug. When I took over the code and pointed out the UI code was not supposed to run in multiple threads, he insisted there was only one thread. When I listed the seven threads (that I could find) in the code, he agreed I shouldn't have all those threads and I'd better fix it. He programmed in that fashion too - he didn't fix any bugs, he just covered them up with more code.

Very Important Things to consider while writing programs in software development

Every day, a software project dies. Some die a slow, painful, expensive, death. Others die a quick, not painless, and relatively embarrassing death . As Software Engineers, we never want our own projects to die. As individual contributors the livelihood of our projects are often times outside the realm of our control. At the same time, there are many things that are within our control that can help the projects that we work on be a success.

This is a list of things to consider while writing programs in software development— habits that when practiced, will not guarantee success in a software project…but will greatly limit the possibility for failure.

Learn from your neighbor – It doesn’t matter if your neighbor is a Junior Programmer or the CTO – run your ideas past them and see what they think. If your neighbor has more expertise then you, then they may have some tried and true advice to get you past the roadblock you’ve been hitting in your code for the last hour. If they are less experienced, then challenging them with a complex problem and discussing it with them may help grow their expertise — something that will surely help your team in the long run.

Keep it simple – This is so easy to say, yet so hard to do. This is the one item that I have to constantly remind myself of when developing software — Software geeks often generate their own requirements without even realizing it (‘Example: Oh, I bet they would like it if they could do this this way OR that way!’). Antoine de Saint-Exupery said it best – “A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away” – Ask yourself each day – ‘what can I remove from the software and still maintain the essence?’ – This alone will get you heads above the rest.

Your code must speak the same language as your client - I’ve been reading bits and pieces of the book Domain-Driven Design . The one main message I am taking away is that the language your code speaks and the language your customer speaks need to be one and the same. If your client keeps talking about how the ‘Policy’ can be sold by a ‘Salesperson’, then maybe you should name your classes ‘Policy’ and ‘Salesperson’, and name your method ‘sell’ not ‘widgetA’, ‘thingB’, and ‘update’ (OK – this is very over-simplified…but the point is that your code will ROT fast if you need to go through multiple layers of translation to understand the changing requirements…let your code be the voice of your customer!)

Water your brain – If you aren’t reading reference books to keep up to date, then you aren’t doing your job as a Rockstar Software Engineer. I don’t care how sweet your code is…if you can’t pick up a few books a year written by the software gods (even if it’s just for a quick refresher) – then you aren’t doing your team any favors. There’s plenty of great books out there to read (and plenty of crappy ones too — so be careful). Two books that I like to read at least once a year are: Smalltalk Best Practice Patterns and Design Patterns — yes I know, very old school, but there are timeless nuggets of information within each! Recent books I’ve read or are reading include the Domain-Driven Design mentioned above and another Kent Beck book, Implementation Patterns. I’m always looking for new books — what is in your library?

Test first - Sorry to break the news, but test-driven development is not a buzz word…it’s something you need to do. If nothing else, it will force you to Keep it Simple. If you write the tests first, you can define the criteria for success up front, therefore providing you with a finish line — when the tests pass, you’re done. Without a finish line, it is so easy to keep running….and running and running, until you have implemented what you think should be implemented…not what the customer needs

Introduce your code to your team - If you work in an environment where there is shared code ownership, this is incredibly important. When you are working on something that you know no one else on the team is familiar with, review the code with them when you make changes. This can accomplish several things at once. First, When you are on vacation without a cell phone, your team will know how to fix your wacky code – We’ve all been here… The last thing you want is to have a message from a co-worker on your hotel room phone in Mexico saying that all hell has broken loose! Secondly, the best brain to have on a software problem is the one that isn’t biased towards a solution. If you wrote the code, you are already biased — you think it is the best way to solve the problem, whether you like it or not. A fresh brain can point out the obvious ways to do it better — and that is a good thing for your team (even if it hurts your own ego a little bit).

Monday, January 16, 2012

Get installed Applications with Details

AIM:  To retrieve all installed apps with the application name, package name, version-number and -code as well as the icons.
Classes:  method getPackages() returns an ArrayList with all the apps.
Code snippet:

class PackageInfoData{
    private String appname = "";
    private String pname = "";
    private String versionName = "";
    private int versionCode = 0;
    private Drawable icon;

private void getInstalledPackages() {
    ArrayList<PackageInfoData> installedApps = getInstalledApps(false); /* false = no system packages */
    for (int i=0; i<installedApps.size(); i++) {
       Log.i("Instlled app","APp Name:"+installedApps.get(i).appname+"package:"+installedApps.get(i).pname);
    return installedApps ;

private ArrayList<PackageInfoData> getInstalledApps(boolean getSysPackages) {
    ArrayList<PackageInfoData> res = new ArrayList<PackageInfoData>();       
    List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);
    for(int i=0;i<packs.size();i++) {
        PackageInfo p = packs.get(i);
        if ((!getSysPackages) && (p.versionName == null)) {
            continue ;
        PackageInfoDatanewInfo = new PackageInfoData();
        newInfo.appname = p.applicationInfo.loadLabel(getPackageManager()).toString();
        newInfo.pname = p.packageName;
        newInfo.versionName = p.versionName;
        newInfo.versionCode = p.versionCode;
        newInfo.icon = p.applicationInfo.loadIcon(getPackageManager());
    return res;

Android Developers Blog

Ram's shared items

Amazon Product Ads