Reorganize directory structure MVC ExtJs 4 App - extjs-mvc

I have learned from the sencha doc how to create a simple MVC application, and now I wonder if it is possible to move from this structure :
-app
--Controller
---controller1.js
---controller2.js
...
--Model
---model1.js
---model2.js
...
--Store
---store1.js
---store2.js
...
--View
---view1.js
---view2.js
...
to this modular structure :
-app
--Module1
---controller.js
---model.js
---store.js
---view.js
--Module2
---controller.js
---model.js
---store.js
---view.js
I want also if you can advise me about the modular structure (good, bad, complex, remarks...), Thank you in advance.

You can do whatever you want with different file and class names. Just remember to keep class name in sync with its position in the file hierarchy. For example if you have class
MyApp.controller.Controller1
located in the following file
- app\Controller\Controller1.js
If you move it to the
- app\module1\Controller.js
You would need to rename class name to
MyApp.module1.Controller
See for yourself whether having such class hierarchy would be appropriate for you. I would not do this. We keep all code according to ExtJs MVC directory structure (mostly). We have the following directories
- store
-- base
- view
-- base
- controller
- model
We usually put base classes underneath special base director to easily separate them from the rest of code.

Related

Nodejs Code Reusing Best Practices

I am new to nodejs. I can't get my mind over organizing module code reusing in Nodejs. For example :
Let's say I have 3 files, which corresponds to 3 library files I wish to load. Then, I have 5 files which requires the 3 libraries.
Will I have to repeat typing the following in the 5 files?
require("./library-1.js");
require("./library-2.js");
require("./library-3.js");
Is there any way for me to automatically include these 3 lines of code (which is potentially more than just 3) in the 5 files?
Generally yes you end up with this kind of repetition, but the explicit dependencies are really helpful next year when you go to refactor your app. However, You can very easily wrap all 3 libraries into a monolithic module if you prefer:
//monolith.js
exports.lib1 = require('./library-1');
exports.lib2 = require('./library-2');
exports.lib3 = require('./library-3');
Then just load that with var monolith = require('./monolith');
Yes, you can require a folder as a module. If you want to require() a folder called ./test/.
Inside ./test/, create a package.json file with the name of the folder and a main javascript file with the same name, inside a ./lib/ directory.
{
"name" : "test",
"main" : "./lib/test.js"
}
Now you can use require('./test') to load ./test/lib/test.js.
similarly you can require other files

processXmlResource cannot reach the xml file

I'm trying to replicate this hello world example with Haxe and HaxeUI.
When i compile the project everything seems fine but when i try to execute the swf from browser i have an error like: Cannot access a property or method of a null object reference referred to processXmlResource (in the root folder i have the main.hx and in a subfolder the xml).
Below is the screenshot of the error i get:
Have you modified your applications application.xml (or project.xml) to find the asset in your project root? Or put all your assets in an assets sub folder and let then reference that from you application.xml?
Basically it seems it is not finding your xml resource. This sample might be a good example of a basic project setup: https://github.com/ianharrigan/haxeui/tree/master/samples/hello_world_xml

How to get path to UITestActionLog.html from code

Each test case saves results to a separate UITestActionLog.html file. But in the end of each test case I'd like to move that .html to a different folder and rename it.
Is it possible to do so in, say, [TestCleanup()]? If yes, then how can I programmatically get .html report location?
The TestContext class contains several fields with "directory" in their names. These can be used to access the various directories associated with running the tests.
As well as managing the files as asked by your question the TestContext class has an AddResultFile method. The Microsoft documentation on this mehod is not clear, but it seems that the files are saved for failing tests and discarded for passing tests.
To get the directory in which the UITestActionLog file will be located, use the TestContext.TestResultsDirectory Property. You can use below code to get the full path:
string fullPath = TestContext.TestResultsDirectory +"\" +"UITestActionLog.html";

Cucumber options annotation

The cucumber-jvm javadocs states that purpose of the glue element is to specify the location of the stepdefinitions and hooks. However, this doesn't seem to work for me. Lets say I have my features in directory a, and my step definitions in directory b. Then,
#Cucumber.Options(
features= "directory_a",
glue="directory_b"
)
will load my feature files from directory_a, but, it doesn't load my step definitions from directly_b. However, if I use
#Cucumber.Options(
features= {"directory_a", "directory_b"}
)
then my features from directory_a is loaded, and my step definitions from directory_b are also picked up. Which is exactly what I want, however, I don't understand why the former isn't working? I'm guessing it has something to do with it expecting the URI to be formatted differently (maybe i need to prepend a classpath:// or something like that), but I can't find any information on this in the documentation.
I have successfully used something like:
#RunWith(Cucumber.class)
#Cucumber.Options(
//this code will only look into "features/" folder for features
features={"classpath:features/"},
glue = { "com.mycompany.cucumber.stepdefinitions", "com.mycompany.cucumber.hooks" },
format = { "com.mycompany.cucumber.formatter.RuntimeInfoCatcher", "json:target/cucumber.json" },
tags = { "#working" }
)
public class CucumberStarterIT {
}
Looking at the doc at http://cukes.info/api/cucumber/jvm/javadoc/cucumber/api/junit/Cucumber.Options.html it specifies the options to be of type String[] so perhaps it's not expected to work "well" if you don't give it a single-value list. Try glue={"directory_b"} and see what happens for you.
I had this problem too... and so far it seems to be that:
"features" is looking for a filesystem path:
features = "src/foo/bar"
whereas "glue" is looking for a package name:
glue = "foo.bar"
Not sure why they are different, but this seems to be working for me.
Hi as per my knowledge it all depends on the structure of you project. For example if you add the "Directory_a" ( directory which contains feature files) in the root level and StepDefinition, Hooks at src > test > java "Directory_b" And the TestRunner class at the same level ( src > test > java ) in "Directory_c"
Dir_a
|
src
|---main
|---test
|------java
|------Dir_b
|------Dir_c
You saying "Dir_b" while you are in the "Dir_c" It will identify "Dir_b" or any directory in same level with out any additional paths so,
It will be
glue = {"Dir_b"},
But when you look at the directory that includes feature file you have to give the path from the root level
In this case it's
features = {"Dir_a"}
or Giving the actual path eg :- "E://Project_Name//Dir_a" should work too
If your feature directory is NOT in root level make sure you give the path like "src/path to feature directory"
It will work fine :)

Step to translate Joomla component

I've created an administrator component for Joomla 2.5 recently (in French), and not knowing how to proceed to translate it in English and German, I was wondering if someone could help me understanding the process.
Indeed, I think I understood that I need to format my strings such as :
JText::_( 'mystring' )
Then that I create .ini files, but I don't know where to create them, what they should contain, if it exists a tool like PoEdit that could suit etc. So if you have any idea how I should proceed...
Thank's guys !
In the "language" directory at the root of your website, you create the directories and files :
administration/language/en-GB/en-GB.com_yourcomponentname.ini
administration/language/fr-FR/fr-FR.com_yourcomponentname.ini
administration/language/de-DE/de-DE.com_yourcomponentname.ini
You translate each of them. I am not sure, you need a tool to do that.
And I don't know if it exists a PoEdit plugin to help you to do that too...
Your ini files look like the others that already exist in the language directories :
COM_ADMIN="Informations système"
COM_ADMIN_ALPHABETICAL_INDEX="Index alphabétique"
COM_ADMIN_CACHE_DIRECTORY="(Répertoire cache)"
Then in your views, to call a translated string :
JText::_( 'COM_ADMIN' )
This function will look for the value of COM_ADMIN in the ini file.
The loaded ini file will be the language the user has chosen, and if a translation doesn't exist, then it will load the value of the default language (chosen in administration panel).
Then if this key doesn't exist in any of these ini file, they the key is displayed.
To package your archive :
In install.xml, add these lines :
<administration>
<!-- Directory and file stuff -->
<languages folder="language/admin">
<language tag="en-GB">en-GB/en-GB.com_yourcomponentname.ini</language>
<language tag="fr-FR">fr-FR/fr-FR.com_yourcomponentname.ini</language>
<language tag="de-DE">de-DE/de-DE.com_yourcomponentname.ini</language>
</languages>
</administration>
And add the translation files in the language/admin directory.

Resources