目前分類:學習雜記 (6)

瀏覽方式: 標題列表 簡短摘要

  最近看到一段程式碼,寫法是大腸包小腸的For迴圈寫法,意思就是一個For迴圈內又包一個For迴圈,而這段程式主要是在比對大迴圈的值,是否存在於小迴圈內或是那個位置.


ex :


for (int i = 0 ; i<strArrayA.Length ; i++)


{


    for (int z = 0 ; z<strArrayB.Length ; z++)


    {


         if (strArrayA[i].Equal(strArrayB[z]))


         {


                  do something.....


                  break;


          }


    }


}


  之所以會勾起過去的效能問題,主要是過去有遇到一段難以忘記的效能問題寫法,跟這個做法有點相似,但這寫法在資料量少時,感覺不太出來,但資料量一多加上硬體設備沒那麼好時,整個效能問題的感覺會更加明顯,不過之前遇到的問題寫法有點不同,它是在大的For迴圈內,用一個DataView的RowFilter在過濾資料.用意也是一樣,從大迴圈的值,看是否存在於DataView內.


ex :


foreach (string stra in strArry)


{


    DataView1.RowFilter="UserKey ='" + stra + "'";


    if (DataView1.Count>0)


    {


         .....do something.


    }


}


  看起來似乎沒有什麼問題,而當初在寫這段程式時,預計這作業的功能運用,stra最多不到百筆,DataView也是一樣,但事與願違,事後使用者將其"發揚光大",資料量多達萬筆,這時就明顯的感覺到效能的差異,尤其一般end user的電腦設備沒有我們的好(有些使用者的電腦只有256MB的Ram...),所以他們的感覺更深刻,所以我被罵到臭頭(雖然這段也不是我寫,但這後來由我接手),但前一手會這麼寫也是正常的,如果是我,可能也是會這麼寫,所謂不經一事,不長一智,著手去測試觀察時,發現程式在跑這段時,記憶體會狂升,所以end user記憶體不大的情況下,就會跑page file,效能就更差了,就有位使用者反應,中午先點下去跑,中午吃完飯,睡個午覺,下午就可以用了.聽起來很誇張,但實際還真是如此,因為又加上網路頻寬的不足(2m/256K,8人共用),說真的,沒有發生這件事,還真的不知道RowFilter在這情況下,會有這樣的結果.


  後來改了寫法,不用RowFilter,記憶體就沒升的那麼誇張,效能忘了有沒有差到10倍以上,但可以確定的是差很多.而第一個例子的大腸包小腸的兩個for迴圈寫法,是這次看到的,其實我不是很喜歡這種寫法,如果要這麼做,就要考慮到迴圈的次數等問題,雖然例子內有用到break,減少了迴圈次數,但仍覺得不好,這時想到的是Array.IndexOf的做法來取待小迴圈.


ex :


int tmpIndex=0;


for (int i = 0 ; i<strArrayA.Length ; i++)


{


    tmpIndex = Array.IndexOf(strArrayB,strArrayA[i])


    if (tmpIndex >-1)


    {


           do something.....


     }


}


  程式碼看起來變少,但因為DataView的RowFilter經驗,不知道這樣的效能會不會變的更差,於是寫了一個Unit Test比較兩種寫法的效能差異,結果用Array的方式還不錯,效能比用大小腸的好,沒有RowFilter的問題發生,但要感覺出兩種的差別,也是要資料量大及設備差才明顯,不然也是根本就感覺不出來.


  很多在Coding的時候,有些地方根本不會想到資料量大後的影響性,比如說在寫一個TreeView的功能,當初設定的的node並不多,最多也不過百筆,但後來使用者的應用方法超出當初設計時的規劃,node超過萬筆,這就可怕了,不只耗效能,使用者也很難從這TreeView中找到所要的資訊,這時所challenge的還有UI操作的便利性,系統的效能下降,使用者操作的效能也變差.


 


效能的改善是一段無止盡的路~

jeffyeh 發表在 痞客邦 留言(0) 人氣()

最近有遇到一次怪狀況,上網上到一半,突然跳出Adobe Reader的更新訊息,發現有8.0,要我升級.


正想要更新時,突然想到,不對啊,我的本來就是8.0了.....


就把那個更新視窗給關了,單獨開Adobe Reader的程式看看.


結果更新檢查完後,並沒有發現新版....


如果剛剛就按下更新,或許就這麼把病毒裝了起來了吧.


台灣電腦網路危機處理暨協調中心(TWCERT/CC)也看到同樣的訊息警告.


有一篇2008.3.10發表的,主旨是盜取帳戶密碼 又見釣魚郵件


於Yam中,有更詳細的報導.盜取帳戶密碼,又見釣魚郵件


其手法也類似我所遇到的情況,可見現在的手法已經不見得是偷偷的入侵.


可能以假的訊息,讓你誤以為真的放它進來.


也是充份的利用大部份的人對某些訊息都會跳過的心態.


還有一些假的網站,長的還真像XP的網站,告知使用者你的電腦中毒了,要立即掃描清除,或是安裝網站提供的防毒程式,按下確認後,就開始安裝一些元件,而那些元件就是木馬.


但如果仔細想想的話,最好是剛到那個網站,那個網站就發現電腦中毒了,沒有掃過電腦裡的檔案,馬上就發現,那可謂當今世上最快的掃毒程式,而且還是Web版的,有這種網站,真不該這麼的没没無名,應該在各大新聞都看的到世紀掃毒技術革新.


雖然google大神的查詢真的很好用,但也有不少人想辦法利用它來讓一些人誤入假網站.


只能說,網路愈方便,自己就要愈小心.


 

jeffyeh 發表在 痞客邦 留言(1) 人氣()

話說,兩家肥皂工廠為了檢查是否有空盒的沒裝肥皂的流出去.


甲工廠花了鉅資,買了一台X光檢測儀,使用高科技的方式檢測,如果發現空盒,會有機器手臂將其夾起. 但因為精密儀器,每段時間都要再花一筆錢檢測,避免產生誤判.


乙工廠就沒有甲工廠那麼的資本雄厚了,買不起X光或機器手臂,最後買了一台電風扇,甲工廠不得其解,一台電風扇怎麼解決這個問題,而且效果一定比不上他的高科技設備.


乙工廠就把電風扇放在流水線的一邊,對個流水線上的肥皂盒吹,如果沒裝肥皂的,會比較輕,就會吹下流水線,掉到不良品的箱子去. 而電風扇也很好維護,又不耗電.


甲乙工廠同樣都解決了空盒的問題,但所付出的成本相差甚多.


這個問題就像平時我們在解決問題,解決方式有很多,但我們所選擇的是否是最好的?


前段時間跟某些同仁聊天,同仁很期待BI上線,覺得BI能做很多分析,所以他們可以怎麼樣又怎麼樣.


但總歸同仁的一些想法,其實有6成左右的分析需求,似乎用Excel就好了, 用不到BI這東西.


感覺就像甲工廠一樣,未來為了維護BI,勢必又要養一群人及一堆設備.


做了三年的程式設計師,或許我是從其它職務轉進來的關係.


我一直覺得這不過是工具,怎麼會有一群人被工具牽著鼻子走的怪現象.


把自己的工作能力價值降低,系統沒有這個功能,人就沒辦法工作了.


我們能運用其它的方法來解決啊,怎麼都在等.


如果乙工廠想要跟甲工廠一樣的設備,那不就要等資金夠,或借錢去買設備? 那這段時間工廠要怎麼生存? 會不會在資金還沒存夠時,就倒了?


但我相信,能提出甲工廠那樣解決方案的人一定很多,就我所遇到或聽到的一些顧問,有不少都是此類型的,提出來的建議有些像產品推銷員.不然就像潮流的追隨者般的Power User或"學者". 但能提出乙工廠解決方案的人並不多,對我而言,這類型的人員才能算是Professional.

jeffyeh 發表在 痞客邦 留言(1) 人氣()

最近在商業周刊看到一篇文章,內容挺讓人玩味的.



[看問題的態度,決定企業轉型成敗]



看完後,就想到過去每次發生問題時,所有主管的第一個反應是什麼.


有幾個反應在啇周的文章內,確實也有發生過. 例如 :


[急於找兇手定罪] 急於找出是誰做的,要他負責,但問題卻沒先著手處理. 我想,這種人可能平時推責任推習慣了,出問題時,急於把責任撇清,證明此時與自己無關. 更差的,還會落井下石.


[遇問題就亂手腳] 發生問題時,如驚弓之鳥,大腦無法冷靜下來,一直不知道要怎麼辦. 如果這情況發生在主管身上,那就慘了,部屬已經很緊張了,你還在讓大家更緊張,反而沒有使大家冷靜下來判斷.


[避風頭+事後軍師] 問題發生跟處理過程中,都沒出現也沒出聲,等大家處理完,才出來問說什麼事,再來提出自己的個人見解與做法. 可惜時效已過,您的見解無法驗證.


[全體一窩"瘋"] 不管問題的大小,問題的可能屬性,反正都會一口氣招集所有的人過來一起處理.


[問題複雜化] 有些人可能天生苦命慣了,不相信這世上不會每件事都那麼簡單,硬是把它想的很難,一直著手在"進階"的問題上,而乎視"簡單"的狀況. 所以可能花了很久的時間在檢查"進階"的問題,好一點的,會回頭看"簡單"的,差一點的,跟上級反應,這可能要請上游廠商協助. 記得有次老婆跟我反應,他們家的ERP連不上,聽了大概描述後,判斷要先檢查網路連線問題,結果他們家的外包電腦公司說不可能,花了一個上午在檢查,下午才修好,檢測結果是,網路線鬆了,沒插好.


種類還有很多,但一時之間無法一一列出,但覺得很有趣,什麼樣的人,才具有"解決問題"的能力.


怎麼去發現問題,解決問題,防範問題. 當有這能力時,那還有什麼問題~


Are you going to be a Trouble-shooter or Troublemaker?

jeffyeh 發表在 痞客邦 留言(0) 人氣()

最近在寫一些工作上要用的的程式,不只是ERP,也有一些是輔助系統管理的工具,寫著寫著,突然間覺得,手頭上的工具其實也是很可怕的東西,如果被亂用,其實跟木馬程式沒什麼兩樣.


原本設計用意是在監控遠端系統是否正常,並遠端透過自己寫的程式介面下指令去獲取資訊,好解決系統問題.


但寫到一半發現,如果這工具是給到心存不良的人使用,那就可怕了,原本的善意就變為惡意,好好的工具變為木馬或僵屍. 如果可以任意從遠端下指令給本機執行,那還有什麼不能做?


所以這工具就此中斷,沒有再繼續下去.


這時就想到,技術真的是兩面刃,可助人也可殺人,而決定權在握刀的那個人.


就算做到再好的防護,總會有人想辦法找出漏洞,並利用它來進行攻擊.


在網路發達的時代,很多新的軟體出現,如P2P,線上影音撥放等.


科技運用的愈來愈普及,資訊安全將會更為複雜及多樣化.


這也是為什麼防毒系統已經不夠用了,還要細分防駭,防火牆...等.


防的愈多,效能效差,所以大概也能理解,為什麼Vista的效能評比不如XP.


微軟的開發工具已經大量的減少開發人員的工作量.可以寫出來的工具功能更加廣泛.


或許這時開發人員所要思考的不單純是好不好用,更應思考安不安全.

jeffyeh 發表在 痞客邦 留言(0) 人氣()

有些事情久了,沒再去動它,就會漸漸忘了,幾年前曾在美國念語言學校,離開前的最後一篇Research Paper, 將它放在這,讓自己永遠記得,過去也曾經有過.


 



Disadvantages of DVD Protection


 


 


Thesis: Computer companies shouldn’t develop the new anti-copy method for DVDs because it will increase cost and because it is not user-friendly for customers. Also, it is futile.


 


I.      Expensive


A.     CSS license


B.     Using DVD


II.     Not user-friendly


A.     Checking CD


B.     Unlock CD


C.     Limit player


III.   Futile


A.     Clever thief


B.     New technology


C.     Rich Internet


 


 


 


DVD Protection 1


 


 


 


 


 


 


 


 


 


 


 




 


Disadvantages of DVD Protection


Yeh, Cheng-Chieh


Intensive English Language Institute


University of North Texas


July 10, 2002


 


 


 


 


 


 


 


 


DVD Protection 2


Disadvantages of DVD Protection


       Since DVD (Digital Versatile Disc or Digital Video Disc) was invented, it has become an important method of storage. DVD can save more data than VCD (Video Compact Disc). When we watch movies, DVD quality is better than VCD quality. DVD can save music, movies, and data. Also, we can use it in DVD player and computer. In fact, because of high technology, some people can use computer to copy data from DVD in order to save money or backup data. Many companies can’t earn much money, so they have developed a new anti-copy method, called CSS (Content Scramble System), is discovered by DoD (Drink or Die) and MoRE (Masters of Reverse Engineering). Because VCD doesn’t have any anti-copy method, people can copy easily. Today many companies use the new anti-copy method which is called CSS to stop illegal transfer. However, it will give customers some bad effects. Companies shouldn’t develop the new anti-copy method for DVDs because it will increase cost and because it is not user-friendly for customers. Also, it is futile.


The reason why companies should not develop the anti-copy method for DVDs is that anti-copy method will increase cost. If companies want to use CSS to protect their products which are saved in DVD, they need to get CSS license in order to use the anti-copy method. Only a few U.S. or European chip companies, who developed


DVD Protection 3


the DVD standard, have a CSS license to manufacture and sell CSS. Also, they have the master key which can decode CSS. If DVD players don’t have the master key, the DVD players can’t read DVD which has CSS. (Yoshida, 1997, 16). Not only is the new anti-copy method a problem for customers, but also it is a problem for manufactures that produce DVD player. Block (2001) said, “DVD title developers who operate legally have to pay royalties to both content owners and DVD technology patent holders. These royalties typically add up to several dollars or more per disc” (13). Therefore, customers have to pay more money for the new anti-copy method. “DVD copy protection is more expensive than our retail price on the games. The sales in the DVD-ROM category are also not high enough to justify the time and expense of adding copy protection measures to the releases” (Block, 2001, 12). People have been using DVD player for a few years. Because of the new anti-copy method, some older DVD players can’t read the DVD which has CSS. However, many companies don’t care about that because they just want to stop copying so that they can earn more money. One customer suit claims copy protection constitutes an unfair business practice. She could not play or copy the CD on her PC and instead had to provide personal information in order to download encrypted song files (Thorsberg & Spring, 2002, 11). As a result, if she wants to


Protection 4


play the CD, she has to buy a new DVD player which has CSS license. In the future, if companies develop a new DVD anti-copy method again, customers will need to buy a new player again.


        The second reason is that if companies develop anti-copy method for customers, customers will need to learn how to use it because it will not be the same as older method. It is not user-friendly. Many customers have had some bad experiences about the anti-copy method. For instance, PC games use a lot of different anti-copy methods, such as password and checking CD. When a game is played, the copy protection technology checks to see if the original CD is in the drive. If the original CD is not in the drive, the game can not be played (Block, 2001, 15). Because DVD can save more data than VCD, some companies try to place more games on a single DVD. One company, Greenleaf Technologies, made a new system. The system can save up to 10 games on a single DVD, but the data is scrambled into an unreadable format until a consumer pays to unlock each game at the publisher’s Web site, and then consumer can read and play it (Block, 2001, 24). Some music companies try to use a new anti-copy method to protect their products, but they give their customers some problems for using their products. For example, BMG, Sony, and Universal all confirm they’re testing copy protection on several sample and


DVD Protection 5


promotional CDs, but customers didn’t know that. When customers use PC to play music, Windows PCs could not read it (Thorsberg & Spring, 2002, 7). SafeAudio’s


protection scheme inserts small distortions that standard CD players filter out. CD-ROM and DVD-ROM drivers can’t block those distortions, so if you use your PC to play, rip, or burn such CDs the music will hiss and pop. Other technologies hide a CD’s table of contents, so your CD-ROM can not read it (Thorsberg & Spring, 2002, 9). Therefore, the new anti-copy method will give customers a lot of trouble. Even though customers paid the money for using their products, customers are still like thieves.


        Third, companies should not develop the anti-copy method because it is futile. In fact, because of Internet, people can get information more easily. People can watch movies, listen to music, read news, and get some information from Internet. Also, people can get some passwords that is a key to lock your program from Internet. “… Would do nothing less than encourage misappropriators to post the fruits of their wrongdoing on the Internet as quickly as possible and as widely as possible, thereby destroying a trade secret forever. Such a holding would not be prudent in this age of the Internet” (Cundiff, 2002, 8). CSS had protected DVD for a short time before DeCSS was invented. The DeCSS program which can copy an


DVD Protection 6


encrypted DVD file to a hard disk. No anti-copy method can protect all software forever. “A system to protect secrecy does not become unreasonable simply because


a clever thief finds a way to penetrate the security” (Cundiff, 2002, 9). Even though companies can develop a new anti-copy method again, people can find a way to penetrate the security again. “When rewritable DVD drives appear, you will be able to copy DVD discs as easily as copying an ordinary floppy disk” (Wang, 2002, 11). Therefore, the anti-copy method just gives customers some using problems. It can’t protect anything.


        In conclusion, companies try to develop a new anti-copy method to protect their products, but they still can’t find a perfect anti-copy method. The anti-copy method just increases cost and gives customers some using problems. Moreover, it is futile. I think the only way, which companies can do, is changing customers’ habit. If customers did not want to copy or use illegal products, companies wouldn’t need to develop any anti-copy method. However, if customers wanted to copy or use illegal products, companies could not stop them. Companies will still develop a new anti-copy method, and customers will still find a way to copy. It will be a big challenge for both of them.


 


DVD Protection 7


References


Block, D. G. (2001, June). Paying for protection. EMedia, 14(6), 58. Retrieved June


24, 2002, from EBSCOhost database.


Cundiff, V. A. (2002, May 13). Protecting sensitive computer codes. New York


Law Journal. Retrieved June 24, 2002, from EBSCOhost database.


Thorsberg, F. & Spring, T. (2002, Jan). New shackles on your CD, video copying.


PC World, 20(1), 20. Retrieved June 24, 2002, from EBSCOhost database.


Wang, W. (2000, March). Cracking DVD. Boardwatch Magazine, 14(3), 134.


Retrieved June 24, 2002, from EBSCOhost database.


Yoshida, J. (1997, May 26). Copy-protect logjam stalls DVD-PC debut. Electronic


Engineering Times, (955), 1. Retrieved June 18, 2000, from EBSCOhost


Database.

jeffyeh 發表在 痞客邦 留言(0) 人氣()