-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_style.html
More file actions
184 lines (153 loc) · 8.37 KB
/
code_style.html
File metadata and controls
184 lines (153 loc) · 8.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!DOCTYPE HTML>
<!--
Arcana by HTML5 UP
html5up.net | @ajlkn
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
<head>
<title>Code Style</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="https://suave.stanford.edu/assets/css/main.css" />
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-132339206-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-132339206-1');
</script>
</head>
<body class="is-preload">
<div id="page-wrapper">
<!-- Header -->
<div id="header">
<!-- Logo -->
<a hidden id="logo">SUAVE</a>
<!-- Nav -->
<nav id="nav">
<ul>
<li><a href="https://suave.stanford.edu/index.html"> SUAVE</a></li>
<li><a href="https://suave.stanford.edu/download.html">Download</a></li>
<li><a href="https://suave.stanford.edu/tutorials.html">Tutorials</a></li>
<li class="current"><a href="https://suave.stanford.edu/documentation.html">Documentation</a></li>
<li><a href="https://suave.stanford.edu/forum.html">Forum</a></li>
<li><a href="https://suave.stanford.edu/publications.html">Publications</a></li>
<li><a href="https://github.com/suavecode/SUAVE">
<span class="icon2 icon-github">
<img src="https://suave.stanford.edu/images/github_white.svg">
</span>
</a></li>
<li><a href="https://travis-ci.org/suavecode/SUAVE">
<span class="icon2 icon-travis">
<img src="https://suave.stanford.edu/images/travis_white.svg">
</span>
</a></li>
<li><a href="https://coveralls.io/github/suavecode/SUAVE">
<span class="icon2 icon-coveralls">
<img src="https://suave.stanford.edu/images/coveralls.svg">
</span>
</a></li>
</ul>
</nav>
</div>
<!-- Main -->
<section class="wrapper style1">
<div class="container">
<div id="content">
<!-- Content -->
<h2 id="suave-code-style-guide">SUAVE Code Style Guide</h2>
<p>SUAVE is built on a slightly modified PEP8 style guide, with changes made to implement a data-oriented view of the code. To help support discovering code, the SUAVE folder structure explicitly mirrors the package structure. Flexibility of the package structure is important, so in general all objects live in their own file, with the same file name as the object name. In order to maintain a separation between Analysis and Data structures, there are often parallel package trees inside the main branches of the package, like SUAVE.Methods.Aerodynamics and SUAVE.Analysis.Aerodynamics. Where possible the names of fields that live in the SUAVE package are written out verbosely, avoiding jargon built on mathematical variable names or acronyms.</p>
<p>Templates for new methods and objects can be found in the SUAVE repo’s <a href="https://github.com/suavecode/SUAVE/tree/develop/templates">templates</a> folder.</p>
<h3 id="naming-convention">Naming Convention</h3>
<p>In terms of typography –</p>
<ul>
<li><code class="highlight_code">any_variable_name</code> - lower case with underscore <br />
This includes working variables and instantiated objects.</li>
<li><code class="highlight_code">field_name</code> - lower case with underscore
Any field of an object should be lower case.</li>
<li><code class="highlight_code">function_name</code> - lower case with underscore</li>
<li><code class="highlight_code">Class_Type</code> - upper case with underscore <br />
The underscores are chosen here to permit the inclusion of acronyms if needed and to maintain symmetry with field name styling.</li>
<li><code class="highlight_code">Package_Name</code> - upper case with underscore <br />
For example folders within the SUAVE package.</li>
</ul>
<p>In terms of naming –</p>
<ul>
<li>Chunk similar field types under a containing field</li>
<li>Bias names towards being specific</li>
<li>Write out field name verbosely, but try to keep short</li>
</ul>
<h3 id="development-life-cycle">Development Life Cycle</h3>
<p>As you develop new features for SUAVE, this is generally how you can expect your feature to evolve, in terms of its level of abstraction, and where it lives.</p>
<ol>
<li>
<p>Prototype <br />
Either a new function or class. You may want to test these within a separate folder. If you are developing a new analysis approach, for example for aerodynamics or weights, you can usually start with a function. If you are working off of an object like a wing, you can abstract the objects as needed. Generally the lowest level object you’ll use is the SUAVE.Core.Data class. <br />
A lot of development can be accomplished in a local environment.</p>
</li>
<li>Initial Integration <br />
Once you’re comfortable that your new feature works robustly, and that it has been tested, it’s time to integrate it into SUAVE. Here are some tips for identifying where it could live.
<ul>
<li>SUAVE.Methods - if it’s a python function. Ping the <a href="http:suavecode.github.io/forum.html">forum</a> if you want to double check your decision!</li>
<li>SUAVE.Analyses - if it’s an object that manages an analysis like aerodynamics</li>
<li>SUAVE.Components - if it’s a data storage container for a vehicle component like a wing or landing gear</li>
<li>SUAVE.Attributes - if it’s a data storage container for any other type of object, like atmospheres or water<br /></li>
</ul>
<p>At this point you might want to initiate a pull request to contribute the code back to the main repository.<br /></p>
</li>
<li>Full-Blown Subpackage <br />
As you write more code, and follow the SUAVE style of keeping one file per object, you will need to create a folder to contain a subpackage. This step may come later in the life of your code, so don’t rush to it if you don’t need the extra overhead.</li>
</ol>
<br>
</article>
</div>
</div>
</section>
<!-- Footer -->
<div id="footer">
<div class="container">
<div class="row">
<section class="col-3 col-6-narrower col-12-mobilep">
<h3>Download</h3>
<ul class="links">
<li><a href="https://suave.stanford.edu/registration.html">Registration</a></li>
<li><a href="https://github.com/suavecode/SUAVE">Github Site</a></li>
</ul>
</section>
<section class="col-3 col-6-narrower col-12-mobilep">
<h3>Learn</h3>
<ul class="links">
<li><a href="https://suave.stanford.edu/tutorials.html">Tutorials</a></li>
<li><a href="https://suave.stanford.edu/documentation.html">Documentation</a></li>
<li><a href="https://suave.stanford.edu/forum.html">Forum</a></li>
</ul>
</section>
<section class="col-3 col-6-narrower col-12-mobilep">
<h3>External Links</h3>
<ul class="links">
<li><a href="http://adl.stanford.edu">Aerospace Design Lab</a></li>
<li><a href="https://aa.stanford.edu">Stanford Aero/Astro</a></li>
<li><a href="https://su2code.github.io">SU2</a></li>
</ul>
</section>
</div>
<!-- Copyright -->
<div class="copyright">
<ul class="menu">
<li>© <script>document.write(new Date().getFullYear())</script> Stanford Aerospace Design Lab <br/>
All rights reserved</li>
</ul>
</div>
</div>
</div>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.dropotron.min.js"></script>
<script src="assets/js/browser.min.js"></script>
<script src="assets/js/breakpoints.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>