You may face hard time starting TDD, but soon you will realize it is worth!

Here I am just sharing about my first experience with TDD approach, the writing is an opinon, if you have different, no issues, I would love to hear.

Prior to TDD approach to developing software application was  like looking no backward, thinking positively while running on code marathon track. The confidence on application was solely dependent on developer’s manual testing. Later this confidence gets sealed by QA team testing. 

TDD changes your thought process to good extent. It enables you to think or more specifically it demands you to think of test cases before writing your code. It asks you “what it should do” before you actually start doing it. 

It seems to be good thing, you should start doing. Initially I found it difficult to adapt, as I was writing lot of code which did not direct contribute to output. I thought writing this code is redundent effort and it is not that worth. I also had problems is estimating the time required. And “which things to test” was a mind blocking question.

I started with writing unit tests for important functions in app, this gave me on ground knowledge of how to write tests, how to run them. I think this is least you can do to dive into TDD i.e. write unit tests for imp functions, execute them, have fun with them. But there is much more yet to do to adapt TDD.

I think one should not loose hope while begining into TDD style. Start small, which will give you idea of environment and it also introduce you to the thought process. 

Few weeks after starting the TDD, we had requirement to change one of our core modules functionality. at this particular time already written tests helped me a lot to be ensured that everything is still working fine.

This was about how I have started into TDD approach. Concluding line I can draw from this is it takes patience and some effort to get familiar with it. 

I have plans to write more when I will get good experience, but I think that will be more on technical side of things.

Thanks šŸ™‚

Advertisements

Add Bootstrap sass(scss) to Angular 2

 

  1. Update .angular-cli.json ( which is in root folder of your Angular2 application) for
    1. “styleExt”: “css” toĀ “styleExt”: “scss”
    2. “styles”: [
      “styles.css”
      ] toĀ “styles”: [
      “styles.scss”
      ]
  2. Update the styles.scss in src folder ( create if does not exist) for adding lines
    1. @import “./assets/bootstrap-sass/variables”;
      @import ‘../node_modules/bootstrap-sass/assets/stylesheets/_bootstrap’;
  3. Install bootstrap sass module npm install –save bootstrap-sass
  4. Copy _variables.scss file fromĀ node_modules/bootstrap-sass/assets/stylesheets/bootstrap to src/assets/bootstrap-sass folder.
  5. (Optional) Update the above file src/assets/bootstrap-sass/_variables.scssĀ for bootstrap customization.
  6. Run ng serve to compile the Angular2 application and see the changes in browser.

 

 

Note:

You may need to update src/assets/bootstrap-sass/_variables.scssĀ for fonts path,

Change

$icon-font-path: if($bootstrap-sass-asset-helper, “bootstrap/”, “../fonts/bootstrap/”) !default;

to

$icon-font-path: if($bootstrap-sass-asset-helper, “bootstrap/”, “../node_modules/bootstrap-sass/assets/fonts/bootstrap/”) !default;

 

 

Getting Started with Angular2 and Bootstrap

Getting Started with Angular2 and Bootstrap

# Install Angular2 Cli
npm install -g @angular/cli

# Create new application
ng new application-name

# Start serving application, see browser localhost:4200
ng serve

# In src directory, install bootstrap using bower
bower install bootstrap –save

# Link bootstrap style to application, edit .angular-cli.json
# add new element to app->styles array
“bower_components/bootstrap/dist/css/bootstrap.min.css”

# Stop and again start serving the application and it is ready!

Handle write permissions in ubuntu for uploads or code generators

Usually we need to change directory/file permission to able to write files. This may be for uploads directory or code generation tool. But most of the time someĀ developers do bad thing, that the give permission 777 to the directory/file and get work the done.

sudo chmod -R 777 /path/some-directory

Here the script which throws the write permission error, now executes smoothly as it has got the 777 permission. But here we compromised serious security risk. Permission 777 means that is read/write/execute to everybody in the system, thus creating loop hole for security.

Instead of assigning permission 777, we can assign 775 and add the user who runs the script(which thrown the permission error) in the user group of the directory/file.

Following command adds given user (userName) to particular group (groupName)

sudo usermod -a -G groupName userName

Above will add user which runs the script to the group of users of directory/file which need write permission. Here I am assuming that your directory/file already has writeĀ permission i.e. user group has writable permission. You can also check members of user group fromĀ file “/etc/group”.

For web applications where Apache is the web server, you can add “www-data” to group of users. For PHP yii framework you need to set writable permission to some directories while development so that code generators can work.

This was just to give alternative way(good) to the developer who quickly give 777 permission to avoid/fix permission error. There are many more things you need to care when you think from security aspect. Avoid globally write is surely one of them.

Happy coding šŸ™‚

 

 

Some ref.

https://help.ubuntu.com/community/FilePermissions
http://askubuntu.com/questions/79565/add-user-to-existing-group
http://www.cyberciti.biz/faq/linux-list-all-members-of-a-group/