I have a structure called NDPlane, and I want to put it in its own file by following this answer.
To avoid confusion as this just being an Objective-C interface for an NDPlane object, how should I name the file? ndplane.h, plane.h, or struct_NDPlane.h, etc...
Related
Assume there is a abstract doctrine class named "file" and child classes "archiveFile" and "currentFile" which are represented by a discriminator column "file_type" ... in my application, only one "currentFile" can exist and multiple "archiveFile". If new files are imported, the newest of this imported file is now the current file and the previous file should move to an archive file ...
In theory, it works fine. But in practice i cannot change the type neither of the currentFile nor the archiveFile ... is there a better approach for my intention or have i to deal with plain sql to set the discrimination column?
In one of the designs I compiled using Yosys I saw that we can have private wires (wires with private name). For example, $0_s0[127:0]. So, I have few questions about them:
why do we have private wires in Yosys (what scenarios)?
does it always get converted to a unique name. For example, when I dump the whole design (using write_verilog), does it give me identical name as when I dump just the module that contains that private wire?
why do we have private wires in Yosys (what scenarios)?
because we need a mechanism to create names for intermediate wires. In an expression like assign x = (a+b)+c; there will be a wire holding the result of (a+b), and that wire will need a name.
Better to do it right and create a namespace for such names and separate them from user defined names. So later passes in the synthesis flow will always know which names to preserve and which names it can throw away.
does it always get converted to a unique name. For example, when I dump the whole design (using write_verilog), does it give me identical name as when I dump just the module that contains that private wire?
No.
Use a command like rename -enumerate to actually give public names to that wires if you care about this kind of consistency between different output files.
I want to use Nepomuk File Ontology (NFO) in a desktop software. Before starting I need some guidance on using NFO.
Forexample:
In NFO we have File class and Image classes.
File Class properties are: nfo:fileCreated, nfo:fileLastAccessed, nfo:fileLastModified, nfo:fileName, nfo:fileOwner, nfo:fileSize, nfo:fileUrl, nfo:hasHash, nfo:permissions.
And Image Class properties are: nfo:depicts, nfo:horizontalResolution, nfo:verticalResolution
Now Please guide, I have an image file i.e imagefile1.jpeg on which I want to apply properties of both File and Image classes.
which one of the below two methods is the correct method to do so.
Method 1: Create a single Object i.e. obj1 of type File and Image. So
now I can annotate obj1 on properties of File class as well as Image
Class.
Method 2: Create two objects, one of type File i.e. obj1 and second
object of type Image i.e. obj2. and now link these two objects via
interpretedAs and isStoredAs properties.
Please guide me which one is the correct approach so that I follow it in my application.
"InformationElement is a piece of information stored within a data
object. Content-specific properties are defined as properties of an
InformationElement. It is separate from the DataObject in order to
make the interpretation independent of the representation."
Source
Also have a look at the description of data objects
So Method 2 is the way to go, to "apply" the different abstractions the ontology intends.
I have a task that i have to complete. I know the solution but i want to make sure that my solution is according to proper OOP/Design Patterns. Here is the scenerio
1- I have 2 files with different formats. (Lets say FormatA and FormatB).
2- I want to convert data in FormatA to FormatB.
3- FormatA is plain text file with keys. Each new line is a new
key/value pair. FormatB is XML.
4- The keys in FormatA file can be same as the keys in FormatB but can also be different. Sometimes we might need to do some calculations to convert the
value to FormatB.
5- There are some chances that more keys will
be added in future to either the old one or the new one.
My solution:
I want the solution to be generic and no hardcoding. So, that if in future some key mapping change then i should not change the code.
1- First i created a "Mapping" XML file that has all the data that which key in FormatA maps to which field in FormatB. The XML structure is something like this
//oldKey = name of the key in the old file format
//newKey = name of the key in the new format
//ignore = optional. set it to true if you want to ignore this field during conversion
//function = optional.Name of a function that will be called. This function will have all the logic to do the calculations
//functionparams = optinal .key names from the old file that need calculation
//defaultvalue = optional parameter. This value will be replaced no matter what if given.
<field oldKey="abc" newKey="def" ignore="false" function="MultiplyBy2" functionparams="abc" defaultvalue="4">
2- I created a class named "TextFileParser" that loads the text file and creates a dictionary with all the keys.
3- I created a class named "MappingXMLParser" which loads the Mapping XML file and populates a dictionary with all the data.
3- I created a class "TextFileToXML" that uses the above 2 classes to write the data in the XML file. No composition is used.
4- I created a class named "Conversion". If the Mapping XML file has declared some function (like "MultiplyBy2") then the definition of functions will be in this class. I will use reflection to call the methods of this class from the class "TextFileToXML".
This is my design but i donot know that it is correct in terms of OOP/Design Patterns/architecture. Can you point out the mistakes ? What can be done better or any good approach ?
As you probably understand, there is no such thing as correct design. I would suggest following standard practices. I would follow these steps:
Translate the key-value file to a simple XML file following the simplest possible XML schema
I would use an XSLT to describe the translation between the simple XML files generated in step 1, and the final result.
Execute the transformation described in XSLT using an XML operations library. I suppose you could find one, on the specific programming language you use.
This way, in case of changing something (adding more keys in future, changing the target XML schema etc), you would only have to change the translation process described in XSLT, which is not application code but an XML file. You have nothing regarding the specific translation process hard-coded in your application.
Regarding the overall design, I would choose to use the Factory pattern. I think it matches perfectly your situation.
Hope I helped!
If I have a view with two or more words, e.g.:
public function actionApprovalQueue()
what is the naming convention of the view file itself?
approval-queue.php
approvalQueue.php
approvalqueue.php
??
The documentation on Conventions only says:
View files should be named after the view name. For example, the index
view is in the index.php file.
which gives no clue about views with two or more words.
When it comes to naming conventions, it comes down to what suits your organisation, or what is followed in your organisation, or what the rest of your team decides. The key is consistency throughout your code base.
I would say go with the dash(hyphen), because variables are generally named $xyzAbc or $xyz_abc. So it would make sense to use approval-queue.php.
Definitely do not go for approvalqueue.php.
Edit: Read more about Yii's conventions here.
Yii recommends naming variables, functions and class types in camel case which capitalizes the first letter of each word in the name and joins them without spaces. Variable and function names should have their first word all in lower-case, in order to differentiate from class names (e.g. $basePath, runController(), LinkPager). For private class member variables, it is recommended to prefix their names with an underscore character (e.g. $_actionList).
Because namespace is not supported prior to PHP 5.3.0, it is recommended that classes be named in some unique way to avoid name conflict with third-party classes. For this reason, all Yii framework classes are prefixed with letter "C".
A special rule for controller class names is that they must be appended with the word Controller. The controller ID is then defined as the class name with first letter in lower case and the word Controller truncated. For example, the PageController class will have the ID page. This rule makes the application more secure. It also makes the URLs related with controllers a bit cleaner (e.g. /index.php?r=page/index instead of /index.php?r=PageController/index).