Featured FREE Whitepapers

What's New Here?

jboss-hibernate-logo

Upgrading Spring 3.x and Hibernate 3.x to Spring Platform 1.0.1 (Spring + hibernate 4.x)

I recent volunteered to upgrade our newest project to the latest version of Spring Platform. What Spring Platform gives you is dependency & plugin management across the whole Spring framework’s set of libraries. Since we had fallen behind a little the upgrade did raise some funnies. Here are the things I ran into:         Maven: Our pom files were still referencing: hibernate.jar  ehcache.jar  These artefacts don’t exit on the latest version, so replaced those with hibernate-core.jar and ehcache-core.jar. We also still use the hibernate tools + maven run plugin to reverse engineer our db object. This I needed to update to a release candidate:<hibernate-tools .version="">4.3.1.CR1</hibernate-tools> Hibernate: The code: “Hibernate.createBlob”… no longer exists replaced with: private Blob createBlob(final byte[] bytes) { return NonContextualLobCreator.INSTANCE.wrap(NonContextualLobCreator.INSTANCE.createBlob(bytes)); } On the HibernateTemplate return types are now List; not element…So needed to add casts for the lists being returned. import org.hibernate.classic.Session; replaced with: import org.hibernate.Session; Reverse engineer works a little differently… Assigns Long to numeric… Added: <type-mapping> <sql-type jdbc-type="NUMERIC" precision="4" hibernate-type="java.lang.Integer" /> <sql-type jdbc-type="NUMERIC" precision="6" hibernate-type="java.lang.Integer" /> <sql-type jdbc-type="NUMERIC" precision="8" hibernate-type="java.lang.Integer" /> <sql-type jdbc-type="NUMERIC" precision="10" hibernate-type="java.lang.Long" /> <sql-type jdbc-type="DECIMAL" precision='4' scale='0' hibernate-type="java.lang.Integer" not-null="true"/> <sql-type jdbc-type="DECIMAL" precision='6' scale='0' hibernate-type="java.lang.Integer" not-null="true"/> <sql-type jdbc-type="DATE" hibernate-type="java.util.Date"/> </type-mapping> Possible Errors:Caused by: org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]Add a dependency for c3p0: <dependency> <groupid>org.hibernate</groupId> <artifactid>hibernate-c3p0</artifactId> <version>${hibernate.version}</version> </dependency> And configure the settings in the cfg.xml for it: <property name="hibernate.c3p0.min_size">5</property> <property name="hibernate.c3p0.max_size">20</property> <property name="hibernate.c3p0.timeout">300</property> <property name="hibernate.c3p0.max_statements">50</property> <property name="hibernate.c3p0.idle_test_period">3000</property>Caused by: java.lang.ClassNotFoundException: org.hibernate.engine.FilterDefinitionProbably still using a reference to hibernate3 factory / bean somewhere, change to hibernate4: org.springframework.orm.hibernate3.LocalSessionFactoryBean org.springframework.orm.hibernate3.HibernateTransactionManagerCaused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.hql.classic.ClassicQueryTranslatorFactory There is minor change in new APIs, so this can be resolved by replacing property value with:org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory. Spring: Amazingly some of our application context files still referenced the Spring DTD … replaced with XSD: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> In Spring configs added for c3p0: <prop key="hibernate.c3p0.min_size">5</prop> <prop key="hibernate.c3p0.max_size">20</prop> <prop key="hibernate.c3p0.timeout">300</prop> <prop key="hibernate.c3p0.max_statements">50</prop> <prop key="hibernate.c3p0.idle_test_period">3000</prop> Spring removed the “local”=: so needed to just change that to “ref”= Spring HibernateDaoSupport no longer has: “releaseSession(session);”, which is a good thing so was forced to update the code to work within a transaction. Possible Errors:getFlushMode is not valid without active transaction; nested exception is org.hibernate.HibernateException: getFlushMode is not valid without active transactionRemoved from hibernate properties: <prop key="hibernate.current_session_context_class">thread</prop>  Supply a custom strategy for the scoping of the “current”Session. See Section 2.5, “Contextual sessions” for more information about the built-in strategies org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove ‘readOnly’ marker from transaction definition.Another option is : <bean id ="productHibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate"> <property name="sessionFactory" ref="productSessionFactory"/> <property name="checkWriteOperations" value="false"/> </bean>java.lang.NoClassDefFoundError: javax/servlet/SessionCookieConfigServlet version update: <dependency> <groupid>javax.servlet</groupId> <artifactid>servlet-api</artifactId> <version>3.0.1</version> </dependency>Then deploying on weblogic javassist: $$_javassist_  cannot be cast to javassist.util.proxy.ProxyThe issue here was that there were different versions of javassist being brought into the ear. I all references removed from all our poms, so that the correct version gets pulled in from from Spring/Hibernate… and then configured weblogic to prefer our version: <?xml version="1.0" encoding="UTF-8"?> <weblogic-application> <application-param> <param-name>webapp.encoding.default</param-name> <param-value>UTF-8</param-value> </application-param> <prefer-application-packages> <package-name>javax.jws.*</package-name> <package-name>org.apache.xerces.*</package-name> <package-name>org.apache.xalan.*</package-name> <package-name>org.apache.commons.net.*</package-name> <package-name>org.joda.*</package-name> <package-name>javassist.*</package-name> </prefer-application-packages> </weblogic-application>Reference: Upgrading Spring 3.x and Hibernate 3.x to Spring Platform 1.0.1 (Spring + hibernate 4.x) from our JCG partner Brian Du Preez at the Zen in the art of IT blog....
software-development-2-logo

The “Free”, “Standard”, “Open” Software Heresy

There are those people that have a strong, dogmatic belief in what they call “Free” or “Standard” or “Open” software. One of those individuals is Jimmie (let’s call him Jimmie in this article) who has responded to an article about Java persistence by Marco Behler on TheServerSide. Let me cite Jimmie’s response here:           JPA is difficult but complete. It has a learning curve, and you’ll have surprises if you try to shortcut its complexities. But they mostly are there for a reason. Difficult stuff is difficult using JPA, that’s true. JOOQ is quick to learn. And is proprietary stuff. Not free. Only one implementation. No public review, only one body involved in its evolution. SQL-oriented, not OO (ok, they say it’s a feature). As a serious professional, learn JPA. Fully. There is no excuse for not knowing which sql queries are generated in your production app. Replacing it with a more basic framework is no solution. Let’s not go deeply into the concrete difference between JPA and jOOQ / SQL. That topic has been discussed already in lengths on Reddit. Let’s consider the essence of the comparison as perceived by Jimmie. Because, Jimmie would probably say exactly the same thing when comparing:JSF with Ext.JS or ZK PostgreSQL with Oracle MS Office or Google Docs (probably OK cause “gratis”) with LibreOffice Linux with Windows or MacOSX (although he might perform some doublethink as a Mac user)Software not being free Jimmie, Is YOUR software free and “not proprietary”? If so, how do you finance it? How do you earn a living? And why are you doing it? What really motivates you? What really motivates your customers and why? Only one implementation How many people actually do use alternatives to Hibernate and why? Are they using EclipseLink mainly because they used to use TopLink for the last 20 years and the learning curve (or benefit) to switch to Hibernate is too high? How often do you actually switch implementations? What keeps you from implementing the jOOQ API, and open-source its implementation? And most importantly: Do you always adhere to the JPA API, even if Hibernate has lots of awesome, proprietary extensions that just happen to work so much better / easier? No public review Who exactly is “public”, and what are their main interests? Did you know that one of the major driving force for the JDK is Credit Suisse, being a large customer for Oracle in the Java environment, for instance? What is your stake and relation with Credit Suisse as your “public” representative? Only one body involved in its evolution Do you say that to YOUR customers also, about your own software as well? SQL-oriented vs “a serious professional” What’s not serious about SQL? In fact, SQL is reviewed by more entities than the JLS, let alone the JPA specs. Have you ever thought about that? More basic Fair enough. But don’t forget: You probably replaced your sophisticated EJB 2.0 framework (still a standard!) from the early 2000’s by a more basic one, which was (at the time) proprietary, had only one implementation, had no public review, nor multiple bodies involved in its evolution. It was, at the time, called Hibernate. And let me take the opportunity to cite Gavin King (creator of Hibernate) about when to use Hibernate: standard OFFSET pagination contextually typed value specifications quantified comparison predicates… and of course all the details of interoperation between SQL and XQuery, one of the most popular aspects of the SQL:2011 standard! And please, learn this FULLY, regardless of whether these things are part of your specific implementation. Because as a serious professional, you shall fully learn SQL. And while you’re at that, learn also everything about execution plans, and join, fetch, buffer caching, cursor caching and all other sorts of algorithms. Because there is no excuse for not knowing which SQL transformations are generated by your database’s CBO. I know you like standards, Jimmie. But beware of the fact that there are some people out there who cannot wait for a standard to evolve to solve their problems. They may have more immediate problems. More specific problems. Simpler problems. Problems that might be solved only by proprietary software, so far. Or problems that are solved by proprietary software, that can be put into production with much less effort than your standards, Jimmie. Lower time-to-market is what your customer might consider “professional”. Not whether this or that tech is used. Someone always invents something proprietary at some time. It might just evolve into a standard. It might have been a bad idea and not evolve into anything. Or it might evolve into a standard and then be the worst standard ever. See again: EJB 2.0. I think we all agree on that, today. No, Jimmie, the world isn’t black and white. It isn’t just about standards vs. proprietary. About free (libre) vs. commercial. About free (gratis) vs. “closed”. It’s about creating value for your customer. Oh, and Jimmie. I sincerely hope you’re neither a Windows, nor a Mac user, because that wouldn’t be free, and there is only one implementation of each OS, and no public review, and only one body involved in their evolutions. And yet, the whole world runs on one of them. Thanks for your attention, Jimmie.Reference: The “Free”, “Standard”, “Open” Software Heresy from our JCG partner Lukas Eder at the JAVA, SQL, AND JOOQ blog....
agile-logo

From Personas to User Stories

Summary User stories are a powerful technique to capture the product functionality from the perspective of a user or customer. But how do we discover the right stories? When should they be written and how detailed should they be? Read this post to find out my answers to these questions.           1. Start with Personas The first step towards writing the right user stories is to understand your target users and customers. After all, user stories want to tell a story about the users using the product. If you don’t know who the users are and what problem we want to solve then it’s impossible to write the right stories and you end up with a long wish list rather than a description of the relevant product functionality. Personas offer a great way to capture the users and the customers with their needs. They are fictional characters that have a name and picture; relevant characteristics such as a role, activities, behaviours, and attitudes; and a goal, which is the problem that has to be addressed or the benefit that should be provided. Let’s look at an example. Say we want to create a game for children, which is fun to play and which educates the kids about music and dancing. We would then create at least two personas, one to represent the children, and one for the parents, as the following picture illustrates.The two sample personas above use my simple yet effective persona template. It encourages you to keep your personas concise, to focus on what really matters and to leave out the rest. You can download the template from romanpichler.com/tools/persona-template where more information on writing personas and using the template is available.Once you have created a cast of characters, select a primary persona, the persona you are mainly designing and building the product for. This helps you make the right product decision and get the user experience (UX) right. In the example above, I have chosen Yasmin as the primary persona. 2. Derive Epics from the Persona Goals Once you have created your personas, use their goals personas to identify the product functionality. Ask yourself what the product should do to address the personas’ problems or to create the desired benefits for them, as the following picture shows.Start with your primary persona and capture the functionality as epics, as coarse-grained, high-level stories. Write all the epics necessary to meet the persona goals but keep them rough and sketchy at this stage. For the dance game, we could write the epics below assuming that the game will be initially launched as an iPad app:As the epics above show, the game should allow the players to select different characters, to make them dance, to choose different dance floors and music tracks, to play the game with their friends, and to post a snapshot of their game on Facebook. While epics are great to sketch the product’s functionality, there is more to your product than epics and stories: You should also capture the user interaction and the sequences in which the epics are used, the visual design of your product, and the important nonfunctional qualities such as interoperability and performance. Use, for instance, workflow diagrams, story maps, storyboards, sketches, mock-ups, and constraint cards to describe them. You can find out more about describing the different product aspects in my post “User Stories are Not Enough to Create a Great User Experience”. 3. Progressively Decompose the Epics into User Stories With a holistic but coarse-grained description of your product in place start progressively decomposing your epics. Rather than detailing all epics and writing all user stories in one go, you derive your stories step by step as the following picture shows.As long as there are some significant risks present and you are figuring out what the product should look like and do, it’s best to derive just enough user stories just in time for the next sprint. Use your sprint goal or hypothesis to determine which epics to decompose and which stories to write as the following diagram illustrates.The approach depicted above minimises the amount of detailed items in your product backlog. This makes it easier to integrate new insights derived from exposing product increments or minimum viable products (MVPs) to users and customers. Say that we want to address the risk of creating the wrong game characters by developing an executable prototype that allows us to run a usability test with selected children. We could then write the following user stories:The stories above are derived from the epics “Choose character” and “Play with character”. The resulting prototype only partially implements the two epics – just to the extent of being able to test if the characters resonate with the users. Once you understand better how to meet the customer and user needs, you can start pre-writing user stories and have a larger inventory of detailed items on your product backlog as you are unlikely to experience bigger changes to your epics and your overall backlog. 4. Get the Stories Ready Before the development team starts working on the stories, check that each user story is ready: clear, feasible, and testable.A story is clear if there is a shared understanding between the product owner and the team about its meaning. It is feasible if it can be delivered in the next sprint according to the Definition of Done. This implies that the story is small enough to fit into the sprint but also that the necessary user interface design, test, and documentation work can be carried out. In the case of the sample stories above, we would have to add acceptance criteria, ensure that the stories are small enough to fit into the next sprint, and consider creating some very rough design sketches to indicate what the characters look like. For instance, to get the story “Yas chooses the little girl” ready, we could create the following rough sketch:The sketch above complement the user story and allows the team to implement the entire story including the visual design in the next sprint. With ready user stories in place the development team is in a good position to progress your product in an effective manner.  For more details on getting user stories ready please take a look at my post “The Definition of Ready in Scrum”.Reference: From Personas to User Stories from our JCG partner Roman Pichler at the Pichler’s blog blog....
agile-logo

People Are Not Resources

My manager reviewed the org chart along with the budget. “I need to cut the budget. Which resources can we cut?” “Well, I don’t think we can cut software licenses,” I was reviewing my copy of the budget. “I don’t understand this overhead item here,” I pointed to a particular line item. “No,” he said. “I’m talking about people. Which people can we lay off? We need to cut expenses.” “People aren’t resources! People finish work. If you don’t want us to finish projects, let’s decide which projects not to do. Then we can re-allocate people, if we want. But we don’t start with people. That’s crazy.” I was vehement. My manager looked at me as if I’d grown three heads. “I’ll start wherever I want,” he said. He looked unhappy. “What is the target you need to accomplish? Maybe we can ship something earlier, and bring in revenue, instead of laying people off? You know, bring up the top line, not decrease the bottom line?” Now he looked at me as if I had four heads. “Just tell me who to cut. We have too many resources.” When managers think of people as resources, they stop thinking. I’m convinced of this. My manager was under pressure from his management to reduce his budget. In the same way that technical people under pressure to meet a date stop thinking, managers under pressure stop thinking. Anyone under pressure stops thinking. We react. We can’t consider options. That’s because we are so very human. People are resourceful. But we, the people, are not resources. We are not the same as desks, licenses, infrastructure, and other goods that people need to finish their work. We need to change the language in our organizations. We need to talk about people as people, not resources. And, that is the topic of this month’s management myth: Management Myth 32: I Can Treat People as Interchangeable Resources. Let’s change the language in our organizations. Let’s stop talking about people as “resources” and start talking about people as people. We might still need layoffs. But, maybe we can handle them with humanity. Maybe we can think of the work strategically. And, maybe, just maybe, we can think of the real resources in the organization. You know, the ones we buy with the capital equipment budget or expense budget, not operating budget. The desks, the cables, the computers. Those resources. The ones we have to depreciate. Those are resources. Not people. People become more valuable over time. Show me a desk that does that. Ha! Go read Management Myth 32: I Can Treat People as Interchangeable Resources.Reference: People Are Not Resources from our JCG partner Johanna Rothman at the Managing Product Development blog....
java-logo

Java yield-like using Stream API

Several programming languages, such as Ruby or Python to name a few, provides the yield command. Yield provides an effective way, in terms of memory consumption, to create series of values, by generating such values on demand. More information on Python Yield. Let’s consider a class or method requiring a huge amount of secure random integers. The classical approach would be to create an array or collection of such integers. Yield provides two major advantages over such approach:      yield does not require to know the length of the series in advance. yield does not require to store all values in memory.Fortunately, yield features can be used in Java 8 thanks to Stream API: import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Date; import java.util.function.Supplier; import java.util.stream.Stream;public class Yield {private static final Integer RANDOM_INTS = 10;public static void main(String[] args) {try (Stream randomInt = generateRandomIntStream()){ Object[] randomInts = randomInt.limit(RANDOM_INTS) .sorted().toArray(); for (int i = 0; i < randomInts.length;i++) System.out.println(randomInts[i]); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } }private static Stream generateRandomIntStream() throws NoSuchAlgorithmException{ return Stream.generate(new Supplier() {final SecureRandom random = SecureRandom .getInstance("SHA1PRNG"); boolean init = false; int numGenerated = 0;@Override public Integer get() { if (!init){ random.setSeed(new Date().getTime()); init = true; System.out.println("Seeding"); } final int nextInt = random.nextInt(); System.out.println("Generated random " + numGenerated++ + ": " + nextInt); return nextInt; }}); }} Following is the output after provided code snippet is executed: Seeding Generated random 0: -896358073 Generated random 1: -1268521873 Generated random 2: 9627917 Generated random 3: -2106415441 Generated random 4: 935583477 Generated random 5: -1132421439 Generated random 6: -1324474601 Generated random 7: -1768257192 Generated random 8: -566921081 Generated random 9: 425501046 -2106415441 -1768257192 -1324474601 -1268521873 -1132421439 -896358073 -566921081 9627917 425501046 935583477 It is easy to see that Supplier is only instantiated one. Of course, we can take advantage of all Stream API features such as limit() and sorted(). The line randomInt.limit(RANDOM_INTS).sorted().toArray() triggers the generation of RANDOM_INTS values which are then sorted and stored as an array.Reference: Java yield-like using Stream API from our JCG partner Sergio Molina at the TODOdev blog....
eclipse-logo

eclipse-pmd – New PMD plugin for Eclipse

I am Eclipse user. So when I wanted to analyze my code by PMD, I needed to use “PMD for Eclipse” plugin. This plugin used to be very buggy, which was enhanced in later versions (currently 4.0.3). But the performance is really bad sometimes. Especially when you are dealing with relatively big codebase and have option “Check code after Saving” on. ecplise-pmd plugin So when I realized that there is new alternative PMD plugin called eclipse-pmd out there I evaluated it immediately with great happiness.   Installation uses modern Eclipse Marketplace method. You just need to go “Help” -> “Eclipse Marketplace…” and search for “eclipse-pmd”. Than hit “Install” and follow instructions. After installation I was a little bit confused because I didn’t find any configuration options it general settings (“Window” -> “Preferences”). I discovered that you need to turn on PMD for each project separately. Which make sense, because you can have different rule set per project. So to turn it on, right click on project -> “Preferences” -> “PMD” (there would be two PMD sections if you didn’t uninstall old PMD plugin)-> “Enable PMD for this project” -> “Add…”. Now you should pick a location of PMD ruleset file.   Unlike old PMD plugin, eclipse-pmd don’t import ruleset. It is using ruleset file directly. This is very handy, because typically you want to have it in source control. When you pull changes to ruleset file from source control system, they are applied without re-import (re-import was needed for old PMD plugin). Problem can be when you (or your team) don’t have existing ruleset. I would suggest to start with full ruleset and exclude rules you don’t want to use. Your ruleset would evolve anyway, so starting with most restrictive (default) deck make perfect sense for me. Unfortunately eclipse-pmd plugin doesn’t provide option to generate ruleset file. So I created full ruleset for PMD 5.1.1 (5.1.1 is PMD version not plugin version). I have to admit that it was created with help of old PMD plugin. You can see that I literally included all the rule categories. I would suggest to specify your set this way and exclude/configure rules explicitly as needed. Here is link to PMD site that explains how to customize your ruleset. This approach can be handy when PMD version will be updated. New rules can appear in category and they will be automatically included into your ruleset when you are listing categories, not rules individually. But you have to keep eye on new rules/categories when updating PMD version anyway, because categories often change with new PMD version. So now we should have rulset configured and working. Here are some screen shots of rules in action: When you hover over left side panel warning:When you hover over problematic snippet:When you do quick fix on problematic snippet:Generating suppress warning annotation for PMD rules is very nice feature. It also provide quick fixes for some rules. Take a look at its change log site for full list. These PMD warning sometimes clash with Eclipse native warnings, so there is possibility to make them more visible. Go to “Window” -> “Preferences” -> “General” -> “Editors” -> “Text Editors” -> “Annotations” and find “PMD Violations”.Here you can configure your own style of highlighting PMD issues. This is mine:To explore full feature list of this plugin take a look at its change log site. There are some features in old plugin I miss though. For example I would appreciate some quick link or full description of the rule. Short description provided is sometimes not enough. I encourage you to take a look at full PMD rule description if you are not sure what’s source of the problem. You will learn a lot about Java language itself or about libraries you are using. Quick links would help a lot in such case. Another behavior I miss is full list of PMD violations for current file.  Also some rules doesn’t use code highlighting (only side panel markers). It is sometimes hard to distinguish between compiler and PMD issues. This is problem for me because our team doesn’t use JavaDoc warnings but I do. So I get a lot of JavaDoc warnings from code written by teammates. And sometimes I can miss PMD issue because it is lost in JavaDoc warnings. (Fortunately SVN commit is rejected if I forget to fix some rule). Conclusion This plugin enhanced my Eclipse workflow. No more disruptions because of endless “Checking code…” processing by old plugin.Reference: eclipse-pmd – New PMD plugin for Eclipse from our JCG partner Lubos Krnac at the Lubos Krnac Java blog blog....
career-logo

How to Negotiate Your Salary

I’m often surprised how many software developers neglect to do any salary negotiations at all or make a single attempt at negotiating their salary and then give up and take whatever is offered. Negotiating your salary is important—not just because the dollars will add up over time and you could end up leaving a lot of money on the table—but, also because how you value yourself and how you handle yourself in a salary negotiation will greatly influence how you are perceived at the company you are working for. Once you are part of a company it is difficult to shake the first impression that has been pinned on you. If you handle salary negotiations in a tactful way that indicates your value while still respecting your prospective employer, you’ll likely paint yourself in a more positive light which can have huge implications on your future career with that company.Negotiations begin before you even apply for the job Your ability to negotiate your salary will be greatly influenced by your reputation. Think about a famous athlete or movie star, how much negotiation power does having a well-recognized name have for either of these professions? The same is true for software development or any other field. The more recognized your name is, the more power you will have when it comes to negotiations. So what can you do to build up a name in the software development field? For some people it will happen by chance, but for most software developers it will require some careful planning and tactics. If you follow this blog, you probably know that I highly recommend building a personal brand and actively marketing yourself as a software developer. The basic strategy to do this is to get your name out there through as many different mediums as possible. Write blog posts, get on podcasts, write books or articles, speak at conferences and user groups, create video tutorials, contribute to open source projects and whatever else you can do to get your name out there. Since, marketing yourself isn’t the topic of this post, I won’t go into details here, but if you are interested in learning more about marketing yourself as a software developer, you can check out this post on the topic or if you want a real in-depth treatment of the topic, you can check out my How to Market Yourself as a Software Developer course. Just remember the better job you do of marketing yourself and building a reputation, the easier it will be for you to negotiate. This might even be the most important factor. I’ve worked with software developers who have been able to literally double their salaries based on nothing but building up a bit of a personal brand and online reputation. How you get the job is extremely important The second biggest factor that will influence your ability to negotiate your salary will be how you got the job. There are many different ways to get a job and not all of them are equal. Let’s examine a few different ways you might get a job. First, you might get a job by seeing a job posting and cold-applying to that job posting with your resume and hopefully a good cover-letter. In fact, many job seekers think this is the only way to get a job. This is in fact the worst way to get a job. If you get a job in this manner, it is difficult to have a good negotiating position, because you are in a much weaker position than the employer. You are the one taking all the initiative and asking for the job. The person with the greatest need always has the disadvantage when negotiating anything. Ever played monopoly? Ever tried to negotiate with someone who didn’t really need anything from you, but you needed one of their properties to complete your monopoly? How did that go? Another way to get a job is through personal referral. You know someone who works at a company, they personally refer you for the job and you end up getting offered the job. This is definitely a much better situation than just applying for a job. In fact, you should always try to get a personal referral when you are actively seeking a job. In this situation, the prospective employer might not even know that you are actively looking for a job—so, your need is going to register as less. And, because you got a personal referral, you already have some credibility. You are essentially borrowing the credibility of the person who referred you for the job. I’m sure you can figure out that the higher credibility of the person who referred you for the job, the higher credibility you will have. This credibility will greatly influence your ability to negotiate when given an offer. Ok, so how else can you get a job? How about the best way possible? When the company who offers you a job finds you and comes after you either directly offering you the job or asking you to apply for it. How the situation presents itself will influence your negotiating power. Obviously, your best situation would be if a company knows of you and directly offers you a position without even an interview. In that case you’ll be able to just about name your own price. But, any time an employer directly seeks you out, you’ll have a very good position to negotiate from. Now, you might be thinking “yeah right, an employer is not going to directly seek me out, much less offer me a job without an interview.” I’ll admit, it is somewhat rare, but it does happen. The best way to make these kinds of opportunities happen is to build up a name for yourself and market yourself like I mentioned in the first section of this post. First person to name a number losesOk, so now that we’ve covered the preliminaries—which are actually the most important part of negotiating your salary—let’s get into the actual details of negotiations. One important thing to understand is that the first person to name a number is at a distinct disadvantage. In any kind of negotiation, you always want to act second. Here’s why: Suppose you applied for a job and you expected that the salary for that job was $70,000. You get offered the job and the first question you are asked is what your salary requirements are. You state that you are looking for something around $70,000. Perhaps you are even clever and say somewhere in the range of $70,000 to $80,000. The HR manager immediately offers you a salary of $75,000. You shake hands, accept the deal and are pretty happy—only there is one big problem: The HR manager had budgeted a range from $80,000 to $100,000 for the job. Since you named a number first, you ended up costing yourself potentially as much as $25,000 a year—whoops. You might think this is an extreme example, but it isn’t. You have no way of knowing what someone else is expecting to offer until they tell you. Revealing your number first puts you at a distinct disadvantage. You can’t go up from the number you state, but you can certainly be talked down. So, when you name a number first, you have no upside, but a big downside potential. Oh, but you are more clever than that you say. I’ll just name a really high number. This can blow up in your face as well. If you name too high of a number, you might not even get countered, or you may get countered very low in response. It is almost always to your advantage to have the employer name a number first. The only exception to this is when an employer is purposely going to low-ball you. This situation is pretty rare, but if you have a good reason to suspect this will happen, you may want to name a number first, to set an anchor point. Why? Because if you get a low-ball number, it may be difficult to get an employer to come up a lot from that number. Of course, in that situation, you probably aren’t going to have much success no matter what you do. But, what about when you are asked to name a number first? Don’t do it. Just say “no.” Yes, I know this is tough advice to follow, but let me give you some specific situations and some ways to deal with them. First of all, you may get asked about your salary requirements before an interview or as a field on a job application. If you have a field on a job application, leave it blank if possible or simply put “negotiable depending on overall compensation package.” If you have to name a specific number, put $0 and then explain why later. If you get asked directly in a pre-screening interview about what salary you require or are expecting try to answer the same thing. Say it depends on the overall compensation including benefits. You may get a response stating what the benefit would be or that they just need a general number. In this case, you should try to as tactfully as possible turn the question around and ask a series of questions like the following: “I’d rather learn more about your company and understand more about the job I would be doing before naming an exact number or estimate, but it sounds like you are just trying to figure out if we are in the right range, so we don’t both waste our time—is that correct?” Mostly likely you’ll get a yes. Then follow up with something like this. “You must have a range that you have budgeted for this particular position, right?” Again, you should get a yes. If you are brave, just pause here and don’t say anything else. You may then get them to answer with the range, but if you aren’t brave or they aren’t volunteering any information, you can follow up with: “Well, if you tell me what the range is, even though I don’t know enough to state exactly what my salary requirements are, I can tell you whether or not the range matches up to what I am looking for.” Now, obviously, this isn’t easy to do, but if an employer is going to ask you to name a number, there is no reason why they shouldn’t expect to name one as well—or even first. Try as hard as you can to get them to name one first. If they absolutely refuse, you still have some options. If you have to name a number, name a large range and make it conditional on the overall compensation package, but make sure the lower end of the range is slightly above the absolute lowest you are willing to go. For example, you might say: “I can’t really name an exact figure because it is completely dependent on what the overall compensation package is, but I would generally be looking for something between $70,000 and $100,000—again, depending on the overall compensation package.” What if you are asked about your current salary? This is a tough one; technically it’s none of their business, but you can’t exactly say that. Instead, what you want to do is to turn the question around. There are a variety of different ways to do this, but here is one suggestion: “I’d prefer not to say what my current salary is because if it is higher than what you expect to pay for this job, I wouldn’t want that to eliminate me from being considered for this job—since, I might be willing to accept less for the right position—and, if it is lower than what this job would pay, I wouldn’t want to sell myself short either—I’m sure you can understand.” This is a pretty honest answer, which will mostly likely avoid the question without causing offense. You can also state that you’d just prefer not to answer that question or that you are under a confidential agreement with your employer to not talk about exact salary numbers. If you absolutely have to name a number, try to make the number as variable as possible by talking about bonuses or benefits that affect the overall compensation or state it as the overall compensation package is valued at x dollars and add up what any benefits you are getting are worth. When you have an offer If you can avoid the salary question, you’ll eventually get an offer and it will have to have a number on it. You can’t really get an offer without a number, because it wouldn’t really be an offer. But, negotiations don’t end when you get an offer, that is unless of course you named a number and they gave it to you—whoops.(By the way, if you are in this situation, don’t try and pull any stunts. If they give you what you asked, you pretty much have to either take it or leave it. If you name a higher number than you first asked, not only will it be bad taste, but you’ll likely get the entire offer pulled.) Once you have an offer in hand, you will almost always want to counter. What you counter with is up to you, but I’d highly recommend countering as high as your stomach will allow. You might think that by coming closer to their number, you’ll be more likely to get a favorable response, but in general that approach will backfire. Pick a high number and counter back. Now, you might be worried that doing this will cause you to lose the offer completely. As long as you do it in a tactful way, it is pretty unlikely that the offer will be completely taken off of the table. Usually, the worst case scenario is they stay firm on their offer and tell you that you’ll have to take it or leave it. If the offer does get pulled, you can always respond by saying that you made a mistake and after weighing everything you realized that their original offer was more than fair. (Not fun, but if you really need the job, you can always go down that road.) The fact of the matter is that once you are offered a job, you aren’t likely to just get that offer pulled. Remember, an employer that has invested that much time in interviewing you and making an offer isn’t going to want to just start over again, so you can afford to be a little brave. In most cases when you counter, with your high counter, you’ll get back another response with a slightly higher offer. You can accept this offer, but in most cases, I’d recommend countering just one more time. Be careful here, because you can piss people off. But, one tactful way to do it is to say something like this: “I’d really like to work for your company. The job sounds great and I am excited to work with your team, but I am still just a bit unsure on whether the numbers will work out. If you can do x dollars, I can be sure and commit to it today.” If you do this right and don’t ask for something too much higher, you can usually get a yes. Most employers would rather pay you a little bit more rather than lose you. Worst case, usually, is that they will tell you they can’t go any higher. I really don’t recommend negotiating beyond this point. If you are really brave you can try, but past a second counter-offer, you are really risking losing good-will and souring the deal. You want to appear shrewd, but not greedy. No one likes to feel like they just got worked or taken advantage of. (For a good book on negotiation, check out: Getting Past No: Negotiating in Difficult Situations) Some final advice Know your numbers well. Research as much as possible what the salary ranges are at the company you are applying for and what the salary ranges are for comparable positions. There are some sites online you can use to get salary ranges, although they aren’t always reliable. The better the case you can make for what your salary should be, the easier your negotiations will be. You are in a much better position if you can name exact number ranges and statistics that show why the salary you are asking for is justified. A reason for the salary you are requesting is never because you “need” that much money. No one cares what you need. Instead talk about why you are worth a certain amount or what benefit you can bring to the table. Talk about what you have done for past employers and why investing in you at the salary you are requesting is a good investment. Get as many offers as possible at any one time, but be careful playing them against each-other. You are at a distinct advantage in any negotiation if you can afford to walk away from the deal. To be in this position, you may need to get multiple offers lined up, so you may want to apply for several jobs all at once. Just be a bit careful in playing different offers against each other. You can do it in a tactful way by talking about how you have a couple of offers you are currently considering and want to make the best decision, but be careful not to sound arrogant. Confidence is good, arrogance is bad.Reference: How to Negotiate Your Salary from our JCG partner John Sonmez at the Making the Complex Simple blog....
software-development-2-logo

It’s not NoSQL versus RDBMS, it’s ACID + foreign keys versus eventual consistency

The Background Coming from a diverse background and having dealt with a number of distributed systems, I routinely find myself in a situation where I need to explain why foreign keys managed by an acid compliant RDBMS (no matter how expensive or awesome), lead to a scaleability problem that can be extremely cost prohibitive to solve. I also want to clarify an important point before I begin, scaleability doesn’t equate to a binary yes or no answer, scaleability should always be expressed as an cost per unit of scale and I’ll illustrate why. Let’s use a simplified model of a common web architecture.   In this model, work is divided between application servers (computation) and database servers (storage). If we assume that a foreign key requires validation at the storage level, no matter how scaleable our application layer is, we’re going to run into a storage scaling problem. Note: Oracle RAC is this model…at the end of the day, no matter how many RAC nodes you add, you’re generally only scaling computation power, not storage. To circumvent this problem, the logical step is to also distribute the storage. In this case, the model changes slightly and it begins to look something like this.In this model, one used by distributed database solutions, (including high end acid compliant databases such as Oracle RAC or Exadata or IBM purescale), a information storage is distributed among nodes responsible for storage and the nodes don’t share a disk. In the database scaling community, this is a “shared nothing” architecture. To illustrate this a little further, the way most distributed database work in a shared nothing architecture is one of two ways, for each piece of data they either:Hash the key and use that hash to lookup the node with the data Use master nodes to maintain the node to data associationSo, problem solved right? In theory, especially if I’m using a very fast/efficient hashing method, this should scale very well by simply adding more nodes at the appropriate layer. The Problem The problem has to do with foreign keys, ACID compliance, and the overhead they incur. Ironically, this overhead actually has a potentially serious negative impact on scaleability. Moreover, our reliance on this model and it’s level abstraction, often blinds us to bottlenecks and leads to mysterious phantom slowdowns and inconsistent performance. Let’s first recap a couple of things (a more detailed background can be found here for those that care to read further.A foreign key is a relation in one table to a key in another table the MUST exist for an update or insert to be successful (it’s a little more complicated than that, but we’ll keep it simple) ACID compliance refers to a set of rules about what a transaction means, but in our context, it means that for update A, I must look up information BHere’s the rub, even with a perfectly partitioned shared nothing architecture, if we need to maintain ACID compliance with foreign keys, we run into a particular problem. If the Key for update A is on one node, and the Key for update B is on a different node… we require a lookup across nodes of the cluster. The only way to avoid this problem… is to drop the foreign key and/or relax your ACID compliance. It’s true that perfect forward knowledge might allow us to design the data storage in such a way that this is not really a problem, but reality is otherwise. So, at the end of the day, when folks are throwing their hats into the ring about how NoSQL is better than RDBMS, they’re really saying they want to use databases that are either:ACID compliant and they’ll eschew foreign keys Not ACID compliantAnd I think we can see that, from a scaleability perspective, there are very good reasons to do this.Reference: It’s not NoSQL versus RDBMS, it’s ACID + foreign keys versus eventual consistency from our JCG partner Mike Mainguy at the mike.mainguy blog....
agile-logo

Hiring Trap: I’ll Wait for the Best Person

A senior product manager had a great interview the other day. “I know the industry. I worked on the first generation of their product. I know their customers. I could do this job. I understand their problems. I showed them how I’d solved their problems in the past. I can do this again. “It’s a little junior for me, but I don’t want a go-get-’em job. I’m at the point in my life where I want to take a little time for me. The kids area done with college. I want to take a little extra vacation time so I can spend more time on my hobbies and travel. That makes my salary competitive. I’m not ready to retire. I still want to challenge myself. But I don’t need to work like crazy either. This would be a great job.” The people there said, ‘You’re like family.’ I’m the best candidate for the job. Why are they even interviewing the third candidate?” Good question. When the economy is down or improving, hiring managers think they have a glut of candidates. They think they can take their time and hire slowly. They think they can wait for the best person. This is a hiring trap. What they do is postpone their pain, and allow terrific candidates, the best people to slip through their fingers. Do they think this product manager is going to wait for them to make up their minds? No. This guy is going to have offers, and fast. He’s capable. He’s competitive. He knows how to solve the problems this and other companies need solved. And, just because this company can’t make up it’s mind quickly doesn’t mean other companies won’t. We don’t really have a war for talent. We never did. But, you, the hiring manager are in a competition for the best people. The best people for you, are only an offer away. Do you really need to interview a slew of people to know who is best? If you start describing someone as “family,” maybe you can stop looking. Just a thought. If you think you need to keep looking, what are you looking for? Why drive the cost of a hire up? Don’t fall into the trap of waiting for the best person. Hire a great person. Now.Reference: Hiring Trap: I’ll Wait for the Best Person from our JCG partner Johanna Rothman at the Managing Product Development blog....
javascript-logo

Functional Reactive Programming and JavaScript

Functional reactive programming (FRP) is an emerging programming paradigm that has recently gained popularity in the web world. That popularity isn’t just tied to fact that the video streaming giant Netflix blogged about how it applies FRP to optimize its API, but because it actually provides an elegant way to reduce the complexity of dealing with time-varying events and asynchronous operations. An Example Let’s look at an example to see how FRP can solve a problem that you have likely had to deal with in JavaScript before – when asynchronous requests to the server don’t return in the order they were requested. For the sake of demonstration, let’s say we have a requirement for a cascading drop-down list that consists of 2 related drop-downs. When you select a value from the first one, an AJAX request will be issued to get the list of values to fill up the second drop-down. You can implement in jQuery (or any other JavaScript framework) something like this: <script>// <![CDATA[ $('#dropdown1')change(function () { var selected = $(this).val();var promise = $.ajax('/path/to/your/server', { data: {value: selected} });promise.then(function(data){ var html = $.map(data, function(item){ return '<option value="' + item + '">' + item + '</option>' }).join(''); $('#dropdown2').html(html); }); }); // ]]></script> The problem arises when user is rapidly selecting different values from dropdown1 and the responses are out of order in which they were requested. You could end up having invalid values in dropdown2. One way to solve this problem is to disable dropdown1 until the response comes back to prevent the user from selecting different values. Unfortunately, this makes the application less responsive as the user can’t interact with dropdown1 input. That is when FRP gives you an idea – what if you can make these responses observable, like an event stream, where you want it to react to only the latest response in the stream. There are two popular FRP JavaScript libraries: Bacon.js and Rx.js. I will use Rx.js in this example. The idea is to push these response promises as soon as you get them into an observable event stream. The library will unwrap these promises once they get resolved into yet another stream where our application will be observing. It will react only to the last event. Rx.js doesn’t have a event bus out-of-the-box where you can push values into and observe. (Unlike Bacon.js, where you do have a Bus class that can do this). However, you can create your own event bus with ease, or find one that is already implemented like this one. With the help of the library, our code looks incredibly simple: <script>// <![CDATA[ var bus = new MessageQueue();$('#dropdown1').change(function () { var selected = $(this).val();var promise = $.ajax('/path/to/your/server', { data: {value: selected} });bus.push(promise); });bus.flatMapLatest(function(promise){ return Rx.Observable.fromPromise(promise) }).subscribe(function(data){ var html = $.map(data, function(item){ return '<option value="' + item + '">' + item + '</option>' }).join(''); $('#dropdown2').html(html); }) // ]]></script> First, we create an observable stream called bus to which we can push value. Then we subscribe to the stream so we can react when the value (the response) changes. The flatMapLatest filter method is the one that doing all the magic here. What it does is unwrap the promise when it get resolved into another observable stream. But, while it is waiting for the promise to get resolved, if there is another promise that comes after, it will switch to that stream instead. There is no need to disable the drop-down input. The user can try to select another value if he/she mistakenly picked one, not having to wait for the previous response to come back. The second drop-down is guaranteed to be in sync. Final Thoughts For a small application like this, FRP doesn’t really offer any more advantages than a functional programming or procedure programming. But as the system scales up in these perspectives such as number of interactive components, concurrencies, number of asynchronous operations (and callbacks), the FRP paradigm begin to offer abstractions that help developers not worry about trigger reevaluation of time-varying expressions. I hope you find this article useful and intriguing enough to explore more about FRP. Enjoy.Reference: Functional Reactive Programming and JavaScript from our JCG partner Phuong Nguyen at the Keyhole Software blog....
Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close