기본 콘텐츠로 건너뛰기

2016의 게시물 표시

Directory FileName Sort

C#에서 Directory.GetFiles(<Path>) 에서 파일명으로 Sort를 할필요성이 있다. Files 배열을 받아서 Sort를 할수도 있지만, Directory class 에서 Sort 기능도 제공을 하는데, LINQ에 Sort 기능을 제공한다. To sort by name, var sorted = Directory . GetFiles ( "." ). OrderBy ( f => f ); To sort by size, var sorted = Directory . GetFiles ( "." ). OrderBy ( f => new FileInfo ( f ). Length ); 참고   http://stackoverflow.com/questions/6294275/sorting-the-result-of-directory-getfiles-in-c-sharp

C# Namespace Naming Guidelines

The general rule for naming namespaces is to use the company name followed by the technology name and optionally the feature and design as follows. CompanyName.TechnologyName[.Feature][.Design] For example: Microsoft.Media Microsoft.Media.Design Prefixing namespace names with a company name or other well-established brand avoids the possibility of two published namespaces having the same name. For example,  Microsoft.Office  is an appropriate prefix for the Office Automation Classes provided by Microsoft. Use a stable, recognized technology name at the second level of a hierarchical name. Use organizational hierarchies as the basis for namespace hierarchies. Name a namespace that contains types that provide design-time functionality for a base namespace with the  .Design  suffix. For example, the  System.Windows.Forms.Design Namespace  contains designers and related classes used to design  System.Windows.Forms...

String, StringBuffer, StringBuilder is Difference

1. String 1-1. 특징 - String 객체는 immutable 이다 . 즉 , 한번 생성되면 String 객체가 변할 수 없다 . - 문자열 , 숫자 , char 등을 concat 할때는 StringBuffer, StringBuilder 를 사용할 수 있지만 단순한 경우에는 + 를 활용해 직접 합쳐도 된다 . - 수정할 경우, 수정마다 매번 새로운 객체를 생성함. 2. StringBuffer 와 StringBuilder 차이점 2-1. 특징 - 기본적으로 두 클래스가 제공하는 메소드는 동일하지만   StringBuffer 는 멀티 쓰레드 상태에서 동기화를 지원 한다 . ( 각 메소드 별로 synchronized 키워드가 존재 ) - String 을 + 를 활용해 합치는 경우 매번 인스턴스를 생성하기 때문에 성능상에 이슈가 많다 . 이런 성능 이슈를 개선하기위해  JDK 1.5 버전 이후에는 컴파일 단계에서 StringBuilder 로 컴파일 되도록 변경되기 때문에 + 를 활용해도 성능상에 큰 이슈는 없다 . 3. 추가내용 3-2. String 클래스는 변경이 불가능한 immutable 클래스이다 . - StringBuffer 클래스가 String 클래스 보다 항상 더 나은 성능을 가지고 있다면 왜 자바를 설계한 사람들은 String 클래스를 기본 문자열처리 클래스로 정했을까 ? - substring(), toLowerCase(), concat(), trim() 등의 메소드를 생각하면 String 클래스는 변경이 가능한 클래스처럼 보이지만 실제로는 이러한 메소드들은 원래 객체와 다른 새로운 String 객체를 만들어 반환한다 . 또 하나의 String 객체가 생성되기 때문에 원래 String 객체는...

MongoDB 백업 및 복구방법

MongoDB 백업 및 복구방법 MongoDB 데이터 저장 디렉토리 설정(Windows) -> 보통 Default 로 "C:\data\db\" 로 지정되나, 혹시 디렉토리 설정을 바꿔서 모를경우에는 아래와 같이 명령어를 통해서 확인한다. mongodb --dbpath [arg-path] mongodb -v 명령어를 통해서 dbpath 경로를 확인할수 있다. local dump # mongodump -d [dbname] -o [dirname] Remote dump # mongodump --host mongodb1.example.net --port 37017 --username user --password pass /opt/backup/mongodump-2011-10-24 Mongorestore # mongorestore -h 127.0.0.1 "D\mongoDB\"