软件开发环境

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

软件开发环境郝宗波haozb3@163.com1.1几个小测试良好的编程风格和坚实的基础知识是良好的软件设计的基础。只有了解底层的基础才能设计出高层次的抽象。以下是几个相关测试。1.1.1关于数据大小的问题structstru1{charc1;shorts;charc2;intI;};请问stru1的大小(Size)是多少?1.1.1关于数据大小的问题(续)structstru1a;printf(c1%p,s%p,c2%p,i%p\n,(unsignedint)(void*)&a.c1-(unsignedint)(void*)&a,(unsignedint)(void*)&a.s-(unsignedint)(void*)&a,(unsignedint)(void*)&a.c2-(unsignedint)(void*)&a,(unsignedint)(void*)&a.i-(unsignedint)(void*)&a);运行1.1.1关于数据大小的问题(续)structstru1{charc1;charc2;shorts;intI;};请问stru1的大小(Size)又是多少?运行1.1.2关于堆栈的问题(1)Voidloop();Voidaddr();Intmain(){addr();loop();}Long*p;Voidloop(){longi,j;j=0;for(i=0;i10;i++){(*p)--;j++;printf(“%d\n”,i);}}voidaddr(){longk;k=0;p=&k;}运行inta=0;全局初始化区char*p1;全局未初始化区main(){intb;//栈chars[]=abc;//栈char*p2;//栈char*p3=123456;//123456\0在常量区,p3在栈上。staticintc=0;//全局(静态)初始化区p1=(char*)malloc(10);p2=(char*)malloc(20);//分配得来得10和20字节的区域就在堆区。strcpy(p1,123456);//123456\0放在常量区,编译器//可能会将它与p3所指向的123456优化成一个地方。}(2)intmain(){inti;inta[10];for(i=0;i=10;i++){a[i]=0;printf(“%d\n”,i);}exit(0);}1.1.3关于指针的问题voidmain(){int*i;allocateInt(i);printf(“*i=%d”,*i);}voidallocateInt(int*i){i=(int*)malloc(sizeof(int));*i=3;}结果是什么?1.1.4哪个访问的速度更快(1)intarray[12][12];intI,J;for(I=0;I12;I++)for(J=0;J12;J++)array[I][J]=J;(2)intarray[12][12];intI,J;for(I=0;I12;I++)for(J=0;J12;J++)array[J][I]=J;1.1.5多线程一定具有比单线程更高的并发性吗?为什么?1.1.6同样数目的多层次的If-else语句和Switch语句哪个执行速度更快?为什么?1.2我们从这门课程中将学到什么?知识.软件设计开发方面的方法和学习能力.我们将集中在对个人开发有帮助的方面(我们不仅能看和听我们更加能作)这门课程也给我们提供了一些未来可能涉及方面的视图。1.2.1知识聚焦:关于编程语言(1)—Object-orientedlanguage,notonlylanuage,butalsothinkinobject.关于软件设计—DesignPattern,Object-orientedDesgin,UML,AgileModeling,XP.关于Testing—Usageofsometools,XUnit,writingunittest,Makeadailybuildingtoolbyourself(part2)课程的基本内容第一章概论。第二章良好的编程风格。包括书写良好程序应有的书写方式,以及面临的一些基本陷阱。主要是梳理和深化。第三章模块化设计是本课程中最困难和最重要的部分,从底层和上层对模块化进行了深入探讨,运用摸索和Case例证的方式自己“发明”了面向对象编程,包括,为什么,如何封装,为什么需要虚函数,及其实现机制,对象的模型,等等。通过程序的不断演化,了解软件设计和构架中的重要问题,矛盾,痛苦和解决。是良好软件构架的坚实基石。也是调试各种复杂问题的重要支撑。第四章用线程封装的例子,揭示了一个实用的具有高扩展性和重用性的类的设计过程,包括其设计思想,策略,探索,不仅有how,更有why,这一例子还展示了绝大多数面向对象的设计技术,访问控制,多态,静态成员函数等等。通过两个设计模式封装了操作系统的线程API。并探讨了跨平台可移植线程类的设计和实现,提供了Linux和Windows上的跨平台线程类。引入了一个独特的跨平台类设计的模式APIBinder,大大简化了传统的复杂,难维护的条件编译方式。第五章简要介绍了UML.第六章设计模式的探讨通过设计模式的运用,我们将第三章模块化的理想和目标具体化。通过设计模式的学习,我们学会用对象的方式思考,学会基于接口编程的精髓。通过设计模式的锤炼,我们能真正把软件设计,软件构架知识和目标变成我们自己成长中可触摸的东西。第七章介绍自动单元测试,和测试驱动的开发于设计。学会并了解新的技术是软件构架必须的基础。下面是一点学习的体会“F1”/”google”:在开发一个软件时,学会如何用Help和在internet上搜索答案.Demos:好的开发工具有许多Demos它们可能涉及到你感兴趣的多个方面.源代码:Lib/program.MFC,VCL,ACE,STLandsoon.开始一本傻瓜型的cookbook足够了.然后是经典的系统的和深入的书籍最最重要的:Case,CaseandOnlyCase.1.3.软件开发的方法和学习能力Howtousedemos:1)readingonebyone.Example1:Iwanttolearninterprocesscommunicationindelphi,Itrytoguessname.a)locatethedirectory:c:\programfiles\borland\delph6\demosb)Iskimthedirectories,andguessname,maythenameisinshort,interprocesscommunication-IPCc)Ok,thereisadirectoryipcdemos,Ifind!!Example2:Iwantlearnhowtowritenetworkapplication.a)locatethedirectory:c:\programfiles\borland\delph6\demosb)FindaInternetdir,andthereisachatsubdirectory,It’sgood.WecouldStart.2)FindKeyfeaturesindemos(usefindkeywordinfiles).Example:Iwanttolearninterprocesscommunicationindelphi,ButIdon’tlikeguess.a)IknowsomeAPIsfromWindowsSDKhelp,forexampleWaitForSingleObjectb)OpenSearchGUIinwindows.Input*.pas(DelphiSourcecode)andkeyword:WaitForSingleObjectc)WefinditDebugit.Problem:Icouldnotunderstandit,wheretoreadfromstart?a)BuilditandRun.b)learntouseit.c)fromtheplacethattriggersomefunction,wesetabreakpoint.d)Runit.Fromthebreakpointwecouldruntheprogramstepbystepandwatchtheeffect.Example:TheChatprogramindelphia)RuntheprogramtheinterfaceofChatlikethatb)Wefoundifstrokeenterkey,themessagewillbesent.Theeventhandlehastobesetincomponentmemo.FinditinObjectInspectorc)ThereisaeventOnKeyDownhasahandler“Memo1KeyDown”,DoubleClickit,thengotothecode.Setabreakpointthere.d)RuntheprograminDelphienvironment.Writesomemessageinthememoandstrokeenter.StepbyStep(UseF7),wecouldtracethecodethathowtosendmessage4)Forthosedon’thavegoodGUIenvironment,trytofindsomegoodtools,forexampleusingsourceinsighttoreadccodeinlinuxorunix.HowtoreadLib:1)Whenyoufamiliarwiththelib(useit),thentrytoread.(VCLhas600000andmorelines)2)Debugit3)whenneedextendsomefunctionofthelib,wehavetotracethelib.Againandagain,wewilllearntheabilityhowtolocatethekeycodeautomatically.4)UsetoolstoabstractthecodeintoDiagram.JBuilder,together,modlemakeretc.1.4选择哪种语言?选择哪种语言是软件设计和构架的开始。一个语言提供了新的机制去支持新的方法学吗?一个语言提供了一些措施去更多地使用系统的资源吗?一个语言提供了很好的库支持你想完成的工作吗?Compilingorinterpreting?是否遗产系统需要某种语言?一个语言提供了新的机制去支持新的方法学吗??Structuralprogrammingdividesbigproblemintosmallproblem.Programisgoodforreuse.Towardsmodularity.Typicallanguages:C,PascalProblems:dataisseparatedfromprocessinglogic.Typicalrepresentativeexample:globalvariable.IntiVoidp();voidp2();{{i=12;if(i==12){…}…….}}Object-orientedprogrammingdividesproblemintofinergrainthanstructuralprogramming.Programisbetterforreuse.Towardsmodularity.Typicallanguages:C++,java,Smalltalk,delphi.Problems:unabletoparameterizetype.Thetypicalexampleiscontainerlikelist.BloatedCode,ands

1 / 37
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功