Total Pageviews

2012/10/07

Coding Guidelines for the Developer During Development


1)Do use the Transactions in long running queries and many small-small queries

2)DON’T Use SELECT *

3)Avoid explicit or implicit functions in WHERE clauses

4) Avoid long actions in triggers if using

5) Use temporary tables and table variables appropriately

6)As a good rule of thumb try to replace all sub queries with joins

7)Order of Tables in Join Conditions.

8)Loop optimization

9)Parameter sniffing

10)Can use Fixed Index Hint while using the conditions

11)Size the data type wisely in the SP during declaration.

12)Efficient use of MAXDOP setting within query.

13)GROUPING SETS in SQL 2008

14)Always use the With rowlock, with no lock where occurring deadlocks.

15)Use Update From Rather than simply Update

16) UNION ALL instead of UNION

17) Avoid expensive operators such as NOT LIKE


http://phpflow.com/misc/coding-guidelines-for-the-developer-during-development/

2012/09/26

如果你的薪水是別人給你的,你就是可以被取代的


理財專家給薪水族的忠告:如果你需要拿錢回家養家,那麼一定要遵守。如果有人養你,則另當別論。

記得以前有位同事離職前多拉了幾個人走,以為會對公司的業務造成影響,經我觀察的結果做了結論:完全沒有影響,缺人找人,頂多資深員工辛苦點,對公司來說,「所有員工在職時都很重要,離職後都不重要」,沒有一個員工是非留不可的,這似乎就是職場常態。

近20年以來,我長時間在美台兩地以理財專家的立埸談理財,幫助客戶及社會大眾做好理財。我常強調做好理財的目的是錢盡其用,讓錢發揮最大的效用,一個相關的重要原則就是凡事講究划算。

我覺得以這樣的現實觀點來看工作,和我倡議的『回到蠻荒』觀點倒是有相通的地方,那就是不做徒勞無功的事,或沒有成果的事。蠻荒的動物都能秉持這樣的原則工作。所以依現實的原則看工作,現代人工作的目的應該只是為了能賺錢,除此以外無他。

以下是探討這類觀點的專家所提供的一些工作原則,不妨做為參考:

原則1:工作真的只是一份工作

不要期待工作與生活能兼顧,事實上也沒幾個人能將工作與生活成功的整合起來,工作並不是生活,我們工作是為了要過生活,或保有自己所喜歡的生活。想想看,你一天或一個禮拜能有多少時間和家人相處,或和親朋好友去做一些你喜歡做的事,就可以知道要兼顧工作與生活是不可能的。

工作只是工作,目的是為了賺錢。錢只是一個工具,讓您換得食物、衣服、車子、房子、休閒育樂…換得「成就」…而「成就感」必須從個人所做的學習與事物中得到價值和肯定..


原則2:不要害怕換工作

工作既是為了賺錢,只要可能賺更多錢,或做起來更愉快、更有滿足感,何妨就換工作?而且,以這樣的原則換工作,收入當然會越換越多,跳槽可能也會變得稀鬆平常。要每次工作時都全力以赴,有稱職的表現,對雇主和業界都能交代,應該隨時可以找到下一個工作機會。但站在生涯規劃的觀點,要思考的不只是下一份工作,而是下下一份工作在哪裡。其如果已經三十歲以上,更應該將目標放在提早規劃四十歲以後的人生,就會知道自己該做好什麼準備。


原則3:一鳥在手勝過十鳥在林 

很多公司都聲稱他們有優渥的福利制度,包括退休金計劃。可是不斷有事實告訴我們,越來越多的人在屆滿退休之前就失去工作了。所以爭取眼前的福利可能更實際,比較值得期待,例如包括健康醫療保障在內的團體保險、托嬰照顧、親職休假、績效獎金的分發,增加加班費或年終獎金等等。

更值得思考的是---這份工作你能做多少,或是說---老闆會讓你做多久?然後呢?


原則4:謀生本事不厭其多

新世紀的工作與收入可能會變得不穩定,產業的興衰或輪替也會變得快速無比,在同一家企業內辛苦一輩子可能會以失業收場。所以橫向拓展各方面的技能,會比縱向的在企業的組織內向上攀爬追求位高權重還要實際。

其實現在已有不少企業也『學會』了一些聰明的技巧,對授予好聽的高階職位並不吝惜,可以讓你擁有耀眼的頭銜,但對薪資增加並沒有多大幫助。與其追求這種虛名,不如讓自己能具備十八般武藝可以多方面賺錢,隨時跳槽。
充實自己的技能讓自己無可替代,或者在風險控管下,掌握機會自己創業,才是M型社會生存王道!


原則5:做好份內工作就回家去

再提醒你,工作只是工作,公司少了你一個人的工作,照樣可以運轉下去。踏實的學習你的工作所該具備的技能,努力做好你的工作,但不要奢望你可以憑一己之力多為公司創造多少業績或產能。

不要因此耗掉你大量的私人時間,讓自己從盲目工作中抽離出來。記住,做好自己份內的工作,然後回家去。說真的,在老闆的眼中,你真的沒有那麼重要!面對現實吧!


原則6:遠離辦公室政治

你工作的目的是為賺取合理的收入,而不是追求虛名與權位,所以不用在心思在辦公室政治上。當紅炸子雞可能因改朝換代而去職走路,被冰凍的失志衰老也可能鹹魚翻身。與其耗費時間介入這些無意義的辦公室鬥爭,不如多花時間在自己的家庭。好好為自己的人生規劃準備才是最重要的。

2012/09/20

10種不跟也罷的老闆

  1. 別跟那些沒有個人生活的老闆
  2. 別跟那些總是遷怒於你的老闆
  3. 別跟那些總是扮演搞笑角色的老闆
  4. 別跟總是掙扎求生的老闆
  5. 別跟那些總是誇誇其談的老闆
  6. 別跟那些總是和你爭的老闆
  7. 避免那些總是說個不停的老闆
  8. 別跟那些總是忙忙碌碌的老闆
  9. 別跟那些沉迷於聲色犬馬的老闆
  10. 別跟那些能活吃了你的老闆

http://www.life.com.tw/index.php?act=view&news_no=7322&t=1348128394

Failed to Apply Thousand Seperator / Text Pattern

Problem
I had set the text pattern to "#,##0", but it is not working.

Here is the setting in iReport


But it does not work as expected.

Solution
The root cause result from the expression class of this text field is java.lang.String. As I change to java.math.BigDecimal. It works now.



2012/09/17

8 Common Code Violations in Java



  1. Format source code and Organize imports in Eclipse
  2. Avoid multiple returns (exit points) in methods
  3. Simplify if-else methods
  4. Do not create new instances of Boolean, Integer or String
  5. Name public static final fields in UPPERCASE
  6. Combine multiple if statements into one
  7. switch should have default
  8. Avoid duplicate string literals, instead create a constant

http://www.dzone.com/links/r/8_common_code_violations_in_java.html

2012/08/23

Best Practices to Make Life Easier for the Programmer


Constants
Should you ever need a variable that is not changing over time (or in many cases just one time), you should use constants. Constants are quick-to-find variables and they help you minimize memory usage.

Configurations
The term ‘configuration’ means variables that are used a lot and rarely change but can be changed in the middle of execution, if needed. Constants can be made as configurations if it can be changed in the middle of execution. Otherwise, leave it as a constant.

Access Control
So many programmers don’t care about access-level modifiers. If you need broader access, use protected and, as a last resort, public access. This way you can protect your specific method or member from the ‘outside world’.

Comments
Comments let you remember code snippets, algorithms, sort methods, even randomized numbers you’ve created before. This is a big advantage if you’re working on a team. Because of comments, other people will understand your intentions.


http://architects.dzone.com/articles/do-not-delete-common

2012/08/13

2012/08 神戶京都之旅


風見雞館

北野異人館街一隅

北野異人館街的星巴克

Kobe Tower

神戶港夜景

Kyoto Tower

琵琶湖煙火

伏見稻荷神社

藝妓回憶錄拍攝場景

奈良公園

宇治川煙火



2012/07/27

Clear IE Cache Through Command Line

Scenario
Owing to Microsoft IE will cache JavaScript, CSS files, so it may not recognize when we update JavaScript or CSS files. 
We need to clear browser cache every time, when we update JavaScript or CSS files.

Solution
Windows provides command line to clear IE cache
  • All : RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 
  • History : RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1
  • Cookies : RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
  • Temp Internet Files : RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
  • Form Data : RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16
  • Passwords : RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32
We need to clear cookies and temp internet files, so we copy the two commands into text file, and save as a bat file. Then move to C:\

And create a shortcut on your desktop.

As you need to clear browser cache, just click the batch file. It will clear cookies and temp internet files automatically.



青年拒絕窮忙!主管最浪費員工的7大症狀


1. 在不同專案間調動人力,或不斷換人處理專案。
2. 缺乏適當規劃所造成的浪費。
3. 每次救火都會產生浪費。
4. 超時加班導致浪費。
5. 當專案變調或取消,就會產生浪費。
6. 士氣低落所導致的浪費。
7. 多工也會造成浪費。


http://topic.cw.com.tw/500/magic-1.aspx

2012/05/29

What's difference between an empty string and a null value

Question: What is the difference between an "empty" value and a "null" value? 
Answer: An empty string is treated as a null value in Oracle.

Demo
NIGT013.COLL_B_DATE is null, and apply NVL2 to  substitute a value (i.e. empty string) when a null value is encountered.

But it showed null value in report. It results from an empty string is treated as a null value in Oracle

Therefore, in order to show non-null value in my report. Substitute two spaces when a null value is encountered.

Then it won't show null value in report anymore.

2012/05/22

7 Application Deployment Best Practices


  1. Keep the installation structure SIMPLE. 
  2. Always get rid of old files. 
  3. Automate it 
  4. Don’t over do it with the symlinks
  5. Delete everything first. 
  6. Have a roll back strategy.
  7. Don’t make changes to your deploy mechanism or deploy scripts between deploying to different environments. 

2012/05/15

Top 7 programmers bad habits


1. The all code is crap, except mine, attitude.
2. The “I fix that in a second” catastrophe.
3. The “That will only take a second” misconception.
4. The ego spiral.
5. “It wasn’t me!”
6. The demotivated genius.
7. The premature programmer.

2012/04/16

10 project management lessons from the Titanic disaster


1: You need to know what you’re measuring
Frederick Brook says, milestones should be objectively measurable. If you do not have valid measurements for your project, you will run into problems.


2: Assumptions can kill you
Maybe we assumed that a particular system was using a newer software release than it actually was. 
Maybe we assumed that another department would take care of ordering cable.
Maybe we assumed that the vendor received our critical email message. 
Assumptions are important in your work, but if you proceed on the basis of them, make sure everyone is clear about what assumptions you are making.


3: Distractions are dangerous
If enough members of your team encounter enough distractions, your project will gradually fall behind.


4: Little things add up
The small delays are just as critical as the large ones, meaning that adherence to milestones is critical to the success of a project.


5: Stakeholders should be kept informed
Our stakeholders need to know about the status and progress of your project. Keeping them informed will keep them happier.


6: Other people’s perspectives matter
If a client asks a question, try to see beyond the question itself to the motivation behind the question. 
If a technical person is explaining a function of a system or program, make sure the explanation avoids jargon. 
Clear communication will lead to happier clients.


7: Moving targets can hurt you
Any change is rarely “small.” Rather, it typically involves changes to other parts of a system, results in greater complexity, and requires more testing.


8: Traceability is essential
How familiar are you with the strategic objectives of your company? 
Can you find a logical connection between the requirements of your project and those strategic objectives? 


9: Methodology is more important than technology
You might want to use sophisticated planning and tracking software and tools. 
More important, though, is that your plan be solid. 
The best software in the world will not save a poorly designed plan.


10: Documentation may have lasting benefits
Documentation is often the most important part of the project because it may exist long after the project team has disbanded.


http://www.techrepublic.com/blog/10things/10-project-management-lessons-from-the-titanic-disaster/3174

2012/04/13

Becoming A Better Developer

  • Motivation
    • If you’re not growing, you’re dying…
  • Confidence
    • Good developers are usually quite confident in their abilities. Why? Because they know that they have put in the effort to truly understand what they are talking about. Be confident in what you know.
  • Choose Concepts Over Implementations
    • If you understand the concepts, that enables two things. 
      • First, you can use those concepts in other languages with ease. But far more importantly it lets you think abstractly about different ways to solve a problem. 
      • It also lets you learn from other communities. So rather than waiting for somebody else to solve a problem in your language, or looking for help in your language, you can look anywhere for help. 
  • Read At Least One Book per Week (well~it's very difficult for me >_<)
    • There are two main things that you’ll benefit from with this approach. 
      • First, by reading actual books, you’ll focus on exploring a concept in depth.
      • The second advantage to the one-book-per-week approach is that it will make you push your boundaries. 
  • Share Your Knowledge
    • The best way to learn is to teach.
  • Become a Mentor
    • The important thing is to look at the mistakes they are making and help them to understand why they are making the mistake. The obvious benefit here is that you are “paying back” the community and investing in the future of the industry.



For complete information : http://blog.ircmaxell.com/2011/11/becoming-better-developer.html

2012/04/12

Apache Commons應用 - CollectionUtils

Requirement
報表輸出結果,應該依序輸出「營業事業所得稅」、「綜合所得稅」、「遺產稅」、「贈與稅」、「貨物稅」、「菸酒稅」、「證券交易稅」、「期貨交易稅」、「營業稅」、「特銷稅」。如果沒有資料,該稅別要顯示出來,數字要顯示0。結果如下,


根據user requirement要求的輸出結果,並不是按照tax code或者tax name的筆劃順序進行排序,此部份必須要根據query回來的的結果來做加工。

Problem
原本的作法是用SQL將統計資訊算出來,但是其只會傳回有存在的資料,若沒有符合條件,就不會回傳資料,故只有回傳兩筆資料。

從SQL回傳回來的結果會是一個List of value object,以目前的條件,只會有兩個value object,分別是「營利事業所得稅」與「期貨交易稅」。


Solution
由於資料固定只有10筆,放在SQL裡頭做的話,SQL會很複雜,日後維護不易,故此部份的資料加工放在AP端進行處理。
  1. 建立一個新的List物件, List result = new ArrayList();
  2. 根據回傳回來的list of value object來進行判斷
    1. List中是否有「營業事業所得稅」的資料
      • 若「有」,從List中找出該object,並add到新的List物件
      • 若「無」,add一筆空的資料到新的List物件
    2. List中是否有「 綜合所得稅 」的資料
      • 若「有」,從List中找出該object,並add到新的List物件
      • 若「無」,add一筆空的資料到新的List物件
    3. List中是否有「 遺產稅 」的資料
      • 若「有」,從List中找出該object,並add到新的List物件
      • 若「無」,add一筆空的資料到新的List物件
    4. 「 贈與稅 」、「 貨物稅 」、「 菸酒稅 」、「 證券交易稅 」、「 期貨交易稅 」、「 營業稅 」、「 特銷稅 」依此類推

Apache Commons有提供CollectionsUtils此API,其提供不少utility method來針對Collection物件進行一些處理,根據以上需求有兩個:

  1. 從List中check是否有存在特定的object
  2. 從List中取得特定的object

//List中是否有「營業事業所得稅」的資料
1:  private static boolean is35Exist(List list) {  
2:      return CollectionUtils.exists(list, new Predicate() {  
3:        @Override  
4:        public boolean evaluate(Object obj) {  
5:          NIG630ReportBean bean = (NIG630ReportBean) obj;  
6:          return "營利事業所得稅".equals(bean.getTaxNm());  
7:        }  
8:      });  
9:    }  

//從List中找出該object
1:  private static NIG630ReportBean find35(List list){  
2:      return (NIG630ReportBean) CollectionUtils.find(list, new Predicate() {  
3:        @Override  
4:        public boolean evaluate(Object obj) {  
5:          NIG630ReportBean bean = (NIG630ReportBean) obj;  
6:          return "營利事業所得稅".equals(bean.getTaxNm());  
7:        }  
8:      });  
9:    }  





Stop Redeploying in iReport Development

Context
以下是本案的project structure:


所有的jrxml放在jasperreports folder中,當jrxml有異動,處理程序如下:
1. 執行maven build
2.  將jrxml compile成jasper file會搬到nig-web\src\main\webapp\WEB-INF\classes\META-INF\jasperreport
3. 包成ear file
4. deploy到application server

Problem
在用iReport開發的時候,最浪費時間的部份,就是在我們無論做任何的細微的修改,如果要看到修改後的結果,都要將jrxml compile成jasper,然後redeploy到application server,此過程曠日廢時,浪費許多寶貴的開發時間。

Solution
Step1. 打開iReport工具-->工具--選項

Step2. iReport--> Compilation and execution--> unchecked "Use Report Directory to compile"-->將「nig-web\src\main\webapp\WEB-INF\classes\META-INF\jasperreports」貼進 "Compilation directory"-->click 「確定」按鈕

設定完成後,當我們在iReport Designer做任何異動,click "Compile Report" button,iReport會自動將jasper file搬移到指定目錄,application server會自動抓到最新的jasper file,不用再rebuild and redeploy了。





iReport print when expression 應用

Requirement
在報表呈現的內容,每筆資料之間,需要有間隔的虛線如下

Problem
原本iReport designer中的作法,是將line放在detail band中的fields下方,screenshot如下:

但是此舉,在最後一筆資料,也會出現分隔線,此結果不合理。

Solution
step1. 將分隔線放到detail band的fields上方,如此一來,列印順序是line-->data-->line-->date-->line-->data,以此類推

 step2. 由於列印順序是line-->data-->line-->data-->line-->data,為了滿足需求,只要讓第一次出現line的時候,不要讓顯示出來就好。此時,click line,並在attribute視窗中的print when expression輸入條件,當是第一筆的時候,不要印出line,從第二筆資料開始即可。


2012/04/08

Project Manager and Subject Matter Expert


對於project manager這個角色,到底需不需要有技術能力,一直是常在爭論的議題。
這篇文章倒是給了一個不錯的答案:『有會更好』


他提到了,如果是technical project manager可以帶來幾個好處

  1. 遇到問題的時候,他更能掌握問題的難度,更能掌握要花多少時間來解決這個問題,對於時程的掌握會更踏實
  2. 你對於你的團隊更有同理心,因為你知道問題的難度。project manager總是想急著解決問題,常會脫口而出:『這個問題有這麼難嗎?有需要這麼久嗎?』
  3. 由於你有技術的底子,對於某些問題,若有過往的經驗,可以更快找出解決方案,並帶了團隊走向正確的方向,避免花額外的時間去做trial and error

以下是摘錄全文中的部分:

  • Scope and Schedule – If you have a background in the project you are managing it becomes much easier to understand what the project is trying to accomplish.  This helps you in defining the scope of the project and setting the schedule.  You will know roughly how long it takes to build a server, install a circuit, or design a network.
  • Empathy – If you understand the work, it makes it much easier to empathize with the team.  I have built some strong relationships with the network engineers I work with, because they think of me as one of them and not just another project manager.  A project manager should never under estimate the value of relationships.
  • Misinformation and Solutions – You will have a much better sense of when you are getting the wrong information and be able to contribute to solutions.
  • Ramp Up – Most projects start life underfunded and behind schedule.  It is an unfortunate fact of life for project managers.  If you know the subject matter, you will spend more time focused on the project than trying to understand it.  This will save you significant precise time.



全文請看:http://www.cerebellumstrategies.com/project-manager-expert/

2012/04/04

5 Reasons Why Software Quality Matters to your Business


Predictability
Do it once and do it right, and there will be less re-work, less variation in productivity and better performance overall.


Reputation
Some companies have a reputation for building quality software. 
A good, solid reputation is hard to establish and easy to lose, but when your company has it, it’s a powerful business driver. 


Employee Morale
The most productive and happy employees have pride in their work. Enabling employees to build quality software will drive a much higher level of morale and productivity.


Customer Satisfaction
A quality product satisfies the customer. A satisfied customer comes back for more and provides positive referrals. 


Bottom Line
Predictable and productive performance, a stellar reputation, happy employees, and satisfied customers are the formula for a successful software business.


http://blog.smartbear.com/post/12-04-03/5-reasons-why-software-quality-matters-to-your-business/

12 Ways to Become a Better Programmer


1. Read Other People’s Code
Reading other people’s code will allow you to understand different points of view in problem solving as well as introduce you to new techniques. It is important to have an objective to your reading, such as learning a new programming paradigm or how to work with a new API. 


2. Develop Personal Motivation
Being motivated to become better at your chosen profession is an excellent step in the right direction.


3. Get a Mentor
This should be a person that you aspire to be like professionally, that has a background that you can relate to and that you have a lot to learn from. 


4. Learn to Listen
Learn to listen to what the customer has to say, listen to your coworkers when they are discussing the project. Don’t assume that what you think is really what they want. 


5. Gain Confidence
Why are good programmers so confident? They know they have put in the time and effort necessary to truly understand what they are talking about. This knowledge enables them to make the best decisions and be able to discuss or defend them in a productive way when needed. 


6. Join a User Group
hese groups are usually structured around two concepts: teaching and networking. Not only will you be able to learn something new at each monthly presentation but you will gain valuable contacts in your industry that could later lead to internships, jobs or mentors.


7. Read at Least Two Books a Month
By reading books you will be focusing and exploring a concept in depth as opposed to “grazing” on information such as blogs, tweets and other online reading that rarely goes in-depth on a topic. This way, you will be better able to take these lessons and concepts and apply them to the real world.


8. Learn to Use Your Debugger
For some programmers, finding bugs means you did not spend enough time planning or that you have been sloppy during your code writing. Errors in your code should not be taken personally. Humans will continue to make mistakes and that is something we have to accept. Stop looking at your debugger as an evil you need to avoid and see it as a tool you can use to create better code.

9. Never Stop Learning
Over the years the continuous pattern of framework upgrades, version numbers and release dates start to run together but you must keep your skills up to date by evaluating new technology and trends as they are happening. 


10. Share Your Knowledge
The best way to learn something is to teach it to someone else.


11. Learn Keyboard Shortcuts
For programmer this means knowing how to type quickly and accurately as well as know your way around keyboard shortcuts that will make you a faster developer.


12. Learn When to Take a Break
When working on a task such as programming that requires concentration, you will often find that you are making more mistakes or creating more problems when you are tired. Stopping programming is often a better solution when tired than having to fix the mess you made.


http://www.learncomputer.com/12-ways-to-become-better-programmer/