Effective Java(第3版)(英文版)
1Introduction1
2CreatingandDestroyingObjects5
Item1:Considerstaticfactorymethodsinsteadofconstructors5
Item2:Considerabuilderwhenfacedwithmanyconstructorparameters10
Item3:Enforcethesingletonpropertywithaprivateconstructororanenumtype17
Item4:Enforcenoninstantiabilitywithaprivateconstructor19
查看完整
2CreatingandDestroyingObjects5
Item1:Considerstaticfactorymethodsinsteadofconstructors5
Item2:Considerabuilderwhenfacedwithmanyconstructorparameters10
Item3:Enforcethesingletonpropertywithaprivateconstructororanenumtype17
Item4:Enforcenoninstantiabilitywithaprivateconstructor19
查看完整
Joshua Bloch是Java 集合框架创办人,领导了很多 Java 平台特性的设计和实现,包括 JDK 5.0 语言增强以及屡获殊荣的 Java 集合框架。2004年6月他离开了SUN公司并成为 Google 的首席 Java 架构师。此外他还因为《Effective Java》一书获得著名的 Jolt 大奖。
自从Java 6发布之后,Java又有了翻天覆地的变化。本书涵盖了Java 7、Java 8和Java 9中语言和库的各种新特性。让你能够深入了解Java平台的细微之处。通过对每一个项目的全面描述和解释,告诉你应该做什么、不应该做什么,以及为什么要这样做。
1Introduction1
2CreatingandDestroyingObjects5
Item1:Considerstaticfactorymethodsinsteadofconstructors5
Item2:Considerabuilderwhenfacedwithmanyconstructorparameters10
Item3:Enforcethesingletonpropertywithaprivateconstructororanenumtype17
Item4:Enforcenoninstantiabilitywithaprivateconstructor19
Item5:Preferdependencyinjectiontohardwiringresources20
Item6:Avoidcreatingunnecessaryobjects22
Item7:Eliminateobsoleteobjectreferences26
Item8:Avoidfinalizersandcleaners29
Item9:Prefertry-with-resourcestotry-finally.34
3MethodsCommontoAllObjects37
Item10:Obeythegeneralcontractwhenoverridingequals37
Item11:AlwaysoverridehashCodewhenyouoverrideequals50
Item12:AlwaysoverridetoString55
Item13:Overrideclonejudiciously58
Item14:ConsiderimplementingComparable66
4ClassesandInterfaces73
Item15:Minimizetheaccessibilityofclassesandmembers73
Item16:Inpublicclasses,useaccessormethods,notpublicfields78
Item17:Minimizemutability80
Item18:Favorcompositionoverinheritance87
Item19:Designanddocumentforinheritanceorelseprohibitit93
Item20:Preferinterfacestoabstractclasses99
Item21:Designinterfacesforposterity104
Item22:Useinterfacesonlytodefinetypes.107
Item23:Preferclasshierarchiestotaggedclasses109
Item24:Favorstaticmemberclassesovernonstatic112
Item25:Limitsourcefilestoasingletop-levelclass115
5Generics.117
Item26:Don’tuserawtypes117
Item27:Eliminateuncheckedwarnings.123
Item28:Preferliststoarrays126
Item29:Favorgenerictypes.130
Item30:Favorgenericmethods135
Item31:UseboundedwildcardstoincreaseAPIflexibility139
Item32:Combinegenericsandvarargsjudiciously.146
Item33:Considertypesafeheterogeneouscontainers151
6EnumsandAnnotations157
Item34:Useenumsinsteadofintconstants.157
Item35:Useinstancefieldsinsteadofordinals168
Item36:UseEnumSetinsteadofbitfields169
Item37:UseEnumMapinsteadofordinalindexing.171
Item38:Emulateextensibleenumswithinterfaces176
Item39:Preferannotationstonamingpatterns180
Item40:ConsistentlyusetheOverrideannotation.188
Item41:Usemarkerinterfacestodefinetypes191
7LambdasandStreams193
Item42:Preferlambdastoanonymousclasses193
Item43:Prefermethodreferencestolambdas197
Item44:Favortheuseofstandardfunctionalinterfaces199
Item45:Usestreamsjudiciously203
Item46:Preferside-effect-freefunctionsinstreams210
Item47:PreferCollectiontoStreamasareturntype.216
Item48:Usecautionwhenmakingstreamsparallel222
8Methods227
Item49:Checkparametersforvalidity227
Item50:Makedefensivecopieswhenneeded231
Item51:Designmethodsignaturescarefully236
Item52:Useoverloadingjudiciously238
Item53:Usevarargsjudiciously245
Item54:Returnemptycollectionsorarrays,notnulls247
Item55:Returnoptionalsjudiciously249
Item56:WritedoccommentsforallexposedAPIelements254
9GeneralProgramming261
Item57:Minimizethescopeoflocalvariables261
Item58:Preferfor-eachloopstotraditionalforloops264
Item59:Knowandusethelibraries267
Item60:Avoidfloatanddoubleifexactanswersarerequired270
Item61:Preferprimitivetypestoboxedprimitives273
Item62:Avoidstringswhereothertypesaremoreappropriate276
Item63:Bewaretheperformanceofstringconcatenation279
Item64:Refertoobjectsbytheirinterfaces280
Item65:Preferinterfacestoreflection282
Item66:Usenativemethodsjudiciously.285
Item67:Optimizejudiciously286
Item68:Adheretogenerallyacceptednamingconventions289
10Exceptions293
Item69:Useexceptionsonlyforexceptionalconditions293
Item70:Usecheckedexceptionsforrecoverableconditionsandruntimeexceptionsforprogrammingerrors296
Item71:Avoidunnecessaryuseofcheckedexceptions298
Item72:Favortheuseofstandardexceptions.300
Item73:Throwexceptionsappropriatetotheabstraction.302
Item74:Documentallexceptionsthrownbyeachmethod.304
Item75:Includefailure-captureinformationindetailmessages.306
Item76:Striveforfailureatomicity308
Item77:Don’tignoreexceptions310
11Concurrency311
Item78:Synchronizeaccesstosharedmutabledata311
Item79:Avoidexcessivesynchronization317
Item80:Preferexecutors,tasks,andstreamstothreads323
Item81:Preferconcurrencyutilitiestowaitandnotify325
Item82:Documentthreadsafety330
Item83:Uselazyinitializationjudiciously333
Item84:Don’tdependonthethreadscheduler336
12Serialization339
Item85:PreferalternativestoJavaserialization339
Item86:ImplementSerializablewithgreatcaution343
Item87:Considerusingacustomserializedform346
Item88:WritereadObjectmethodsdefensively353
Item89:Forinstancecontrol,preferenumtypestoreadResolve359
Item90:Considerserializationproxiesinsteadofserializedinstances363
ItemsCorrespondingtoSecondEdition367
References.371
Index377
^ 收 起
2CreatingandDestroyingObjects5
Item1:Considerstaticfactorymethodsinsteadofconstructors5
Item2:Considerabuilderwhenfacedwithmanyconstructorparameters10
Item3:Enforcethesingletonpropertywithaprivateconstructororanenumtype17
Item4:Enforcenoninstantiabilitywithaprivateconstructor19
Item5:Preferdependencyinjectiontohardwiringresources20
Item6:Avoidcreatingunnecessaryobjects22
Item7:Eliminateobsoleteobjectreferences26
Item8:Avoidfinalizersandcleaners29
Item9:Prefertry-with-resourcestotry-finally.34
3MethodsCommontoAllObjects37
Item10:Obeythegeneralcontractwhenoverridingequals37
Item11:AlwaysoverridehashCodewhenyouoverrideequals50
Item12:AlwaysoverridetoString55
Item13:Overrideclonejudiciously58
Item14:ConsiderimplementingComparable66
4ClassesandInterfaces73
Item15:Minimizetheaccessibilityofclassesandmembers73
Item16:Inpublicclasses,useaccessormethods,notpublicfields78
Item17:Minimizemutability80
Item18:Favorcompositionoverinheritance87
Item19:Designanddocumentforinheritanceorelseprohibitit93
Item20:Preferinterfacestoabstractclasses99
Item21:Designinterfacesforposterity104
Item22:Useinterfacesonlytodefinetypes.107
Item23:Preferclasshierarchiestotaggedclasses109
Item24:Favorstaticmemberclassesovernonstatic112
Item25:Limitsourcefilestoasingletop-levelclass115
5Generics.117
Item26:Don’tuserawtypes117
Item27:Eliminateuncheckedwarnings.123
Item28:Preferliststoarrays126
Item29:Favorgenerictypes.130
Item30:Favorgenericmethods135
Item31:UseboundedwildcardstoincreaseAPIflexibility139
Item32:Combinegenericsandvarargsjudiciously.146
Item33:Considertypesafeheterogeneouscontainers151
6EnumsandAnnotations157
Item34:Useenumsinsteadofintconstants.157
Item35:Useinstancefieldsinsteadofordinals168
Item36:UseEnumSetinsteadofbitfields169
Item37:UseEnumMapinsteadofordinalindexing.171
Item38:Emulateextensibleenumswithinterfaces176
Item39:Preferannotationstonamingpatterns180
Item40:ConsistentlyusetheOverrideannotation.188
Item41:Usemarkerinterfacestodefinetypes191
7LambdasandStreams193
Item42:Preferlambdastoanonymousclasses193
Item43:Prefermethodreferencestolambdas197
Item44:Favortheuseofstandardfunctionalinterfaces199
Item45:Usestreamsjudiciously203
Item46:Preferside-effect-freefunctionsinstreams210
Item47:PreferCollectiontoStreamasareturntype.216
Item48:Usecautionwhenmakingstreamsparallel222
8Methods227
Item49:Checkparametersforvalidity227
Item50:Makedefensivecopieswhenneeded231
Item51:Designmethodsignaturescarefully236
Item52:Useoverloadingjudiciously238
Item53:Usevarargsjudiciously245
Item54:Returnemptycollectionsorarrays,notnulls247
Item55:Returnoptionalsjudiciously249
Item56:WritedoccommentsforallexposedAPIelements254
9GeneralProgramming261
Item57:Minimizethescopeoflocalvariables261
Item58:Preferfor-eachloopstotraditionalforloops264
Item59:Knowandusethelibraries267
Item60:Avoidfloatanddoubleifexactanswersarerequired270
Item61:Preferprimitivetypestoboxedprimitives273
Item62:Avoidstringswhereothertypesaremoreappropriate276
Item63:Bewaretheperformanceofstringconcatenation279
Item64:Refertoobjectsbytheirinterfaces280
Item65:Preferinterfacestoreflection282
Item66:Usenativemethodsjudiciously.285
Item67:Optimizejudiciously286
Item68:Adheretogenerallyacceptednamingconventions289
10Exceptions293
Item69:Useexceptionsonlyforexceptionalconditions293
Item70:Usecheckedexceptionsforrecoverableconditionsandruntimeexceptionsforprogrammingerrors296
Item71:Avoidunnecessaryuseofcheckedexceptions298
Item72:Favortheuseofstandardexceptions.300
Item73:Throwexceptionsappropriatetotheabstraction.302
Item74:Documentallexceptionsthrownbyeachmethod.304
Item75:Includefailure-captureinformationindetailmessages.306
Item76:Striveforfailureatomicity308
Item77:Don’tignoreexceptions310
11Concurrency311
Item78:Synchronizeaccesstosharedmutabledata311
Item79:Avoidexcessivesynchronization317
Item80:Preferexecutors,tasks,andstreamstothreads323
Item81:Preferconcurrencyutilitiestowaitandnotify325
Item82:Documentthreadsafety330
Item83:Uselazyinitializationjudiciously333
Item84:Don’tdependonthethreadscheduler336
12Serialization339
Item85:PreferalternativestoJavaserialization339
Item86:ImplementSerializablewithgreatcaution343
Item87:Considerusingacustomserializedform346
Item88:WritereadObjectmethodsdefensively353
Item89:Forinstancecontrol,preferenumtypestoreadResolve359
Item90:Considerserializationproxiesinsteadofserializedinstances363
ItemsCorrespondingtoSecondEdition367
References.371
Index377
^ 收 起
Joshua Bloch是Java 集合框架创办人,领导了很多 Java 平台特性的设计和实现,包括 JDK 5.0 语言增强以及屡获殊荣的 Java 集合框架。2004年6月他离开了SUN公司并成为 Google 的首席 Java 架构师。此外他还因为《Effective Java》一书获得著名的 Jolt 大奖。
自从Java 6发布之后,Java又有了翻天覆地的变化。本书涵盖了Java 7、Java 8和Java 9中语言和库的各种新特性。让你能够深入了解Java平台的细微之处。通过对每一个项目的全面描述和解释,告诉你应该做什么、不应该做什么,以及为什么要这样做。
比价列表