[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-140260-en":3,"doc-seo-140260-105":30,"detail-sidebar-cat-0-en-105":91},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":20,"is_deleted":4,"is_public":20,"is_downloadable":20,"audit_status":20,"page_count":21,"language":22,"language_code":23,"site_id":24,"html_lang":23,"table_of_contents":25,"faqs":26,"seo_title":27,"seo_description":14,"update_tm":28,"read_time":29},140260,1099514068035,"Ezra","https://ap-avatar.wpscdn.com/davatar_276721f389ce27ea32af1340a28f341c",6,"Technology","Drawing Polygons - Top-Down and Bottom-Up Design Guidelines","Drawing regular polygons requires a program that meets constraints such as the number of sides and a specified side length. The material emphasizes a design workflow: applying a top-down decomposition into parts and subtasks, understanding advantages like clarity while accounting for uncertainty, and using a bottom-up strategy to assemble reusable components from existing libraries. It also highlights practical implementation steps like handling straight-line segments, turning by angles, checking boundary conditions, avoiding off-by-one errors, and using random numbers with seeds for simulations and games.","Example: Drawing polygons.  \nRequirements: a program to draw a regular polygon with a given number of sides, and a given side length.  \nThese requirements are not complete.  \nWhat is the maximum and minimum permissible side length? Min number of sides: 3  \nMaximum number: 8 (for example) .  \nThis is a design problem. You have to put \"parts\" together to get a program that satisfies the requirements.  \nWe can work at this from the top down and from the bottom up.  \nTop-down approach: Think about what parts or tasks need to be done to meet the requirements.  \nThen think about what subparts and subtasks need to be done to implement the parts or tasks.  \nAnd keep going this way, dividing into smaller and smaller parts, until we get to things we already have.  \nPros: Tends to lead to clean, understandable designs. Each part has well-defined purpose, relative to the requirements.  \nCons: One problem is that you don't necessarily know that you will get to things you have (or can get) . So you have to have an idea what's possible and what's available.  \nThe other problem is that this process can indicate the need for slightly different  \nsubsystems, that in fact could be the same, which would be more economical. (E.g., sorting numbers and sorting character strings could be done by one sort routine.) This is more of a problem with team projects.  \nBottom-up approach: We start with what we have, and (based on our knowledge of how systems are implemented) we put them together to make useful components for building systems. We put these into libraries that designers can use. We keep building up this way. You get reusable components more easily than with top-down approach, but good bottom-up design requires prior experience with top-down (so you know what components are likely to be useful) .  \nSo for example the Myro library is useful for controlling scribbler-like robots. And when you design a robot control program, these are basic-level components you will be using (as well as other libraries) .  \nIn the case of the polygon program, we can do a little top-down and a little bottomup. Obviously, we need to be able to draw straight lines of a given length, and to turn through a given angle. Note that Myro does not provide these operations.  \nIn figuring out how to do something, it is always helpful to think \"How would I do it?\" Then look at the individual steps.  \nThis is especially useful for robots, because we are physical, mobile objects like the robots. Put yourself in the robot's place.  \nStart simple, say with a square.  \nMake sure to check boundary conditions (minimum and maximum values) to make sure it works. This is where programs often go wrong, because they tend to be special cases.  \nRelated: off-by-one errors: Usually means you go through a loop one too many times or one too few times.  \nStandard coding practices can help avoid these errors in common cases. You always do the common cases the same way, which you know works.  \nRandom numbers:  \nMost programming languages provide (via a library) a pseudo-random number generator. This is a deterministic number series that looks random.  \nRandom numbers are useful in games, simulations, and many other applications.  \nTo get real a random starting point (seed), either get a genuinely random number (radioactive decay), or use something that is effectively random, like the number of milliseconds from the start of the program until the first interaction. Or the number of msec. from some fixed time in the past until the program started.","cbCaiammVTqeQTxH","https://ap.wps.com/l/cbCaiammVTqeQTxH","pdf",21463,1,3,"English","en",105,"# Program Design Approaches\n## Top-Down Decomposition\n## Bottom-Up Reusable Components\n# Polygon Implementation Considerations\n## Basic Geometry Operations\n## Boundary Conditions and Off-By-One Errors\n# Random Numbers and Seeding","[{\"question\":\"What are the maximum and minimum permissible side lengths for the polygon program?\",\"answer\":\"The document states that the minimum number of sides is 3 and the maximum number is 8, but it does not provide concrete permissible side-length values.\"},{\"question\":\"What is the top-down approach to designing the polygon drawing program?\",\"answer\":\"Define the parts or tasks needed to meet the requirements, then break each into smaller subparts and subtasks until reaching tasks that are already available.\"},{\"question\":\"How should random numbers be handled in programs?\",\"answer\":\"Use a pseudo-random number generator from a library, and obtain a real starting point by choosing an appropriate seed—either from a genuinely random source or from something effectively random like elapsed milliseconds.\"}]","Drawing Polygons - Top-Down and Bottom-Up Design Guidelines | PDF",1787572447,8,{"code":4,"msg":31,"data":32},"ok",{"site_id":24,"language":23,"slug":33,"title":13,"keywords":34,"description":14,"schema_data":35,"social_meta":86,"head_meta":88,"extra_data":90,"updated_unix":28},"drawing-polygons-top-down-and-bottom-up-design-guidelines","",{"@graph":36,"@context":85},[37,53,68],{"@type":38,"itemListElement":39},"BreadcrumbList",[40,44,48,50],{"item":41,"name":42,"@type":43,"position":20},"https://docshare.wps.com","Home","ListItem",{"item":45,"name":46,"@type":43,"position":47},"https://docshare.wps.com/document/","Document",2,{"item":49,"name":12,"@type":43,"position":21},"https://docshare.wps.com/document/technology/",{"item":51,"name":13,"@type":43,"position":52},"https://docshare.wps.com/document/drawing-polygons-top-down-and-bottom-up-design-guidelines/140260/",4,{"url":51,"name":13,"@type":54,"author":55,"headline":13,"publisher":57,"fileFormat":60,"inLanguage":23,"description":14,"dateModified":61,"datePublished":62,"encodingFormat":60,"isAccessibleForFree":63,"interactionStatistic":64},"DigitalDocument",{"name":9,"@type":56},"Person",{"url":41,"name":58,"@type":59},"DocShare","Organization","application/pdf","2026-08-27","2026-08-24",true,{"@type":65,"interactionType":66,"userInteractionCount":20},"InteractionCounter",{"@type":67},"ViewAction",{"@type":69,"mainEntity":70},"FAQPage",[71,77,81],{"name":72,"@type":73,"acceptedAnswer":74},"What are the maximum and minimum permissible side lengths for the polygon program?","Question",{"text":75,"@type":76},"The document states that the minimum number of sides is 3 and the maximum number is 8, but it does not provide concrete permissible side-length values.","Answer",{"name":78,"@type":73,"acceptedAnswer":79},"What is the top-down approach to designing the polygon drawing program?",{"text":80,"@type":76},"Define the parts or tasks needed to meet the requirements, then break each into smaller subparts and subtasks until reaching tasks that are already available.",{"name":82,"@type":73,"acceptedAnswer":83},"How should random numbers be handled in programs?",{"text":84,"@type":76},"Use a pseudo-random number generator from a library, and obtain a real starting point by choosing an appropriate seed—either from a genuinely random source or from something effectively random like elapsed milliseconds.","https://schema.org",{"og:url":51,"og:type":87,"og:title":13,"og:site_name":58,"og:description":14},"article",{"robots":89,"canonical":51},"index,follow",{"doc_id":7,"site_id":24},{"code":4,"msg":5,"data":92},[93,97,101,105,110,113,118,122,127,130,134],{"id":20,"doc_module":4,"doc_module_name":46,"category_name":94,"show_sort_weight":95,"slug":96},"Story & Novel",90,"story-novel",{"id":47,"doc_module":4,"doc_module_name":46,"category_name":98,"show_sort_weight":99,"slug":100},"Literature",80,"literature",{"id":52,"doc_module":4,"doc_module_name":46,"category_name":102,"show_sort_weight":103,"slug":104},"Exam",70,"exam",{"id":106,"doc_module":4,"doc_module_name":46,"category_name":107,"show_sort_weight":108,"slug":109},5,"Comic",60,"comic",{"id":11,"doc_module":4,"doc_module_name":46,"category_name":12,"show_sort_weight":111,"slug":112},50,"technology",{"id":114,"doc_module":4,"doc_module_name":46,"category_name":115,"show_sort_weight":116,"slug":117},7,"Healthcare",40,"healthcare",{"id":29,"doc_module":4,"doc_module_name":46,"category_name":119,"show_sort_weight":120,"slug":121},"Research & Report",30,"research-report",{"id":123,"doc_module":4,"doc_module_name":46,"category_name":124,"show_sort_weight":125,"slug":126},9,"Religion & Spirituality",20,"religion-spirituality",{"id":125,"doc_module":4,"doc_module_name":46,"category_name":128,"show_sort_weight":125,"slug":129},"World Cup","world-cup",{"id":131,"doc_module":4,"doc_module_name":46,"category_name":132,"show_sort_weight":131,"slug":133},10,"Lifestyle","lifestyle",{"id":135,"doc_module":4,"doc_module_name":46,"category_name":136,"show_sort_weight":106,"slug":137},19,"General","general"]