Jekyll2025-09-13T09:55:56+00:00https://xyfoo.github.io/feed.xmlFrankie FooBlogArchive2025-06-26T16:00:00+00:002025-06-26T16:00:00+00:00https://xyfoo.github.io/2025/06/26/CMR-Negotiating-The-Best-Salary-Tom-Washington<![CDATA[

This is an article I read on CareerEmpowering.com, which no longer exist after 2019 and is only available on Internet Archive's wayback machine. This is a reproduction of the article, in case the copy on Internet Archive went down for any reason.


Negotiating the best salary

Like most of the things you’ve been learning in this book, negotiating a salary is not difficult, but it does require preparation and practice. By studying and applying appropriate salary-negotiation principles, you can significantly increase your starting salary. You owe it to yourself to get the best salary and benefits possible. Salary, respect, and authority are interwoven.

All jobs have formal or informal salary ranges. Your goal is to receive an offer and negotiate for the high end of the range. To do so you must know the salary range for your geographical area. Your primary information will come from Internet salary sites and from people who are knowledgeable about the field and industry. To get top dollar you must also clearly be the top choice.

As a rule, if you have a solid background and are making a job change rather than a career change, go for a 15–20% increase in salary. You can do this based on the fact that the employer has decided to look outside rather than promote from within and expects to pay a premium for your experience, fresh ideas, and potential.

The first principle for getting a top salary is to fully sell your worth to the organization. You do so by demonstrating your ability to make or save money for the organization, solve problems, or reduce the stress and pressure that your future boss has been experiencing. Although companies have formal or informal salary ranges, those ranges are often ignored when someone with unexpected experience or potential becomes available.

KNOW YOUR WORTH

Knowing your worth in the job market is one of the most important things you can do in preparation for receiving a job offer. Complete your salary research at the beginning of your job hunt so you know what your career field is paying today. Since salaries often drop during a recession, many people have turned down perfectly good offers because the offer was less than what they had been making previously. It can take three to five months to get another decent offer, which will likely be no higher than the salary offered months earlier. Had the person accepted the first offer, he or she would not only have those months of salary, but would also be getting ready for the first salary review, which could bring the person close to their previous salary.

I once worked with a Seattle-based group of laid off employees whose company was headquartered in San Francisco. They quickly discovered that they were being paid according to Bay Area standards, where the cost of living was significantly greater than Seattle. They understood that their salaries could not be matched by Seattle-area employers. They sold themselves well and quickly got reemployed, but at salaries slightly less than they had previously been paid. Before long virtually all of them were back up to their old salary level. Had these very capable people not known their current worth in the Seattle market, some of them could easily have turned down good offers. Instead, they accepted the current market trends and did not take it as personal affront when they were offered less than their previous salaries. While no one likes to step back in pay, at times it is appropriate. That’s why it is essential to understand the market trends in the metropolitan areas where you are seeking employment.

Since salaries tend to rise during a boom time, don’t short change yourself if you’re job hunting at a time when the economy is strong. Know what your type of job is paying at that time in your locality.

At the early stages of your job search, determine your overall value in the field you’re pursuing. The Internet currently offers the best resources for salary information. The three top sites are SalaryExpert (www.salaryexpert.com), Salary.com (www.salary.com), and SalariesReview.com (www.salariesreview.com). Virtually all of the job and career sites will take you to one of these websites when you click on salary information at sites like MSN, HotJobs, and Monster. Salary Expert and Salary.com offer a free, but pretty accurate salary printout, based on your metropolitan area. Both will encourage you to go for one of their premium products which range from $39 to $99 (for the executive report). SalariesReview offers one product at $19. When I got reports from each of the three for the same occupation, the numbers were different, but tended to be within 5% of each other. Certainly check out the free salary printout and give serious consideration for the premium service which will enable you to determine more accurately what you should expect. The printouts from all three give you the salaries at the 25th, 50th , and 75th percentiles. This is helpful. Those with more experience would tend to be on the higher end of the scale. The use of percentiles also recognizes that different organizations pay different amounts. Some organizations, for example, feel that they are such good organizations to work for that they can attract top talent at lower salaries. Other organizations pay poorly because they are cheap or because they are not profitable enough to pay top salaries. In the premium salary printouts they also consider the industry you are seeking and the size of the preferred organization. This is valuable. Accountants, for example, will get paid less in some industries and more in others. Larger organizations tend to pay better and have more generous benefits.

Beyond these tools, the most useful resources for determining salaries are people, including professional association board members, headhunters, and people who currently do the type of work you’re interested in. Associations exist for every career field imaginable. They sometimes produce salary surveys for the benefit of their members. Even those which don’t, can often give you good information about current salary ranges. To find an appropriate association, use The Encyclopedia of Associations and National Trade & Professional Associations of the U.S. These resources are available at most libraries. To find local associations ask people in your chosen field what associations they belong to.

Once you locate an association, attend meetings and talk to members. With national associations find out if salary surveys are available and also ask to speak to the person most knowledgeable about salaries.

Headhunters are another good source of salary information because they are privy to what people are being offered currently. Many will take two or three minutes with you to give you some advice. If you choose to call some headhunters, briefly sell yourself and ask if they are interested in receiving your resume as well. Recruiting firms and employment agencies often conduct wage surveys that they make available to the public as part of their marketing. You can call and ask these firms if they have such surveys available.

Talking to people who do the type of work you want to do can also provide excellent insight into salary scales. You can usually get this information over the phone. Explain the purpose of your call, and ask if they have a couple minutes. Then tactfully ask about salary ranges. You might say something like, “I’m not asking what you make, but if you could give me a good sense of how much someone here in the Cleveland area might make with four years’ experience in shipping and receiving, that would really be helpful.” Taking them off the hook by specifically not asking how much they make invariably yields better results.

KNOW WHAT YOU NEED

Knowing your worth as well as your financial and psychological needs is crucial. If you are currently paid well but are miserable in your job, you would probably be willing to take a pay cut if you could get greater job satisfaction. The question becomes how much of a cut you could accept.

To determine your financial needs, establish three budgets. If you kept track of last year’s expenditures it will be easy. In the left column you would list all of the categories of expenditures that you have. The next three columns would consist of: 1) last year’s expenditures; 2) a level of spending that is less but still comfortable; and 3) a bare-bones budget that enables you to keep your car and home, but slashes other nonessential items. By doing this you are not saying you want to live on a bare-bones budget. This process will simply give you an idea of how low you could go salary-wise and still maintain a modicum of normalcy.

Next, examine and define what you need in a job regarding your psychological needs. The right job is one that enables you to utilize your top skills and strengths. It also allows you to be and express what you already are, without trying to squeeze you into some pre-existing mold. The right job should closely match your temperament, values, and motivators. You should also define the type of organization you want to work for. The organization you work for is tremendously important and can often make the difference between a good job and a great job. Take time to define what would make for you a nearly ideal job, and then determine the lowest salary you would accept if this dream job was offered to you. Assume you are currently working. How much less than you are now earning would you accept?

Create a checklist to help determine how close a particular job is to what you want. On the next page is Debbie Wilson’s checklist. It provided her with a useful guide as she evaluated jobs she interviewed for. You can use Debbie’s checklist as a guide for creating your own checklist. Each item is listed according to its importance, with the most important things first. Debbie was looking for accounting management positions. Adapt the items to suit your career focus.

The following items are ones you might want on your list when defining the type of organization you want to work for:

  • Good salary
  • Benefits
  • Act on employee suggestions
  • Flexible
  • Innovative
  • Potential for advancement
  • High ethics and integrity
  • Pleasant physical environment
  • My own office
  • Minimal office politics
  • Pleasant place to work
  • Casual dress
  • Tuition reimbursement
  • Good opportunities for training
  • Excellent reputation in the industry
  • Relocation unlikely
  • Low turnover
  • Profitable company
  • Rarely have layoffs
  • Promotes from within
  • Facing challenges I’d like to be involved in
  • Short commute
  • Hours are reasonable, small amount of overtime
  • Well-managed organization
  • Top management is stable
  • Organization is doing interesting, valuable work
  • Team emphasis but also work independently
  • Organization has strong sense of direction
  • Management is open with staff
  • Management encourages new ideas

The list is intended to help you get started. Borrow items, but also come up with points that are important to you.

What You Should Know About An Organization

If you look at Debbie’s list, you’ll notice that most of the items dealt with the type of organization she wanted to be a part of. The clearer you are in what you want in an organization, the more likely you are to find it. The problem is, there just aren’t many really good organizations to work for. That’s why employer research is so important. Going to work for a new company is always a risk. Your goal is to reduce those risks and find an organization that matches your needs. Failure to consider these factors and to learn as much about the organization as possible, can lead to frustration and even grief. Suppose you’re a person who needs a very stable work environment, yet you go to a company which is experiencing a reorganization, a shakeup in top management, or is being absorbed by a larger company. What if ethics are very important to you, yet your company misrepresents its ability to make delivery dates? You owe it to yourself to learn as much as possible about these issues.

To help you to determine what you really want in an organization, I’ve created a booklet I call “What You Should Know About An Organization.” It’s available on our website at www.cmr-mvp.com. Click on Books and Booklets by Tom Washington. The booklet examines important characteristics of organizations that you may not have fully considered. The topics elaborated on include: Advancement, atmosphere, benefits, bonuses, dress code, physical environment, ethics and integrity of the organization, family owned companies, flexible/rigid structure, goals of the organization, growth potential, history of the company, innovative, management philosophy, management structure, office politics, problems, products/services, profits/sales volume, relocation policy, reputation, amount of R&D, size, stability, training, tuition reimbursement, and turnover.

DO NOT DISCUSS SALARY UNTIL THE JOB IS OFFERED

Discussing your salary requirements before an offer is made hurts your ability to negotiate. For that reason you should avoid asking about salary, and you should deflect probes into your current earnings or salary expectations.

If the job seems challenging, assume it will pay adequately. Even if it turns out that the job will not pay enough, going through the interviewing process will at worst cost you some time. The following four things can happen only if you thoroughly sell yourself throughout the interviewing process and then go for the job offer:

  1. The job is excellent and it pays what you want.

  2. You succeed in convincing the employer that they need a highly capable person such as yourself, causing them to change the job description and to bump the salary up a couple notches.

  3. You’re overqualified for this position, but an excellent job in the company opens up a few months later and you are hired.

  4. The employer hears of a suitable position with another company and refers you there.

None of these positive things can happen if you prematurely terminate the interview process.

If the job seems challenging, it is best to attend the first interview, learn as much as you can, sell yourself to your fullest ability, and do everything you can to get a second interview. If you are not interested in the position, and you believe it will not pay enough, you can always tactfully decline the offer for a second interview. I would recommend sticking with the process, however, with the intent of getting an offer. Then see where it can go. Any one of the four things listed above might happen.

The problem with asking about pay is that the interviewer will often turn the question around and ask you how much you make or how much you need to make. When that happens, you’re in trouble. Of the three things that can happen, only one is positive. If you provide your income or your expectations, it will either be too high, too low, or about right. If the figure you give is too high, it will generally be assumed you will not be interested in the company’s salary range, so the offer won’t be extended. If you are making considerably less than they are prepared to pay, the assumption will be that you’re a lightweight. This, too, results in no offer. Or, you might get the offer but they may lowball you, knowing that what they’re offering you is 15% below the bottom of their range, but 20% above what you were making before. They know you will be hard pressed to turn down their offer.

Deflecting Questions

No matter how you look at it, talking about money before the time is right confuses things. Frequently of course, it’s the employer who brings up the issue, so you need to know how to deal with it. Even in the first interview, the employer may ask you “What are you looking for?” “How much do you need?” “What’s the minimum amount you’d accept?” or “What range did you have in mind?” Assuming no offer has been made and that the employer has not told you the salary range, your response might be “Perhaps we should concentrate on determining if I’m the right person for the job.” Another response might be, “I always make it a point not to discuss money until a job has been offered.” If you’re fairly far along in the interview process you might add, “Can I assume you’re offering me the position?” Although the employer was not actually offering a position, more than one job seeker has heard, “Well, yeah, I guess I am.”

Usually these mild deflections work, but some interviewers persist. If the question comes again, tactfully, but assertively state, “If you don’t mind, I’d really like to concentrate on making sure I’m the one who can help you reach your goals. When we accomplish that, I’m sure the compensation will be fair.” A statement like that will usually work. In using any of these responses it is important to be as diplomatic as possible.

People are often concerned that these mild deflections will get an employer angry. When handled tactfully, that rarely happens. If you detect that the employer is getting angry, you could ask what range has been set for the position. If the employer provides the range, then indicate whether your needs will fall within that range.

If the employer is unwilling to give you the range, and you really are interested in the position, you might use a wide range by stating, “Probably $28,000 to $35,000 depending on the level of responsibility and benefits.” If you make over $50,000 you might use a $10,000 range.

When The Interviewer Supplies A Salary Range

If the interviewer gives you a salary range for the position and asks whether the amount would be acceptable, you owe it to the interviewer to say yes or no. Some managers want to know immediately whether your salary needs can be met and may pose this question to you during the first ten minutes of the first interview. Their rationale is that they don’t want to waste their time or yours. If the range is acceptable you may want to say something as simple as “The range seems adequate.” You would not want to sound elated or concerned.

PLAN YOUR STRATEGY

The goal of all good negotiations is to allow both sides to gain most of what they want—this is the well-known win-win concept. During the first interview and immediately after, you will begin determining what you need to feel like a winner in this situation. You will learn a lot about the job, your prospective boss, and the culture of the company. If the job, boss, and company seem relatively undesirable, you might be unwilling to accept it for anything less than 30% more than you currently earn. With a much more desirable job, you might accept only a 5% pay increase. Before deciding whether to accept an offer, many factors will be considered; money will be only one of them. Take notes immediately after the interview, jotting down what you learned, observed, and felt, as well as issues that were raised and questions you would like to have answered.

Between the time you are invited back for a second interview and the time you actually attend the interview, you will continue to research the company to determine how desirable it is. You should also formulate questions that will help you decide whether you would accept an offer. If you have detected some undesirable aspects of the job, determine whether they could be altered, and if so, how.

EVERYTHING IS NEGOTIABLE

Keep in mind a key concept in negotiating—everything is negotiable, not just money. There is no guarantee you will get everything you want, but everything is fair game for discussion. The worst thing that can happen is that the employer will say no. Raising an issue, even one that ultimately gets rejected, can cause the employer to give in on another issue that otherwise would also have been rejected.

At the end of the first interview, you should ask about the intended process, including how many interviews are anticipated, and how soon they expect to fill the position. That way you’ll know when to expect an offer. You’ll also know when you need to be fully prepared to negotiate.

DEFINE WHAT IT WILL TAKE TO ACCEPT THE OFFER

Clients frequently tell me that they are going to turn down an offer, often before the offer is actually made. They point out problems with the job and assume that there is no way to make it work. Perhaps a salary range has been discussed and it won’t be enough. Or there are job duties that are undesirable, or there would be too much travel. There are a hundred possible reasons why the job is not right. Often, however, with some creative negotiating, the individual might be able to get all, or nearly all, of what he wants.

When clients tell me they are going to turn down an offer, I usually ask them to determine what it would take to get them to accept the offer. Often the first reply is that the organization would never acquiesce to their requests. Although the organization may not budge, you’ll never know until you ask. So ask. After all, you were about to turn down the offer. Take the time to figure what it would require to get you to accept the offer. Then ask for it. Don’t demand, don’t threaten, just explain that while you like many aspects of the job, there are reasons that will cause you to decline the offer unless certain changes can be made. If the only issue is money, tell them what it would take. Give them a chance to match it. If you’ve been getting five weeks of vacation a year with your present employer and the new company’s policy states that you would only get two weeks until you’ve been there five years, ask for five weeks. Maybe they can make an exception, or maybe they can’t. If they can’t, at least you gave it your best shot.

Sometimes the problem with the offer is more complex. Perhaps there are several duties that you would rather not have to perform, or there may be some responsibilities that you would like to add. Maybe there are several things that would have to be changed. That’s okay. Identify everything that is keeping you from accepting the offer. Then ask yourself whether you must get everything on your list. If there is some room for compromise, there is a greater chance of closing the deal.

Tact is critical if you hope to get what you want. Any hint that you are demanding changes will almost surely kill the deal. Instead, in your most genuine and tactful voice, tell the hiring manager that you would really like to work for her, but that it just would not work with the current offer. State the problem areas and then ask, “What can we do?” Since the two of you would like to work together, make her your ally. That shouldn’t be hard since she selected you from among several candidates. This ally is critical to you since this is the person who will either make the decisions on your behalf or will sell your requests to higher authorities.

Stay open minded. Perhaps there are a couple issues that for various reasons the company just can’t compromise on. Yet, on a couple other issues, they may exceed your expectations. A job offer is a total package, and rarely should you let one aspect of the job be a deal breaker.

BENEFITS ARE IMPORTANT

You won’t know if you want the offer until you know the full range of benefits and perks. A health plan that pays 100% of all bills and has no deductible can save you a $1,000 or more per year. A company car might be worth $4,000 per year. Since many companies do not offer dental or orthodontic insurance, having such a policy may be worth another $1,000 per year. Tuition reimbursement could also save you thousands if you intend to pursue a degree.

As you look at the financial value of a job offer, you must consider its total value. Take into account salary, stock options, bonuses, profit sharing, insurance, tuition reimbursement, and determine the total value for you. In other words, tuition reimbursement may be nice, but it’s of little use to you if you have no interest in entering another classroom. Likewise, if your kids are grown and married, orthodontic insurance will have little value for you.

A fairly complete list of benefits and perks includes: vacation pay; bonuses; stock options; profit sharing; health, dental, orthodontic, vision, disability, and life insurance; company car or payment for mileage; tuition reimbursement; expense account; professional memberships; country club or health club memberships; relocation expense; free parking; deferred compensation; pension funds; severance pay; outplacement assistance; physical exams; use of corporate plane or vacation property; estate and financial planning; tax and legal assistance.

WHAT ARE THOSE INTANGIBLES WORTH?

There are many intangibles to consider. Perhaps the last company you worked for did nothing illegal, but was always on the edge of doing things that were unethical. As a result, you didn’t feel good about yourself and you felt no sense of pride when you told people where you worked. What would it be worth to you to work for a company with a great reputation?

Perhaps your present company watches you like a hawk. What would it be worth to you to work for a company that only hires highly responsible people and then trusts them to do whatever is necessary to get a task done?

These same questions could be posed regarding any of the factors that affect people in a work environment. People like working in organizations where people cooperate, where there is minimal office politics, where people get ahead on merit, where top management listens and keeps everyone informed, where employees receive recognition for doing good work, and where employees are treated fairly and with respect.

While it’s hard to put a dollar value on these factors, most people would trade some money to work in a more suitable, positive work environment. Some would trade a lot, others only a little. But clearly, these factors must be taken into consideration when you determine the minimum salary you would accept to work for an organization.

YOU’RE WORTH WHAT THEY’RE WILLING TO PAY

While negotiating, keep in mind that neither you nor your prospective boss knows your true worth. Your worth is whatever someone is willing to pay you. Your challenge is to make the employer want you badly enough so he or she will offer you what you want.

You May Be Worth More Than You Think

When all is said and done, the most important aspect of interviewing is to make the employer want to hire you. Once that happens, good things will follow. The following story demonstrates this idea.

A young woman was interviewing for a position which was really going to make her stretch. She had convinced the employer of her potential, and he really liked her spunk. He asked her how much she wanted, and she responded by saying, “I think twenty-four would be fair.” What she was really saying was that she wanted $24,000. The employer paused for a moment and said, “Fine, let’s start you at twenty-four hundred. When can you begin?” Do you see what just transpired? She asked for $24,000 but the employer thought she meant $2,400 per month, which is $28,800. It was more than he had intended to pay, but she had created value in his mind, so he was willing to pay it without negotiating. This also demonstrates that she was worth more than she thought. She broke some of the rules of negotiating, but she ended up with far more than she had ever hoped for. The key to her success was that throughout the interview, she sold herself.

People Want What They Want

The psychology of salary negotiations is important to understand. A key psychological factor is that people want what they want. Once people decide they want something, they are virtually always willing to spend more to get it than they originally intended. In 1990 a Van Gogh painting called Portrait of Dr. Gachet sold for a record $82.5 million. Art appraisers had assumed it would sell for about $60 million, based on the sale price of a similar Van Gogh the year before, which set a record of $53.9 million. When the bidding got started, it quickly exceeded the $60-million level. The painting was finally sold to a wealthy Japanese businessman. No doubt he had hoped to spend only $60 million, but he really wanted the painting. As the bidding kept rising, he undoubtedly said to himself, “I don’t care how much it costs, I’m going to have that painting.”

Most of us don’t go around buying expensive art, but we go through exactly the same process when we shop for a new car. Almost everyone ends up spending more than was originally intended.

So, even if your prospective boss says he or she simply can’t go over a certain amount, don’t accept that too quickly. Managers have budgets, and if they are willing to cut the budget somewhere else, it may free up some money.

Determine The Causes Of Roadblocks

If you reach a roadblock in your salary negotiations, try to determine the true cause. You might ask the employer, “What do you think is the main issue? Is it a problem with your budget, or will the wage-and-salary-administration folks feel that the job’s structure doesn’t warrant a higher salary?” By asking a question you will at least get a response. This will also give you something different to discuss for the next few minutes. Once you have a response, even if it’s not the full truth, you can begin dealing with that issue. Get the person to agree that your worth is greater, and then help her come up with a creative way to find the money. If the human resources department is the problem, then suggest rewriting the job description to give you more responsibility. This would place you in a higher pay bracket. By helping to clarify the issue, you are also helping the manager decide how badly she wants you. She is psychologically committed and does not want to lose you. Furthermore, she’s come this far in the process with you, and she does not want to lose you over a measly $2,000 or some other fairly minor sticking point.

To negotiate in the way I’ve just described requires confidence that you have something unique or valuable to offer. If you have identified your strengths, and if you are interviewing for a job that will fully utilize those strengths, you will have some unique attributes to offer. If, on the other hand, the employer was ready to flip a coin as to whether to give the job to you or candidate B, you are not in as strong a bargaining position. The employer may have reason to believe that candidate B would accept a lower figure than you. Although the employer wants to hire you, she may be unwilling to go to any great lengths to do so. During the interviewing, and then later during the negotiating, you must assess how much this person really wants you. At a certain point the person will say in essence, “That’s as high as I can go, take it or leave it.” When that point is reached the decision will be up to you.

The Value Of A Job Is Set By The Responsibility Level

Sometimes a job only has a certain value. While you might be capable of handling more responsibility than the job needs, the worth of the job is based upon the level of responsibility required. You may get the offer, but you will not be able to negotiate for top dollar unless you can get the employer to expand the duties and responsibilities.

You’ll Gain Respect By Negotiating

Some people are afraid that by negotiating for salary they may offend the employer. If you negotiate fairly and reasonably, employers will actually respect you more. Almost all initial offers are less than what the employer is prepared to pay you. If you accept the initial offer, it may actually cause the employer to wonder why you were obtained so cheaply. Employers expect to negotiate, so accommodate them. For some it’s even a game that they enjoy. Let them have some fun.

Ask For A Shorter Review Time

If you reach an impasse, asking for a shorter review time may break it. Typically, reviews come six months after joining the firm, and then annually thereafter. If you have the confidence that you can become a strong producer in three months, ask for a review at that point. If you are able to negotiate a sizable raise at that time, it will almost be as if you had started at that level.

When The Offer Is Just Right

If the initial amount offered you is perfectly acceptable, you have a quick decision to make. You could cordially accept the offer and thank the person for making a fair offer. That will make your boss feel good. Or, you could counter with an amount just 5% above the initial offer to see if there is room to negotiate.

Saving Face When You Have To Back Down

Sometimes an offer is made and the employer refuses to budge on the amount, or comes up only a token amount. During the negotiation you were fairly adamant that you wanted a significantly higher starting salary. You realize that you still want the job despite the large gap between offered and desired pay, but it seems awkward accepting what has been offered. Here’s a solution: “Mr. Chang, I’ve always felt that the quality of the job is more important than the pay. This job is very attractive to me. In my mind there’s no question that the job is worth $48,000 and I’m worth at least that amount. Let’s go ahead and start at your $42,000 figure. It’s my intention to quickly prove to you my worth. At my review, if I’ve demonstrated real value, I’ll expect to be paid what I’m worth.” At this point all Mr. Chang has to do is affirm that you will be paid based on your actual contribution. You’re basically putting Chang on notice that he risks losing you if you are not compensated properly. You haven’t actually said it, and you are not threatening Chang, but he’s on notice, nonetheless.

You Need To Practice Negotiating

When it comes to negotiating, there is no substitute for actually practicing what you intend to say. In our society we are not used to haggling. The only haggling over price we do is when buying a car or attending a garage sale. For most of us, neither is an everyday occurrence. That’s why practice is necessary just to become comfortable with the process of negotiating. Also, practice saying the amount you want. Let’s say you want $44,000, although the most you’ve ever made is $38,000. If the first offer you get from an employer is $39,000, you’ll need to counter with $49,000 just to have a chance to get your $44,000. If you haven’t practiced saying that you want $49,000, that number will stick in your throat and you won’t get it out.

Get The Employer To Redefine The Position

Because no one knows your strengths as well as you do, it’s your responsibility to thoroughly present your capabilities and demonstrate the full range of your strengths. If your background exceeds the scope and salary of the position you’re applying for, a smart manager may change the scope of the job without any prompting from you. Others will not be so perceptive, so the responsibility falls upon you to explain how the organization can maximize their investment in you by redefining the position. If you can show how they can get a higher return on their investment, you may be able to extract part of that return in the form of more salary.

BREAKING THROUGH AN IMPASSE

If it’s important to you that you truly get what you’re worth, you must be prepared to walk away from the bargaining table. You should be clear on the minimum you would accept. If, despite your best efforts, you can’t get close to an acceptable salary, you’ll be forced to restate your minimum requirements. If your prospective employer indicates those needs cannot be met, you’ll shake hands and both express regret that it did not work out.

While you should be clear regarding the minimum you would accept, you must remember that you are not just talking dollars; there are also the benefits and the intangibles to consider. Only you can decide whether the combination meets your minimum needs. As both sides sense an approaching impasse, both parties will begin considering how they will feel if the deal does not go through. Reaching that stage often helps both sides get creative again to come up with a solution. You’ll be saying to yourself, “I really do want to work for this person, and I think this company is going places. I don’t want to miss out on this opportunity.” The employer will be saying, “This is the person who can help me get my promotion. With her drive and past successes, I know she’ll be effective. I’ve got to find a way to bring her on board.”

As you sense an impasse approaching, you may choose to adjourn. It may work like this: “Mrs. Barkley, maybe the best thing to do is get back together tomorrow. I would really like working for you and I’m still excited about the opportunities here. From my standpoint, it would really help if you could add $2,000 to the starting pay.” Barkley would probably then restate her position. Neither side is promising to budge, but sometimes a good night’s sleep can put a new perspective on things.

NEGOTIATING THE SALARY

Salary negotiating is an art. Knowing how to respond and knowing when to be silent can make a difference in your paycheck.

When Silence is Golden

An effective negotiating technique is to respond to an offer by repeating the amount, or by repeating the high end of the range and then remaining silent, looking away as if you are pondering the offer. It is important to repeat the amount so that the employer will know that you fully heard and understood the offer. Since people hate silence, a common response is, “Well, I suppose for someone with your back-ground we could start you at $X.” You’ve already gotten a raise using very few words, and a strategic application of silence.

Let The Employer Know You Want The Job

Whether or not you managed to obtain a raise through your silence, you must now let the employer know that you really do want the job, but that the initial offer is not adequate. You will help prepare the employer to accept your request by expressing your desire for the job. It might be something like, “I appreciate the offer Mr. Gonzalez. I really believe the position will make excellent use of my strengths. But based on my research of what people with my background are receiving, I had really expected something close to $X.”

Responding When The Employer Makes A Specific Offer

All of the discussion so far leads up to the point when an offer is actually made. Knowing what to say and how to respond is important to your success.

Note: As you read this next section, you will notice that in some of the conversations the dollar sign is missing. That’s because in real conversations people often say, “I was thinking of thirty-seven thousand,” rather than “I was thinking of thirty-seven thousand dollars.”

Most employers know it is their responsibility to make an offer, so it may begin like this: “John, we’d like to start you out at $40,000 and then review your salary in six months.” John must quickly decide whether he will negotiate, since he was expecting at least $42,000 and he wants $46,000. He is currently earning $39,000 and feels he is underpaid. In a case like this he might say: “Mr. Russell, I’m glad I turned out to be your top choice. Although money is not the only factor, it is important. In fact, it’s the major reason I’ve chosen to leave my job. When I began this process, I made a decision to take a job at 20% above what I’m now earning. I really don’t see a reason to change that decision. If there is any way you can adjust your budget, it would sure help. I never intended to accept anything below 46,000.”

Although there is nothing that guarantees that John’s worth to his new prospective company is 20% above what he is currently making, it is not unfair for John to want to make more. If he really wants 20% more, he will simply turn down all offers which are below what he wants. He can afford to wait since he currently has a job.

John could also use what I call the straight-forward approach when responding. It would go like this: “Mr. Russell, based on my potential I really feel I’m worth $48,000, but if you would make it $47,000, the decision would sure be a lot easier.”

The creative approach should sometimes be tried. Remember, the offer was for $40,000. “Mr. Russell, based on the duties you’ve described, I agree that the job is probably worth no more than $42,000. I’m sure you would agree with me, however, that I’m capable of handling much more. And when I began this job search, I never intended to accept anything below $46,000. But perhaps if the responsibilities were increased you could justify $46,000.” Notice what has been done. The offer was for $40,000, and the interviewee is basically agreeing, but then suggests that the job is worth $42,000. Even while agreeing, the interviewee adds a little to the salary, then asks if the responsibilities could be increased.

Another strategy is to use another job offer as leverage whenever possible. You may have received an offer where the salary is satisfactory, but the job is not what you really want. Then you may get another offer where the job is perfect, but the salary is low. You might want to say, “Mr. Stuyvesant, the job itself is perfect, and of course I would really enjoy working with you. The salary is below what I expected, and I already have an offer at 4,000 a year more than your offer. If you could adjust your budget, it would make my decision a lot easier.”

Responding To “How Much Do You Want/How Much Are You Worth?”

When making an offer, most employers will specify a certain beginning salary. Some, however, will not, and they may ask, “How much do you want?” or “How much do you think you’re worth?” If you get this type of offer, you will have to depend on what your research revealed. Your research should provide you with a good idea of what the typical range is for the position you want. If you believe the range is $52–57,000, you might say, “The starting salary is important to me, but not nearly as important as a job that fits me and allows me to make the kind of contribution I know I can make. I believe in three years I should be making at least $64,000.” This is a good response. You are giving the impression of being very realistic and flexible. Actually, you have just put the interviewer in a corner. The interviewer may know that the best he or she can hope to do is get you an 8% increase each year. Therefore, to reach your $64,000 goal in three years the starting salary must be the $56,000 you actually wanted. Surprisingly, it is often easier for a supervisor to start you off high at the beginning than to obtain raises commensurate with your contributions later on.

If you believe the range is $52–57,000, you could present a range by saying, “Based on my experience and potential, an acceptable starting salary would be between 54 and 60,000, depending on my full range of responsibilities and other aspects of the benefits package.” This is effective because it cannot be interpreted as saying you would accept an offer as low as $54,000. The idea is to state a range with the high end of your range slightly higher than what you assume their high end is, and your low range slightly higher than what you assume their low end to be. Or you might state a single figure about 5% above what you believe the top of their range is. If you think the top of the range is $57,000, you would look the employer in the eye and say, “I was thinking about 59,000.” The employer will probably reject that amount. Don’t let it bother you. Simply ask, “What’s the best you can offer?” Because of your confidence and the potential you have demonstrated, the next figure will probably be very close to the top of their range.

Of course, the employer could respond, “We were thinking closer to 50.” Perhaps you misjudged the range. For this company $50-52,000 may be the top of their range. Or you may not have completely sold the employer on your potential. Your response might be, “I feel I’m worth more than that. However, working for the right organization is really more important than the starting salary. I’d say 57,000 would be fair. The employer may still not go for it, or may come up to $52,000. If the employer counters with $52,000, you would counter with $55,000 and probably end up at $54,000. Not all negotiations, of course, end up with each counterproposal neatly meeting in the middle.

Wrapping It Up

How tough you negotiate depends on how strongly you feel about your worth. Once you have negotiated for the best salary possible, other factors must still be considered, particularly if the salary offer is below what you expected. If, for example, the employer offers a six-month salary review, ask for a three-month review. Other factors you will continue to negotiate at this point include: cost-of-living increases, moving expenses, tuition reimbursement, flex-time, an extra week of vacation, or anything else that is important to you.

In any negotiations, a final point is eventually reached. You know you’ve reached the end of negotiations when the two sides are close, yet neither side will go any further. At this point someone has to make the final compromise and say, “Let’s call it a deal.”

Salary negotiations are usually not long and drawn out. For entry-level to middle management positions the whole process may take less than two minutes.

Observe the following, typical negotiation:

Employer: Bob, I’d like to have you join us. I’ll start you out at $34,000 and then review your performance in six months.

Bob: I appreciate the offer. As I’m sure you could tell, I’m really quite excited about the position. I’ll be honest though; I had thought the job would be worth considerably more. I had figured on something closer to $42,000.

Employer: (Pause) Bob, I know I’m not going to be able to match your figure, but I’ll tell you what, let’s start you at $36,000.

Bob: That certainly helps. I really do want to accept the position and money is not the only issue. I feel that there are going to be excellent opportunities with this company. I still feel the job is worth 42, and I know I’m worth that much, but I would definitely consider 41.

Employer: Bob, I’m sure you realize that any firm like ours has to place minimums and maximums on salaries at various levels to keep everything in the company balanced. I suppose I could offer you 38, but that’s as high as I can go.

Bob: Make it 39 and you’ve got yourself an employee.

Employer: All right, you’ve got a deal at $38,500. Agreed?

Bob: Agreed. Thirty-eight -five and a review in three months.

Employer: Do you really think you can prove yourself in three months?

Bob: I think so.

Employer: Okay, thirty-eight-five and a review in three months. But I’m not promising a pay increase, you’ve got to earn it.

Bob: I understand. I think you’ll be pleased with my results.

At the executive level, however, negotiations may take a half hour or several days, as both sides propose and counterpropose. If one of the negotiation issues must be decided by someone else in the organization, it may take several days to conclude the negotiations.

The ability to negotiate for a higher salary is one of the most valuable skills you can develop. Once you understand the principles, the practice is up to you.

NOW YOU CAN DECIDE IF YOU WANT THE JOB

Once salary and benefits have been negotiated, you are almost ready to decide whether you will accept the position. You need time to consider the decision. Your emotions are strong at the moment, so you need an opportunity to step back and be objective. Just as the employer did not make the hiring decision after the first interview, you need time to consider everything. Employers realize that it is never an easy decision to accept a new position or to leave a current position. The employer had time to consider several people and to check references prior to making you the offer. The employer had a chance to sleep on it and make the decision with a proper frame of mind. You need the same opportunity.

Ask for time by saying something like, “I think the salary is going to be adequate and I think we’re going to work very well together. How soon do you need a definite decision?” They should give you at least three days. If you have another offer pending, you might respond with, “Today is Thursday. How about if I confirm everything by next Wednesday?” If you’re going to need more than a week you should be prepared to explain some of the reasons. If you have another job offer pending, but won’t know anything definite for two weeks, you’ll probably need to explain the situation. You might explain that if that job comes through, you feel you owe it to yourself to be able to weigh all factors. If you’ve established solid rapport with your prospective boss, the person won’t like waiting for two weeks, but will understand. If the employer cannot wait that long, you may be forced to make a decision sooner than you would have liked. When you ask for the time to make the decision, do not say “I’ll have to discuss it with my wife (husband).”

RESEARCH AFTER AN OFFER IS MADE

Once you’ve gotten the job offer, negotiated salary and benefits, and reached an agreement, you still need answers to your remaining questions. Some of the questions you did ask may not have been adequately answered, and there were other questions you did not ask at all because they seemed too sensitive. Now is the time to ask those questions. To the interviewer you might say: “Mrs. Torgeson, I’m glad you had the confidence in me to offer me the position. The salary is about right and I’m really looking forward to working with you. I do have just a few questions that I would like clarified so that I can make the right decision.” Then proceed to ask every question you have, even those sensitive ones you did not ask earlier. As long as it is asked tactfully, almost any question regarding you, the job, or the organization is reasonable.

Having asked for time to decide, you now have two important tasks to complete: 1) Make a final, all-out effort to discover more about the company from inside sources; and 2) Contact those other organizations which have expressed interest in you.

Complete Your Employer Research

During the next several days learn everything you can even though you’ve basically decided to take the job. Perhaps you would turn it down only if another company made a better offer or if additional research uncovers serious problems concerning the organization. Many people regret their failure to do this final bit of research—I wouldn’t want you to be one of them.

Throughout your research you learned a lot. During the interviews you learned a great deal more. After the offer was made you asked even more questions, including the sensitive ones you had postponed. The answers to those last questions probably cleared away all of your doubts. You may have been tempted to accept the job on the spot. Fortunately you didn’t. On your way home from this interview, begin asking yourself if there are still any matters that need more clarification. Determine what sources might answer your questions. If you haven’t talked to any competitors yet, this would be a good time. It’s also the time to talk to employees and ex-employees of your prospective employer. Ask your contacts if they know anyone who works for or has worked for your target organization.

Things are not always as they appear. The boss who seems so understanding and likable in the interview may be completely different on the job. The company that seems so peaceful may be experiencing political infighting. Or the company that seems so stable may be ready for bankruptcy. Organizations often hide serious problems. It’s now your responsibility to discover what those problems are.

Maintain a healthy skepticism. Talk the job over with your mate, a friend, or a career counselor—anyone who will be more objective about it than you are. It’s amazing what a second party can see that you may be blind to.

Suppose the offer was made on Thursday and you agreed to give your final answer by Monday afternoon. Through several insiders you picked up some information plus a few rumors that need to be clarified. On Monday morning you might call your boss-to-be and ask for an appointment that afternoon: “Mr. Bradley, this is Paul Johnson. I’ve been doing a lot of thinking and I have essentially decided to accept the position. I still have a couple questions to ask you though, and it might be good just to meet with you for a few minutes this afternoon.”

With most questions you will simply ask the question and then evaluate the response. If the answer is not complete enough, you may have to ask a follow-up question. When asking about any rumors, be tactful.

Get Additional Offers

After a job is offered, your second task is to contact those organizations that have interviewed you for definite openings. Your call might go like this:

Ms. Esparza, this is Sandy Hogan. We talked last week about your scheduling coordinator position. You indicated it could be two weeks before I would be asked back for a second interview, but I thought I’d better call to explain my situation. I’ve just been offered a really good scheduling position with another company. But, based on our conversation, I would really rather work for you. What do you suggest I do?

If you are not being considered for the job, the employer will suggest you take the position already offered. If the employer is really interested, another interview may be quickly arranged. Do your best to get one or two additional offers. It may not work, but it is definitely worth the effort. It is extremely helpful to have two or more job offers to consider at one time.

If the job that hasn’t been offered to you is really the one you want, this effort may cause the employer to speed up the decision-making process. What might have taken another week or two, may be reduced to two or three days if you really were the number one choice.

Gathering Information From People

As valuable as written resources are, information gathered from people is often the most helpful. Talk with people who work for or have worked for your target company, people with competitors or suppliers, and people who work for a customer of the target company. All of these people can add to your insights and information about a company.

You may be saying to yourself, “But I don’t know anyone who works for my target companies.” While this may be true, I can guarantee that someone among your friends and contacts does know someone who works for your target companies. If you want to badly enough, you can get direct information about almost any local organization.

Employees And Former Employees

Once you have your list of target organizations, call your contacts and ask them who they know in those organizations. If they don’t know anyone, ask them to ask around for you. It’s okay to ask for favors. After all, you’d do the same for them. Once you get a name, call the person to learn as much as you can about the organization. Be sure to mention the name of the person who referred you or your new contact may be rather cool and reserved. Also try to establish rapport before asking probing questions. For instance, you might start by asking the person his or her overall view of the company.

Competitors

Competitors are valuable sources of information, but they may have some obvious biases. When talking to competitors, talk to sales and management people. Employees at lower levels seldom keep up on competitors. For example, the purchasing manager of a competitor probably belongs to the same association as the purchasing manager in your target company; they may even know each other. Sales people are helpful because it’s their business to know about competitors. As you’re picking up information, determine whether the person is sincere. If the person shares both positives and negatives about your target organization, instead of just negatives, the information will probably prove useful.

Suppliers/Customers

Suppliers and customers may be harder to locate than competitors, but a few well-placed phone calls can reveal them. Most of your target organizations probably fall in a few industries. Call several companies that would be likely to purchase the products or services of your target organizations and ask if they buy from any of them. It’s very possible that they buy from several of your target firms since an organization rarely buys everything from just one source. Each of these companies will give you a slightly different view of your target organizations. Invariably, two or three organizations will be consistently mentioned as having excellent products and providing outstanding service.

Inside Information

Insiders can give you a great deal of information that you won’t find in any written resources. Be aware, however, that every insider, whether employee, former employee, competitor, customer, or supplier, is likely to have some biases about the organization. Be alert to such biases. Everything you hear represents only one viewpoint and needs to be treated as such. This is true of virtually any organization: some will love it, some will hate it. You’ll need to determine whether the person you’re talking with has an ax to grind (he may recently have lost out on a promotion), knows enough about the organization (she may really know only about her own department), or is even telling the truth. This is the fun part. You’re a detective, evaluating motives and confirming stories.

Interviews are a very important part of employer research. During most interviews you’ll learn a lot about the company and the department you would be working in. Make full use of the opportunity to ask questions. Ask about your growth potential, your duties, the interviewer’s management style, and the future directions of the company.

Interviewing is a continuation of your research. Keep your detective cap on and discover all you can. Ask yourself if you would enjoy working for this person. Will you respect this boss? Do your management philosophies match? Will you like each other? These are some of the important questions that can be answered, in part, by the research you conduct during interviews.

Do some research before each interview, even if it’s the third or fourth interview with the same company. This is particularly important if you feel really good about the job, your potential boss, and the company. Discover all you can. Answering questions effectively and asking the right questions could make the difference between being the number-one choice and the number-two choice.

Copyright 2004, Tom Washington. Not for commercial use without prior approval.

]]><![CDATA[This is an article I read on CareerEmpowering.com, which no longer exist after 2019 and is only available on Internet Archive's wayback machine. This is a reproduction of the article, in case the copy on Internet Archive went down for any reason.]]>Web Component with Vue2024-10-04T16:00:00+00:002024-10-04T16:00:00+00:00https://xyfoo.github.io/2024/10/04/web-component-with-vue<![CDATA[

Learning on trying to create web component with Vue SFC. Items here maybe wrong, and might be corrected in the future as I learn.

Context

I'm trying to build some web component using Vue SFC + Vite into independent esm JavaScript library, which is then used in an ASP.NET core MVC applicaiton. I would to use the VSCode tooling for the web component development, and use Visual Studio to managed the backend.

Observation

  • Items within a light DOM will get affected by global stylesheets. This is the default HTML behavior.
  • Items within a shadown DOM (inside a custom element / web component) are not affected by global stylesheets. The styles defined in the custom element doesn't 'leak' to the the outer document.
  • Vue SFC, when running in vite dev server, the elements are generated in the light DOM. Styles, scoped or otherwise, will be applied.
  • Vue SFC, when exported as a custom element thru defineCustomElement API, how the styles is being handled is dependant on the tooling (here we're referring to Vite Vue plugin) and the API configuration.
  • defineCustomElement API allows one to specify if we want the elements to be generated in the shadow DOM (default) or otherwise via shadowRoot option.
  • The vite-plugin-vue package have a features.customElement options to transform Vue SFC to custom elements. If this options is enabled, the Vue SFC imported/referenced in the entry file (the file that will call the Vue's defineCustomElement API & and register the custom element with DOM) will be ...?

  • SFC style: global, CE entry file: shadowDom, Vite Vue Plugin: CustomElement true => Single JS file generated, the style was inlined, style was 'scoped', stayed within the shadow DOM and didn't leaked out to other parts of documents. There's no additional data-attribute was added to the shadow DOM elements.
  • SFC style: scoped, CE entry file: shadowDom, Vite Vue Plugin: CustomElement enabled => Single JS file generated, the style was inlined, style was 'scoped', stayed within the shadow DOM and didn't leaked out to other parts of documents. The generated element within the shadom DOM element have a data-attribute for scope isolation <div [data-v-f3f3eg9]> added to it. Same with the generated style css selectors div[data-v-f3f3eg9]. The data attribute id is the same for the same tag (in CE usage) or the same componet (in vue app) and doesn't change each time it was used. (SO it seems like using scoped is better since it could prevent leakage in vite dev scenario)

  • SFC style: global, CE entry file: shadowDom, Vite Vue Plugin: CustomElement false => 1 js and 1 css file is generated. the style is not inlined but will be exported as a separate css file. The elements & style do not have data-attribute for scope isolation.
    • In Vite Server: The style will be applied to the components, but the style defined will leaked to other parts of the document.The leakage maybe mitigated via usage of className.
    • In custom element usage: Usage of the generated sheetstyle may leak to other parts of the document, but it will not pierce thru the shadow DOM, i.e. the item will not be styled. The leakage maybe mitigated via usage of className. Might be possible to allow styling using ::part psuedo element if defined.
  • SFC style: scoped, CE entry file: shadowDom, Vite Vue Plugin: CustomElement false => 1 js and 1 css file is generated. the style is not inlined but will be exported as a separate css file. The elements & style will have data-attribute for scope isolation. The style will not leaked out to other parts of the documents due to scope isolation.
    • In Vite Server: The style will be applied to the components, with no leakage to other parts.
    • In custom element usage: But it will not pierce thru the shadow DOM, i.e. the item will not be styled. No leakge either. Might be possible to allow styling using ::part psuedo element if defined.
  • If there are multi entry point, all the styles will be exported into a single css file. So seems like using scoped style or css class name will be good in preventing collision.

  • SFC style: global, CE entry file: lightDOM, Vite Vue Plugin: CustomElement true => 1 js file, styled will be inlined. But when used in ce mode, it will complain 'Custom element style injection is not supported when using shadowRoot: false', and it doesn't have any effect to element; element generated in light DOM, and can be affeced by global stylesheet. when in vite dev mode, the style will leaked out to other part of the docs.
  • SFC style: global, CE entry file: lightDOM, Vite Vue Plugin: CustomElement true => 1 js file, styled will be inlined. But when used in ce mode, it will complain 'Custom element style injection is not supported when using shadowRoot: false', and it doesn't have any effect to element; element generated in light DOM, and can be affeced by global stylesheet. when in vite dev mode, the style will not leak out to other place.

  • SFC style: scoped, CE entry file: lightDOM, Vite Vue Plugin: CustomElement false => 1 js and 1 css file, But when used in ce mode and vite server mode, they all work the same way, the style works and isolated.
  • SFC style: global, CE entry file: lightDOM, Vite Vue Plugin: CustomElement false => 1 js and 1 css file, But when used in ce mode and vite server mode, they work the same way but the style may leaked to other part of docs.

  • If demo1, a non *.ce.vue component but it refers to demo3, a *.ce.vue component, and let the tooling auto compile item with *.ce.vue inlined the item. the demo3 the styling wil lcome thru when in demo1, but not when on it's own. It's a mess
]]>
<![CDATA[Learning on trying to create web component with Vue SFC. Items here maybe wrong, and might be corrected in the future as I learn.]]>
Enabling websocket for Blazor server on Azure AppService2021-06-04T16:00:00+00:002021-06-04T16:00:00+00:00https://xyfoo.github.io/2021/06/04/blazor-server-azure-appservice-websocket<![CDATA[

When one deploy a Blazor Server project to Azure AppService, the app works just like any othe web apps. But if you look at the browser developer tools, you'll noticed it's using long polling insted of websocket connection.

To enable websocker on AppService, you'll need to go to Azure Portal > App Service > Configuration > General Settings > Websocket to turn it on. Your app will be restarted, and it will use websocket onwards.

]]>
<![CDATA[When one deploy a Blazor Server project to Azure AppService, the app works just like any othe web apps. But if you look at the browser developer tools, you'll noticed it's using long polling insted of websocket connection.]]>
Knockout Observable In Expression2021-06-03T16:00:00+00:002021-06-03T16:00:00+00:00https://xyfoo.github.io/2021/06/03/knockout-observables-in-expression<![CDATA[

Given this Knockout ViewModel

function MyViewModel() {
    var self = this;
    this.SomeBooleanObservable = ko.observable(true);
    this.SomeIntObservable = ko.observable(3);
}

If you want to use the observable as it is in HTML, do this

<div>
    <p data-bind="visible: SomeBooleanObservable">Standard Data Bind</li>
    <!-- ko if: SomeBooleanObservable -->
    <p>Containerless Control Syntax Flow</p>
    <!-- /ko -->
</div>

but if you need to use JS expression in HTML, prepend () to observable to get it work

<div>
    <!-- This wont work, and will fail silently -->
    <!-- ko if: SomeBooleanObservable == true -->
    <p>Containerless Control Syntax Flow</p>
    <!-- /ko -->
    
    <!-- This will work -->
    <p data-bind="visible: SomeBooleanObservable() == false">Standard Data Bind</li>
    <!-- ko if: SomeBooleanObservable() == true -->
    <p>Containerless Control Syntax Flow</p>
    <!-- /ko -->
    <!-- ko if: SomeIntObservable() >= 2.5 -->
    <p>SomeIntObservable is equal or more than 2.5</p>
    <!-- /ko -->
</div>

Knockout documentation on binding syntax

]]>
<![CDATA[Given this Knockout ViewModel]]>
Different ways to insert data to Microsoft SQL Server2021-05-02T16:00:00+00:002021-05-02T16:00:00+00:00https://xyfoo.github.io/2021/05/02/ways-to-insert-data-to-mssql<![CDATA[

Examples requires Dapper lib

Single value

var conn = new SqlConnection("myconnectionstring");

// RUn single sql command
// INSERT MYTABLE(DbColumn1, DbColumn2) VALUES ('ABC', 123)
var result = conn.Execute(@"INSERT MYTABLE(DbColumn1, DbColumn2) VALUES (@DbCol1, @DbCol2)", new { DbCol1 = "ABC", DbCol2 = 123});

Multiple value

var conn = new SqlConnection("myconnectionstring");

var myList = new List<MyObject>();
myList.Add(new MyObject() { DbCol1 = "ABC", DbCol2 = 123});
myList.Add(new MyObject() { DbCol1 = "DEF", DbCol2 = 456});

// Run single SQL command multiple times, i.e. like a loop
// INSERT MYTABLE(DbColumn1, DbColumn2) VALUES ('ABC', 123)
// INSERT MYTABLE(DbColumn1, DbColumn2) VALUES ('DEF', 456)
var result = conn.Execute(@"INSERT MYTABLE(DbColumn1, DbColumn2) VALUES (@DbCol1, @DbCol2)", myList);

Multiple value (faster)

  • Maximum 1000 set of values per insert statement
var conn = new SqlConnection("myconnectionstring");

var myList = new List<MyObject>();
myList.Add(new MyObject() { DbCol1 = "ABC", DbCol2 = 123});
myList.Add(new MyObject() { DbCol1 = "DEF", DbCol2 = 456});

var sqlCmd = "INSERT MYTABLE(DbColumn1, DbColumn2) VALUES ";
sqlCmd += string.Join(",", myList.Select(x => $"('{x.DbCol1}', '{x.DbCol2}')"));

// Run single SQL command
// INSERT MYTABLE(DbColumn1, DbColumn2) VALUES ('ABC', 123), ('DEF, 456)
var result = conn.Execute(sqlCmd)

Multiple value (fastest)

  • Use SqlBulkCopy
  • No construction of SQL command required
  • Supports more than 1000 rows
var conn = new SqlConnection("myconnectionstring");

var myDataTable = new DataTable("myTable");
myDataTable.Columns.Add("DbColumn1");
myDataTable.Columns.Add("DbColumn2");

myDataTable.Rows.Add(new object[] { "ABC", 123 });
myDataTable.Rows.Add(new object[] { "DEF", 456 });

// No SQL, only bcp
SqlBulkCopy bulkCopy = new SqlBulkCopy(conn);
bulkCopy.DestinationTableName = "dbo.MYTABLE";
bulkCopy.WriteToServer(pageDt.CreateDataReader());
]]>
<![CDATA[Examples requires Dapper lib]]>
Fast Image Loading with RecyclerView &amp; Glide2019-03-26T16:00:00+00:002019-03-26T16:00:00+00:00https://xyfoo.github.io/2019/03/26/glide-recyclerview-integration<![CDATA[

It's not an easy task to write a performant Android app that load large images or process a large number of small images. These operations tend to wreak havoc on your app's memory management.

Glide

Android Developer site has a series of advice on how to handle such a scenario, and one of their recommendations is to use the Glide library.

Glide is a fast and efficient image loading library for Android focused on smooth scrolling. Glide offers an easy to use API, a performant and extensible resource decoding pipeline and automatic resource pooling.

...

Glide’s primary focus is on making scrolling any kind of a list of images as smooth and fast as possible, but Glide is also effective for almost any case where you need to fetch, resize, and display a remote image.

Glide is doing all the heavy-lifting work in the background, so images will be load fast & efficiently.

RecyclerView

RecyclerView is a widget that allows you to create lists of items for large dataset. It's much more advanced and flexible than ListView.

One of the important things that RecyclerView can do is UI virtualization.

Example

The device screen can only show 10 items on the screen, and you have 1000 items in the dataset. RecyclerView will probably generate the following:

Element Count Viewport Note
n/2 Not visible Buffer if the user scrolls up
n Visible On screen
n/2 Not visible Buffer if user scroll down

RecyclerView will only create a total of 20 UI elements (5 + 10 + 5), instead of 1000 in one go. As the user scroll along, it will recycle the created UI element and bind it with new data.

If the image to be loaded is a 'new' image (not previously loaded), Glide will have to load the bitmap and cache it (to the memory and/or disk). Inflating images will take a longer time because it's operationally expensive and memory intensive, in comparison with other UI elements.

And that is why if you have implemented an image gallery using RecyclerView & Glide, and the user decided to flick through the list extremely fast, and the app will typically show a large amount of white space.

Solution

Use the RecyclerView integration library.

The RecyclerView integration library makes the RecyclerViewPreloader available in your application. RecyclerViewPreloader can automatically load images just ahead of where a user is scrolling in a RecyclerView.

Combined with the right image size and an effective disk cache strategy, this library can dramatically decrease the number of loading tiles/indicators users see when scrolling through lists of images by ensuring that the images the user is about to reach are already in memory.

Using the library in Xamarin.Android project

I've ported over the library to a nuget package, so you can use it in your Xamarin.Android project.

If you have any question, you can hop over to the project's repository.

]]>
<![CDATA[It's not an easy task to write a performant Android app that load large images or process a large number of small images. These operations tend to wreak havoc on your app's memory management.]]>
Use Baidu Push Service in Xamarin.Android2019-03-16T16:00:00+00:002019-03-16T16:00:00+00:00https://xyfoo.github.io/2019/03/16/using-baidu-push-in-xamarin<![CDATA[

Firebase Cloud Messaging is a very good push notification service for most Android app, except it doesn't work in China. Google services are blocked over there.

Baidu Cloud Push is one of the push notification service that can work in China. They have iOS/Android client SDK, Java/PHP based server SDK, REST API, and is intergrated into Amazon SNS & Microsoft Azure's Notification Hub service.

I'm going to show you how do you integrate Baidu Cloud Push into Xamarin.Android project, and use it with Amazon SNS/Azure Notification Hub.


What you'll need.


1. Download 'Baidu.Android.PushService' nuget

  1. Download this Nuget. It's a Xamarin.Android binding library for Baidu Push Service Android native SDK.
  2. Complete the additional setup instruction

2. Create the required permissions & registration in App Manifest

<script src="https://gist.github.com/xyfoo/39c9be7957500e7ee88861e5ee242514.js">

3. Implement the push notification receiver

<script src="https://gist.github.com/xyfoo/aee457468cc5f091bdd91c4b6ea81c02.js">

And initialize the class in your MainActivity OnCreate function.

4. You're done!

Upon the app launch, your device will be registered with Baidu Cloud Push (generating a unique UserId, channelId) and a token/regId from your choice of push notification platform.

You can use those ID to do a push notificaiton to your device now.


The full project repository can be found here

]]>
<![CDATA[Firebase Cloud Messaging is a very good push notification service for most Android app, except it doesn't work in China. Google services are blocked over there.]]>
Xamarin.Forms How to: Perform automated UI test2018-11-29T16:00:00+00:002018-11-29T16:00:00+00:00https://xyfoo.github.io/2018/11/29/xamarin-ui-test<![CDATA[

If your application has a broad reach of users, it’s likely you will face one of this:

  • The new release works, but it breaks some feature from the previous release.
  • The feature works correctly on this model, but not that model.
  • The designed UI doesn’t work as well in landscape mode

While unit testing can help you to catch much coding & logical error in your application, it doesn’t help you to do UI (and integration) testing.

Most likely you just tested out the feature by yourself, using your own phone while you developed it. It was not tested on other form factors. As the application complexity increased, you never retested the old feature again.

Xamarin.UITest

Xamarin.UITest is a UI test framework developed by Xamarin. It can simulate user interactions on Xamarin application (Forms, iOS, Android), and also native swift/Obj-C based iOS & Java-based Android application. It’s API that powers Xamarin Test Cloud, enabling an uploaded test to run on hundreds of physical device simultaneously.

However, you can also run the same test on your dev machine, using an emulator or connected device.

Today, we’re going to focus on testing a simple Xamarin.Forms Android application using Xamarin.UITest APIs.

Prerequisites

The following are all done using: VS2017 v15.9, Xamarin 4.12.3.69, Xamarin.UITest 2.2.7, Google Emulator

Make sure of the following before we start:

  • ANDROID_HOME system variable is pointing to the Android SDK’s installation directory. Recommended to be the same as VS’s settings.
  • JDK_HOME system variable is pointing to the Java Development Kit’s installation directory. Recommended to be the same as VS’s settings.

If Xamarin.UITest emit mismatched SDK version between dev machine & emulator, you might want to make sure that “platform-tools.old-xxxxx” doesn’t exist in the Android SDK folder.

1. Setting up Xamarin.Forms

Download the sample project from my github repo

In our XF application, we have

  • a text field
  • a button that validates the length of the text field input (Less than 5 characters, display ‘Wrong’; Else, display ‘Correct’)
  • a series of coloured boxes
  • a label that displays how far along that we have scrolled.

In each of the item that we wish to automate, we should assign a unique name to its AutomationId attribute. We will use this in our test script later.

<script src="https://gist.github.com/xyfoo/a0b3c0fc6673060ef6abb4c0e6ddd0e2.js">

2. Create new Xamarin.UITest project

Add new project > Visual C# > Test > Xamarin.UI Cross-Platform Test Project

Xamarin.UITest project requires NUnit 2.6.3 or 2.6.4 to manage & run the test, and is incompatible with NUnit 3.

3. Initialize application for test

StartApp function in AppInitializer.cs is where the test environment is configured. This function will be called during the test setup, in order to provide a clean test environment for tests to run.

<script src="https://gist.github.com/xyfoo/5ca866445dc388ce7b08fc0b56de81b0.js">

Here we’re asking the initializer to do the following:

  • Specified an installed application on the device (or you can supply an APK file)
  • Enable on-demand screenshot capture as specified in the tests
  • Decide automatically if the test should run on the emulator or connected device
  • Start the application

Initialization in the iOS application is different from the Android application. You can read more @ iOS, Android

4. Writing our test

To test if the text field validation works, we need to do the following:

  1. Enter 4 characters into the text field
  2. Tap the validate button
  3. Check if the message box contains our expected output
  4. Take a screenshot so we can review the result manually later

We can use Marked attribute or AppQuery to locate for the UI element to act on. In Xamarin.Forms, Marked attribute is represented by the AutomationId in Xamarin.Forms that we’ve inserted into XAML earlier.

So one would write the test as below:

<script src="https://gist.github.com/xyfoo/f45b66550198a3cee5c2c1ac3410b033.js">

5. Run the test

Right-click on your test, and select ‘Run Test’, or you can select the test in the Test Explorer.

Right click on the test function{:class="blogimg"}

From test explorer{:class="blogimg"}

6. The test will failed

If you run the test above, the test result will indicate failure. But when we check the screenshot, it will show that the test has in fact performed as expected. So what went wrong?

The main reason is that UI rendering operation is much slower than our test sequence and that rendering time may depend on many external factors, such as network performance, code execution speed, hardware limitation etc. So when we check for the error message, we will encounter error, as the message box has not been rendered yet, and hence the test will fail.

So we should introduce some delay before checking for result, and we can do this by using WaitForElement API.

<script src="https://gist.github.com/xyfoo/6570b39ef9ed522527eefd49bf42fa39.js">

So there you have it, you have written your first Xamarin.UITest automated test.

As exercise, you may try to write a test to test out the scrolling behaviour as an exercise.

]]>
<![CDATA[If your application has a broad reach of users, it’s likely you will face one of this:]]>
Xamarin.Forms How to: Integrate Android 7.1 App Shortcuts2017-04-15T16:00:00+00:002017-04-15T16:00:00+00:00https://xyfoo.github.io/2017/04/15/xamarin-android-7.1-shortcuts<![CDATA[

Android introduced a new feature, App Shortcut in Android 7.1 (API level 25), and are available to any apps that target that API level.

Shortcuts in the messenger app{:class="blogimg"}

App shortcuts can be displayed by long press on the application icon, and touching on each item will start a series of actions defined by the application itself (like the context menu in desktop). Each of the app shortcuts can also be dragged and dropped as an independent icon at the home page, for easier access (like a desktop shortcut with command-line arguments)

Imagine we want to build an app for an airline, the user of the app may want to access these item fast and frequently:

  • Check flight bookings
  • Reach out for customer service
  • Get the flight status for the upcoming flight

These are great candidates for App Shortcut. So let’s see how can we implement this in a Xamarin.Forms application.

Create a shortcut resources file

Create a xml folders and placed it in you Android > Resources folder, and create the following file:

<script src="https://gist.github.com/xyfoo/0ac6d8f0e8a9df690cb5170e0e2f5702.js">

shortcuts.xml defines the list of static shortcuts for your application, and are available from the time the app is installed. A list of intents can be attached to each shortcut, but the user will only see the last intent on the list. For now we only need one intent.

The attributes in the shortcuts are pretty self-explanatory, but there are a few things to take note:

  • Labels (e.g. android:shortcutShortLabel) cannot be directly assigned with a string, but instead will need to defer to Android project’s resources/xml/strings.xml
<script src="https://gist.github.com/xyfoo/a059339d972c373e89b2d218a849d081.js">
  • The intend of each shortcut are pointing back to our MainActivity, but how do we differentiate one action from the other? We use the android:data attribute for that purpose: content://actions/bookings & content://actions/customerservice. More on that later
  • It’s best to use an icon that conform to the app shortcut design guideline.

Associate the shortcut resource file to MainActivity

Add a MetaData attribute to the MainActivity class

<script src="https://gist.github.com/xyfoo/03ea6f66a56a45fa10c020749ccab17a.js">

Matching up MainActivity’s name & shortcut intent’s targetClass

By default, Xamarin.Android will generate a name for each declared Activity class that’s prepend with a hash value. This is inconvenience for us as we could not easily know the generated activity name without examining the final generate AndroidManifest.xml.

To overwrite this behavior, you can specify the activity name explicitly:

<script src="https://gist.github.com/xyfoo/a7e65d5704c3a8bfd7e5be356eb4b56c.js">

Make sure the targetClass in the shortcut intent matched up with the specified activity name.

At this stage, you should be able to build and deploy, and this is what you will see if you long press on the application icon

Displaying list of static shortcuts{:class="blogimg"}

But if you click on it, it would just open the application and do nothing more.

Sample app{:class="blogimg"}

Let’s add some action to the shortcuts so we could directly access the pages.

Capture the intent’s data and pass it on

In the MainActivity.cs OnCreate method, capture the intent’s data (as specified in the shortcuts.xml). For this example, we only want the last segment of the Uri path.

<script src="https://gist.github.com/xyfoo/4c2994ffb0837dccd4c507dbca9f164d.js">

And update our XF’s Application class to accept the data

<script src="https://gist.github.com/xyfoo/59998ef2a09774f98f106225f6e43f2c.js">

The default launch will not contains any intent data. So if we have any intent data on Application class initialization, we presume that it’s invoked from the App Shortcut, and we should do something with it.

We’ll go with using MessagingCenter to fire a message to subscriber for the sake of simplicity in this example. You can use any method that you like.

Do something with the captured data

So what we want to do is we want Customer Service tab to be shown on load up when CustomerService app shortcut is touched. To do that, subscribed to the messages that we would fire in the Application class:

<script src="https://gist.github.com/xyfoo/867b979d85605a90671dea16fe7dfe6b.js">

Once we received the message, we just do tab switching based on the received data. And voila! You can now launch to a specific page from the App Shortcut.

Launch to customer service page directly from App Shortcut{:class="blogimg"}

Bonus: Add a shortcut for upcoming flight

So let’s say you’ve booked a flight, and you want the quick access to the flgith status. And because we could not possibly know ahead of what’s the user’s upcoming flight at the app level, we could not declared it ahead of time in the shortcuts.xml

App shortcut “Flight SA773” is created at runtime{:class="blogimg"}

To do that, we use Dynamic Shortcut. Dynamic shortcut allow you to add/modify the shortcut in runtime when you need it.

The ideal scenario to add the flight shortcut would be when the user has just purchased the flight ticket in-app, or when user manually add the flight as favourite. To simulate such scenario, we have two buttons in the booking page:

Booking button{:class="blogimg"}

and with their Clicked event handler as below:

<script src="https://gist.github.com/xyfoo/40e5dfc9ed683aa8c85cae9eab7d1766.js">

Send some message with data and receive them in MainActivity.cs…

<script src="https://gist.github.com/xyfoo/c257645594010232c63b286534267d3a.js">

With the code above, you can now add a dynamic shortcut, and you can clear it out easily at run time. But that’s not it, you still need to handle the newly created dynamic shortcut invocation.

So let’s go back to MainPage.xaml.cs

<script src="https://gist.github.com/xyfoo/48cb73a3c637e1526df4d67292d65b8a.js">

When we received the data from the App Shortcut’s intent, we extract the flight number, store it in a variable, and then display it when the MainPage is appeared on device screen.

And that’s it!

Final result{:class="blogimg"}

The full source code for this sample can be found at my github repo

]]>
<![CDATA[Android introduced a new feature, App Shortcut in Android 7.1 (API level 25), and are available to any apps that target that API level.]]>
Xamarin.Forms How to: Add a scroll down prompt to ScrollView2017-04-06T16:00:00+00:002017-04-06T16:00:00+00:00https://xyfoo.github.io/2017/04/06/xamarin-scroll-down-prompt<![CDATA[

There’s a request from a customer to have a scroll down prompt when the content is too tall to be displayed in a single screen height. Pretty much like what you normally see in a lot of website:

Example{:class="blogimg"}

When the (scrolled) content is nowhere near the end, show the indicator. Otherwise, hide it.

Demo{:class="blogimg"}

If you’re using a ListView control, you can do that easily by utilizing the ItemAppearing event. If the last item has appeared, hide the scroll down prompt.

However, if you’re using ScrollView control, there are no ItemAppearing event. But you can achieve the effect using Scrolled event.

How it’s done:

<script src="https://gist.github.com/xyfoo/93318427cb1394de49475b7d76bf80df.js">

Here we have a Grid, which have a ScrollView and a Label. The ScrollView have a bunch of BoxView with differing color, and the Label function as the scroll down prompt.

Grid allows layering of controls by Z-level (which you can alter by moving the control up-down the XAML tree), and by putting both controls in the same space, the Label will appear on top of the ScrollView.

In the Scrolled event handler (in the code-behind file), we do the following:

<script src="https://gist.github.com/xyfoo/f401238720c487dcd9cc444eebe325ad.js">
  • Line 3: First we calculate the amount of space available for scrolling.
  • Line 5: If the user haven’t scrolled past the available space (by reading ScrolledEventArgs.ScrollY), we can deduce that the user haven’t reach end of ScrollView. If so, displayed the scroll down prompt.

The calculation above won’t work all the time, because Xamarin.Forms is not meant to be a precise pixel-perfect platform, and there would be some slight variance in the value reported by the UI. Case in point, you may encounter that the ScrollY will always be smaller the SpaceAvailableForScrolling, even if you have scrolled to the very end.

To counter this variance, we declared a buffer of 20 in line 4, and add it to the returned ScrollY value for calculation. You can change this buffer value to anything you want, the larger it is, the earlier the ScrollDownPrompt will disappear.

And that’s it! A simple solution for a simple feature.

]]>
<![CDATA[There’s a request from a customer to have a scroll down prompt when the content is too tall to be displayed in a single screen height. Pretty much like what you normally see in a lot of website:]]>