ww5 created page: build instructions authored by Wieselquist, William's avatar Wieselquist, William
...@@ -31,6 +31,7 @@ class BufferedReader_Int{ ...@@ -31,6 +31,7 @@ class BufferedReader_Int{
} }
}; };
}//end namespace scale }//end namespace scale
int main(){ int main(){
scale::BufferedReader_Int reader; scale::BufferedReader_Int reader;
{ {
...@@ -39,20 +40,26 @@ int main(){ ...@@ -39,20 +40,26 @@ int main(){
} }
std::ifstream ifs("file.txt"); std::ifstream ifs("file.txt");
reader.read(ifs); reader.read(ifs);
std::cout << *reader.buffer() << std::endl; std::cout << *reader.buffer() << std::endl;
return 0; return 0;
} }
``` ```
### Why the underscores? ### Why the underscores?
A strict camel case would have this reader be named ``BufferedIntReader`` or ``IntBufferedReader``, but this has some shortcomings. By pushing the "variant" part of the naming to the end with ``BufferedReader_Int`` and ``BufferedReader_Dbl``, we get good, automatic sorting of the classes. This helps in editors and in documentation: *lexically similar implies logically similar*. Now, imagine what happens when we get around to templating the BufferedReader. A strict camel case would have this reader be named ``BufferedIntReader`` or ``IntBufferedReader``, but this has some shortcomings. By pushing the "variant" part of the naming to the end with ``BufferedReader_Int`` and ``BufferedReader_Dbl``, we get good, automatic sorting of the classes. This helps in editors and in documentation: *lexically similar implies logically similar*. Now, imagine what happens when we get around to templating the BufferedReader.
```c++ ```c++
template <typename T> template <typename T>
class BufferedReader { class BufferedReader {
//contents //contents
}; };
typedef BufferedReader<int> BufferedReader_Int; typedef BufferedReader<int> BufferedReader_Int;
typedef BufferedReader<double> BufferedReader_Dbl; typedef BufferedReader<double> BufferedReader_Dbl;
``` ```
The typedefs mirror the templating syntax and can always be made fairly straightforwardly, as opposed to trying to figure out where to put the "Int", i.e. is it "BufferedIntReader" or "IntBufferedReader". With multiple template parameters it gets even more hairy, but the _ syntax, simply leads to ``typedef std::map<std::string,int> Map_Str_Int``. The typedefs mirror the templating syntax and can always be made fairly straightforwardly, as opposed to trying to figure out where to put the "Int", i.e. is it "BufferedIntReader" or "IntBufferedReader". With multiple template parameters it gets even more hairy, but the _ syntax, simply leads to ``typedef std::map<std::string,int> Map_Str_Int``.
## Defining Word Boundaries ## Defining Word Boundaries
...@@ -72,7 +79,7 @@ With those definitions in mind, let's define a set of word conventions. The main ...@@ -72,7 +79,7 @@ With those definitions in mind, let's define a set of word conventions. The main
* regex: ``<VAR>``=``<SNAKE>`` * regex: ``<VAR>``=``<SNAKE>``
2. classes 2. classes
1. ``CLASS`` class name 1. ``CLASS`` class name
* description: standard CamelCase used for most classes, avoid abbreviations, for acronyms capitalize first, e.g. ORIGEN-->Origen or IO-->Io, MG-->Mg, CE-->Ce * description: standard CamelCase used for most classes, avoid abbreviations, for acronyms capitalize first, e.g. ORIGEN->Origen or IO->Io, MG->Mg, CE->Ce
* regex: ``<CLASS>``=``<UCAMEL>`` * regex: ``<CLASS>``=``<UCAMEL>``
* e.g. ``NuclideSet``, ``Nexus``, ``LibraryIo``, ``CeResourceFile`` * e.g. ``NuclideSet``, ``Nexus``, ``LibraryIo``, ``CeResourceFile``
2. ``CLASSMETHOD``class method 2. ``CLASSMETHOD``class method
...@@ -112,15 +119,19 @@ The goal for Fortran is to as closely as possible mirror the C++ rules. The only ...@@ -112,15 +119,19 @@ The goal for Fortran is to as closely as possible mirror the C++ rules. The only
```fortran ```fortran
module scale_BufferedReader_Int_M module scale_BufferedReader_Int_M
type scale_BufferedReader_Int type scale_BufferedReader_Int
end type end type
contains contains
! -- contents -- ! -- contents --
end module end module
program main program main
use scale_BufferedReader_Int_M use scale_BufferedReader_Int_M
type(scale_BufferedReader_Int) :: reader type(scale_BufferedReader_Int) :: reader
integer :: buffer integer :: buffer
! -- contents --
end program end program
``` ```
... ...
......