Learning JavaScript Design Patterns
'via Blog this'
Saturday, February 14, 2015
Thursday, February 12, 2015
JavaScript Patterns
http://shichuan.github.io/javascript-patterns/
var a = 1
, b = 2
, sum = a + b
, myobject = {}
, i
, j;
var global = (function () {
return this || (1, eval)('this');
}());
var getData = function getData () {
};
var a = 1
, b = 2
, sum = a + b
, myobject = {}
, i
, j;
var global = (function () {
return this || (1, eval)('this');
}());
var getData = function getData () {
};
Saturday, January 31, 2015
SMS-REST, EMAIL-REST Proxy
Разработать итрерфейс для sms сообщений который будет перенаправляться в REST-full API
Пример:
REST: some-app/books/find?author='Tolstoy'&name='Voina i Mir'
SMS: some-app.books.find author: Tolstoy name: Voina i Mir
- Use google voice as sms gate.
- Bind phone and app and bind incomming phone with user
- Think how to deal with captchas ? Dbc?
- Use YAML as basic syntax for requests and function data schema defenitions.
- Response will be sent back to the same number in YAML like format
- User ruby function call syntax:
E.g: books.store name: Onegin, author: Pushkin, note: This is a very good book. | I realy liked it.
| - new line symbol.
- Possible use of other sms gateways
- Implement the same for email. same sintax. Bind email and
- Sdelat' mobile app
- Try other sms gates
---------
Try to make watsup-rest proxy, facebook-rest proxy, vk-rest proxy
Пример:
REST: some-app/books/find?author='Tolstoy'&name='Voina i Mir'
SMS: some-app.books.find author: Tolstoy name: Voina i Mir
- Use google voice as sms gate.
- Bind phone and app and bind incomming phone with user
- Think how to deal with captchas ? Dbc?
- Use YAML as basic syntax for requests and function data schema defenitions.
- Response will be sent back to the same number in YAML like format
- User ruby function call syntax:
E.g: books.store name: Onegin, author: Pushkin, note: This is a very good book. | I realy liked it.
| - new line symbol.
- Possible use of other sms gateways
- Implement the same for email. same sintax. Bind email and
- Sdelat' mobile app
- Try other sms gates
---------
Try to make watsup-rest proxy, facebook-rest proxy, vk-rest proxy
Thursday, January 29, 2015
Naming conventions: camelCase versus underscore_case ? what are your thoughts about it? - Programmers Stack Exchange
Source>> stackexchange forum
Some comment: Absolutely agree it bothers me too
1. call to action notation - first word is action in lower case then camel case
collection->findFirst(...)
obj->getName()
2. No action method naming
App::log()
DB::table('users')->lastMonth()->get()
I like when lower case part is either proverb or adjective
e.g
lastMonth
firstElement
xmlPath
In method camel case first lwcase word should be specification
and last one the most general one eg (object type)
Functions:
1. Javascript style
function onSaveHanlder
2. PHP/Ruby style
send_email()
CSS
1. hyphen/slug style
class="save-btn"
id="header-container-section" // logic structure: first root element then child then child-child
Summary:
In general I like ruby naming convention and ruby approach for naming:
-readability
-clarity
-conciseness (short better then long without lose of clarity)
Not sure about snake case methods: I would use it only for properties instead of getter setter
Private fields should be prefixed with underscore :
eg: private $_items;
Both!
I do a lot of development in CakePHP, and I use either
CamelCase
or $underscored_vars
, in the following fashion (even outside CakePHP Projects):- filenames —
/lowercased_underscored.php
Typical, but worth mentioning. - classes —
class CamelCase extends ParentObject
. Note that, when usingCamelCase
, the initial character is not lowercase. I findcamelCase
to look really weird. - variables —
$are_variables_underscored === TRUE;
- variables that hold instances —
$CamelCase = new CamelCase();
//seen it in qb lib but in some languages like ruby everything is a class - array keys —
$collection['underscored_keys'];
- constants — I think everyone can agree that constants should be
ALL_CAPS_AND_UNDERSCORED
. - methods —
$CamelCase->foo_method_underscored();
- static methods —
CamelCase::just_like_regular_methods();
Some comment: Absolutely agree it bothers me too
have to agree with you, having the first character be lower case drives me crazy! I hate camelCase with a passion. – HLGEM Jan 6 '11 at 22:00
|
For programming languages I've used, like Java, Python, C++, I've adopted a clear format:
- ClassNamesArePascalCase
- methodNamesAreCamalCase
- variable_names_are_underscore
- CONSTANT_VARIABLES_ARE_CAPITAL_VARIABLES
- _private_variable_names_are_prefixed_with_an_underscore
- _PRIVATE_CONSTANT_VARIABLES_ARE_PREFIXED_WITH_AN_UNDERSCORE
Another aspect of naming convention is words order:
1. ModelCallReport or CallReportModel
create_date or date_create
In PHP main principle of global function creation in having one prefix for same group of functions
It makes it easier to search them
array_mapClass methods:
array_filter
1. call to action notation - first word is action in lower case then camel case
collection->findFirst(...)
obj->getName()
2. No action method naming
App::log()
DB::table('users')->lastMonth()->get()
I like when lower case part is either proverb or adjective
e.g
lastMonth
firstElement
xmlPath
In method camel case first lwcase word should be specification
and last one the most general one eg (object type)
Functions:
1. Javascript style
function onSaveHanlder
2. PHP/Ruby style
send_email()
CSS
1. hyphen/slug style
class="save-btn"
id="header-container-section" // logic structure: first root element then child then child-child
2. camel
name="first_name"
3. Bootstrap style (spesialization frist the most general)
class="btn btn-sm btn-default" // logic structure: type then size the color
name="first_name"
3. Bootstrap style (spesialization frist the most general)
class="btn btn-sm btn-default" // logic structure: type then size the color
Some people use camel case for css I dond like it
Summary:
In general I like ruby naming convention and ruby approach for naming:
-readability
-clarity
-conciseness (short better then long without lose of clarity)
Not sure about snake case methods: I would use it only for properties instead of getter setter
Private fields should be prefixed with underscore :
eg: private $_items;
Sunday, December 28, 2014
No more JS frameworks | BitWorking
No more JS frameworks | BitWorking:
Browsers got better. With newer standards like
'via Blog this'
Browsers got better. With newer standards like
HTML Imports, HTML Templates, Custom Elements, and Shadow DOM are the enabling technologies that should allow us to cut the cord from frameworks
http://webcomponents.org/
https://www.polymer-project.org/docs
https://mozbrick.github.io/
http://www.x-tags.org/docs
'via Blog this'
Thursday, December 18, 2014
Subscribe to:
Posts (Atom)