- Почему глобальные объекты и статика — это зло? Можете показать на примере кода?
- Расскажите об инверсии управления и как она улучшает организацию кода.
- Закон Деметры (Принцип минимальной информированности) гласит, что каждый программный модуль должен обладать ограниченным знанием о других модулях и должен взаимодействовать только с непосредственными «друзьями» (иногда его формулируют как «Не разговаривай с незнакомцами»). Можете написать код, который нарушает этот принцип? Почему у него плохая организация и как её исправить?
- Active-Record — шаблон проектирования, который поощряет внедрение в сам объект функций, таких как Insert, Update и Delete, и свойств, которые соответствуют столбцам некоей базовой таблицы в базе данных. По вашему мнению и опыту, какие ограничения и подводные камни у этого шаблона?
- Data-Mapper — шаблон проектирования, который поощряет использование слоя преобразователей (mappers), перемещающих данные между объектами и базой данных, в то же
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5.3 namespaces, closures | |
5.4 traits, short array syntax | |
5.5 finaly, generators | |
5.6 variadic functions, argument unpacking | |
7.0 return types, scalar type hints | |
7.1 const visibility, nullables, multiple exceptions | |
7.2 object type hint, abstract function override | |
5.3 - namespaces | |
- closures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"runtime" | |
"sync" | |
"sync/atomic" | |
"time" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"sync" | |
"time" | |
"fmt" | |
) | |
//$ go run -race main_mutex.go | |
//610917 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"sync" | |
"time" | |
"fmt" | |
) | |
type mutexCounter struct { | |
mu sync.Mutex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"runtime" | |
"sync/atomic" | |
"time" | |
) | |
//$ go run -race main_atomic.go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"sync" | |
"time" | |
"fmt" | |
) | |
type mutexCounter struct { | |
mu sync.Mutex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Restore a melody from the file | |
*/ | |
private class RestoreMelodiListener implements ActionListener { | |
@Override | |
public void actionPerformed(ActionEvent a) { | |
boolean[] checkboxState = null; | |
try { | |
JFileChooser fin = new JFileChooser(); | |
fin.showOpenDialog(theFrame); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .bash_profile | |
# Get the aliases and functions | |
if [ -f ~/.bashrc ]; then | |
. ~/.bashrc | |
fi | |
# User specific environment and startup programs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* "Happy Birthday, Alexander!" | |
* | |
* $Hb = new Hb; | |
* $Hb->main(); | |
*/ | |
class Hb | |
{ | |
protected $HbText = "01001000 01100001 01110000 01110000 01111001 00100000 01000010 01101001 01110010 01110100 01101000 01100100 01100001 01111001 00101100 00100000 01000001 01101100 01100101 01111000 01100001 01101110 01100100 01100101 01110010 00100001"; |