投稿時間:2021-10-25 05:15:42 RSSフィード2021-10-25 05:00 分まとめ(19件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) 売上テーブルから集計用テーブルへ会員ごとの売上額を合算して更新したい https://teratail.com/questions/366044?rss=all 売上テーブルから集計用テーブルへ会員ごとの売上額を合算して更新したい売上テーブルから集計用テーブルへ会員ごとの売上額を合算して更新したい売上テーブルuriagetotalと集計用テーブルrfmanalyticsrawtotalがあります。 2021-10-25 04:14:23
海外TECH DEV Community We should write Java code differently https://dev.to/siy/we-should-write-java-code-differently-210b We should write Java code differentlyFor the last few years I m writing articles which describe a new more functional way to write Java code But the question of why we should use this new coding style remains largely unanswered This article is an attempt to fill this gap Just like any other language Java evolves over the time So does the style in which Java code is written Code written around YK is significantly different from code written after when Java and then Java were released Generics and annotations are so widespread now that it s hard to even imagine Java code without them Then came Java with lambdas Stream lt T gt and Optional lt T gt Those functional elements should be revolutionizing Java code but largely they don t In a sense they definitely affected how we write Java code but there were no revolution Rather slow evolution Why Let s try to find the answer I think that there were two main reasons The first reason is that even Java authors felt uncertainty how new functional elements fit into existing Java ecosystem To see this uncertainty it s enough to read Optional lt gt JavaDoc API Note Optional is primarily intended for use as a method return type where there is a clear need to represent no result and where using null is likely to cause errors API also shows the same presence of get method which may throw NPE as well as a couple of orElseThrow methods are clear reverences to traditional imperative Java coding style The second reason is that existing Java code especially libraries and frameworks was incompatible with functional approaches null and business exceptions were the idiomatic Java code Fast forward to present time Java released few weeks ago Java is quickly getting wide adoption replacing Java which was ubiquitous a couple of years ago Yet our code looks almost the same as years ago when Java was released Perhaps it s worth to step back and answer another important question do we need to change the way in which we re writing Java code at all It served us good enough for long time we have skills guides best practices and tons of books which teach us how to write code in this stile Do we actually need to change that I believe the answer to this question could be derived from the answer to another question do we need to improve the development performance I bet we do Business pushes developers to deliver apps faster Ideally projects we re working on should be written tested and deployed before business even realizes what actually need to be implemented Just kidding of course but delivery date yesterday is a dream of many business people So we definitely need to improve development performance Every single framework IDE methodology design approach etc etc focuses on improving the speed at which software of course with necessary quality standards is implemented and deployed Nevertheless despite all these there is no visible development performance breakthroughs Of course there are many elements which define the pace at which software is delivered This article focuses only on development performance From my perspective most attempts to improve development performance are assuming that writing less code and less code in general automatically means better performance Popular libraries and frameworks like Spring Lombok Feign all trying to reduce amount of code Even Kotlin was created with obsession on brevity as opposed to Java verbosity History did prove this assumption wrong many times Perl and APL perhaps most notable examples nevertheless it s still alive and drives most efforts Any developer knows that writing code is a tiny portion of the development activities Most of the time we re reading code Is reading less code more productive The first intent is to say yes but in practice the amount of code and its readability are barely related Reading and writing of the same code often has different impedance in the form of mental overhead Probably the best examples of this difference in the impedance are regular expressions Regular expressions are quite compact and in most cases rather easy to write especially using countless dedicated tools But reading regular expressions usually is a pain and consumes much more time Why The reason is the lost context When we re writing regular expression we know the context what we want to match which cases should be considered how possible input may look like and so on and so forth The expression itself is a compressed representation of this context But when we re reading them the context is lost or to be precise squeezed and packed using very compact syntax And attempt to decompress it from the regular expression is a quite time consuming task In some cases rewriting from scratch takes significantly less time than an attempt to understand existing code The example above gives one important hint reducing the amount of code is meaningful only to the point where context remains preserved As soon as reducing code causes loss of context it starts to be counterproductive and harms development performance So if code size is not so relevant then how we really can improve productivity Obviously by preserving and or restoring lost context But when and why context is getting lost Context EatersContext Eaters are coding practices or approaches which results to the context loss Idiomatic Java code has several such context eaters Popular frameworks often add their context eaters Let s take a look at the two most ubiquitous context eaters Nullable VariablesYes you read it correctly Nullable variables hide part of the context cases when variable value might be missing Look at this code example String value service method parameter Just by looking at this code you can t tell if value can be null or not In other words part of the context is lost To restore it one needs to take a look into the code of the service method and analyze it Navigation to that method reading its code returning all these are a distraction from the current task And the constant need to keep in mind that a variable might be null causes a mental overhead Experienced developers are good at keeping such things in mind but this does not mean that this mental overhead does not affect their development performance Let s sum up Nullable variables are context eaters development performance killers and source of run time errors ExceptionsIdiomatic Java uses business exceptions for the error propagation and handling There are two types of exceptions checked and unchecked Use of checked exceptions usually discouraged and often considered an antipattern because they cause deep code coupling Although the initial intent of introduction of checked exceptions by the way was preserving the context And compiler even helps to preserve it Nevertheless over the time we ve switched to unchecked exceptions Unchecked exceptions were designed for the technical errors accessing null variable attempt to access value outside the array bounds etc Think about this for a moment we re using technical unchecked exceptions for the business error handling and propagation Use of the language feature outside the area it was designed for results in loss of context and issues similar to ones described for nullable variables Even reasons are the same unchecked exceptions require navigation and reading code often quite deep in the call chain They also require switching back and forth between current task and error handling And just like nullable variables exceptions can be a source of run time errors if not processed correctly Summary Business exceptions are context eaters development performance killers and source of bugs Frameworks as Context EatersSince frameworks are usually specific to a particular project issues caused by them are also project specific Nevertheless if you got the idea of context loss preservation you might notice that popular frameworks like Spring and others which use class path scan convention over configuration idiom and other magic intentionally remove large part of the context and replace it with implicit knowledge of the default setup i e mental overhead With this approach the application gets broken into a set of loosely related classes Without IDE support it s even hard to navigate between components so disconnected they are Besides loss of huge part of context there is another significant problem which negatively impacts productivity significant number of errors are shifted from compile time to run time Consequences are devastating more tests are necessary Famous contextLoads test is a clear sign of this problemsoftware support and maintenance requires significantly more time and effortsSo by reducing typing for a few lines of code we re getting a lot of headache and decreased development performance This is the real price of the magic Pragmatic Functional Java WayThe Pragmatic Functional Java is an attempt to solve problems some problems mentioned above While initial intent was to just preserve context by encoding special states into variable type practical use did show a number of other benefits of taken approach significantly reduced navigationa number of errors are shifted from run time to compile time which in turn improved reliability and reduced number of necessary testsremoved significant portion of boilerplate and even type declarations less typing less code to read business logic is less cluttered with technical detailssensibly less mental overhead and need to keep in mind technical things not related to current task 2021-10-24 19:29:42
海外TECH DEV Community Testing Solid.js code beyond jest https://dev.to/lexlohr/testing-solidjs-code-beyond-jest-39p Testing Solid js code beyond jestSo you started writing an app or library in Solid js and TypeScript what an excellent choice but now you want to unit test everything as fast as possible to avoid regressions We already know how to do this with jest but while it is pretty convenient and quite easy to set up it s also considerably slow and somewhat opinionated Unlike more lightweight test runners it also has a built in code transformation API a jsdom based DOM environment and chooses browser conditional exports by default So what we need to run our tests without jest is Code transformationDOM environmentChoosing browser exports solid registerTo save even more of your precious time I already did all this work for you You just need to installnpm i save dev solid register jsdomand run your test runner with test runner that supports the r register argument testrunner r solid register test runner without support for the r argumentnode r solid register node modules bin testrunner Test runnerYou certainly have a lot of options besides jest uvu fastest but lacks some features tape fast modular extendable many forks or extensions like supertape tabe tappedout ava still fast bron tiny almost no features fast karma a bit slower but very mature test turtle somewhat slower for a full test but only runs tests that test files that failed or changed since the last run jasmine somewhat full featured test system that jest is partially based on and probably a lot more I couldn t test them all so I ll focus on uvu and tape Both support the register argument so all you need to do is to install themnpm i save dev uvu ornpm i save dev tapeand add a script to your project scripts test uvu r solid register test tj s test tj sx or scripts test tape r solid register test tj s test tj sx Now you can unit test your projects with npm test The following examples are written for uvu but it should be trivial adapting them to tape or any other test runner Testing a custom primitive hook Imagine you have a reusable reactive function for Solid js that doesn t render anything and therefore don t need to use render As an example let s test a function that returns a number of words or Lorem ipsum text const loremIpsumWords Lorem ipsum dolor sit amet consectetur adipisici elit sed eiusmod tempor incidunt ut labore et dolore magna aliqua Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur Excepteur sint obcaecat cupiditat non proident sunt in culpa qui officia deserunt mollit anim id est laborum split s const createLorem words Accessor lt number gt number gt return createMemo gt const output len typeof words function words words while output length lt len output push loremIpsumWords return output slice len join We need to wrap our test s actions in a reactive root to allow subscription to Accessors like words For uvu this looks like this in tape the assertions are in the first argument that the test call receives everything else is pretty similar import createEffect createRoot createSignal from solid js import suite from uvu import as assert from uvu assert const testLorem suite createLorem testLorem it updates the result when words update async gt const input expectedOutput Lorem ipsum dolor Lorem ipsum Lorem ipsum dolor sit amet const actualOutput await new Promise lt string gt resolve gt createRoot dispose gt const words setWords createSignal input shift const lorem createLorem words const output string createEffect gt effects are batched so the escape condition needs to run after the output is complete if input length dispose resolve output output push lorem setWords input shift assert equal actualOutput expectedOutput output differs testLorem run Testing directives use Next we want to test the solid primitive fullscreen primitive which doubles as directive and exposes something similar to the following API export type FullscreenDirective ref HTMLElement active Accessor lt boolean FullscreenOptions gt gt void and is used like this in Solid js const fs setFs createSignal false return lt div use FullscreenDirective fs gt lt div gt You could argue that you want to avoid implementation details and therefore render a component exactly like the one above but we don t need to render anything because that would mean us testing the implementation detail of Solid js directive interface So you can have a look at the test in the solid primitives repository Testing componentsFirst of all we need to install solid testing library Unfortunately we cannot use testing library jest dom here but the main extensions to jest s expect are easily replicated npm i save dev solid testing libraryWe want to test the following simple component import createSignal Component JSX from solid js export const MyComponent Component lt JSX HTMLAttributes lt HTMLDivElement gt gt props gt const clicked setClicked createSignal false return lt div props role button onClick gt setClicked true gt clicked Test this Click me lt div gt Our test now looks like this import suite from uvu import as assert from uvu assert import screen render fireEvent from solid testing library import MyComponent from my component const isInDom node Node boolean gt node parentNode amp amp node parentNode document isInDom node parentNode const test suite MyComponent test changes text on click async gt await render gt lt MyComponent gt const component await screen findByRole button name Click me assert ok isInDom component fireEvent click component assert ok isInDom await screen findByRole button name Test this Running all three tests in uvu with the default settings takes s whereas running them in jest using a fast babel jest setup takes s on my box More missing functionalityCompared to jest there s even more functionality missing both in uvu and tape simple mocks spiestimer mockscode coverage collectionwatch modeextendable assertionssnapshot testingWith uvu a lot of these functions can be added through external helpers some are shown in the examples e g coverageand watch and some more not documented there like snoop to add spies For tape there is a whole lot of modules But remember functionality that you don t run does not waste your time May your tests catch all the bugs But how did I do it You can safely skip the next part if you are not interested in the details you should already know enough to test your solid projects with something other than jest The following code is a reduced version of solid register to mainly show the underlying principles Code compilationNode has an API that allows us to hook into the loading of files require d and register the transpilation code We have again three options to do this for us babel register is using babel to transpile the code is fast but does not support type checkingts node uses ts server to transpile the code and provides type safety at the expense of compile timeWe can roll our own solution with babel that allows us to use different presets for different files babel registerTo use babel register we need to installnpm i save dev babel core babel register babel preset env babel preset typescript babel preset solidNow we have to use it inside our compilation babel ts to combine it with the options required to compile our solid files require babel register presets babel preset env babel preset solid babel preset typescript extensions jsx tsx ts mjs ts nodeWhile the main point of this package is to provide an interactive typescript console you can also use it to run typescript directly in node We can install it like this npm i save dev ts jest babel preset solid babel preset envOnce installed we can use it in our compilation ts node ts require ts node register babelConfig presets babel preset solid babel preset env Our own solutionWhy would we want our own solution Both babel register and ts jest only allow us to set up a single set of presets to compile the modules which means that some presets may run in vain e g typescript compilation for js files Also this allows us to handle files not taken care of by these solutions see Bonus chapters As a preparation we create our solid register directory and in it init our repo and install our requirements npm initnpm i save dev babel core babel preset env babel preset typescript babel preset solid typescript types nodeHow do babel register and ts jest automatically compile imports They use the unfortunately deprecated and woefully underdocumented but still workable require extensions API to inject itself into the module loading process of node The API is rather simple pseudo code to explain the API it s a bit more complex in reality require extensions extension string js module module filename string gt const content readFromCache module fs readFileSync filename UTF module compile content filename In order to simplify wrapping it we create our own src register extension ts with the following method that we can reuse later export const registerExtension extension string string compile code string filename string gt string gt if Array isArray extension extension forEach ext gt registerExtension ext compile else const modLoad require extensions extension require extensions js require extensions extension module NodeJS Module filename string gt const mod module as NodeJS Module amp compile code gt void const modCompile mod compile bind mod mod compile code gt modCompile compile code filename modLoad mod filename Now we can start compiling our solid code by creating the file src compile solid ts containing const transformSync require babel core const presetEnv require babel preset env const presetSolid require babel preset solid const presetTypeScript require babel preset typescript import registerExtension from register extension registerExtension jsx code filename gt transformSync code filename presets presetEnv presetSolid registerExtension ts code filename gt transformSync code filename presets presetEnv presetTypeScript registerExtension tsx code filename gt transformSync code filename presets presetEnv presetSolid presetTypeScript Bonus Filename aliasesIf we don t want to use the conditions flag to choose the browser version we can also use aliases for certain filenames to force node to choose the browser exports from solid To do so we create src compile aliases ts const aliases solid js dist server solid js dist dev solid js web dist server solid js web dist dev add your own here const alias regexes Object keys aliases reduce regexes match gt regexes match new RegExp match return regexes const filenameAliasing filename gt Object entries aliases reduce name match replace gt name amp amp alias regexes match test filename filename replace alias regexes match replace name null filename const extensions js jsx ts tsx extensions forEach ext gt const loadMod require extensions ext require extensions js require extensions ext module NodeJS Module filename string gt loadMod module filenameAliasing filename Bonus CSS loaderWhen we import file css we usually tell our build system to load the css code into the current page using its internal loader and if it is a CSS module provide the class names in the import By providing our own loader for css and module css we can have the same experience in node and allow our DOM to actually access the styles So we write the following code in our own src compile css ts import registerExtension from register extension const loadStyles filename string styles string gt if document querySelector data filename filename const div document createElement div div innerHTML lt style data filename filename gt styles lt style gt document head appendChild div firstChild styles replace import g requiredFile gt try require requiredFile catch e console warn attempt to import css requiredFile failed const toCamelCase name string string gt name replace w g char gt char toUpperCase const getModuleClasses styles Record lt string string gt gt const identifiers Record lt string string gt styles replace r n s w w keyframes s s r n r n s g classname animation gt if classname identifiers classname identifiers toCamelCase classname classname if animation identifiers animation identifiers toCamelCase animation animation return identifiers registerExtension css styles filename gt loadStyles filename styles registerExtension module css styles filename gt loadStyles filename styles module exports JSON stringify getModuleClasses styles Bonus asset loaderThe vite server from the solidjs templates ts starter allows us to get the paths from asset imports By now you should now the drill and you could probably write src compile assets ts yourself import registerExtension from register extension const assetExtensions svg png gif jpg jpeg registerExtension assetExtensions filename gt module exports assets filename replace There is also support for raw paths in vite If you want you can extend this part to support them the current version of solid register at the time of writing this article has no support for it yet DOM environmentAs for the compilation we do have different options for the DOM environment jsdom full featured but slow the default option in jesthappy dom more lightweightlinkedom fastest but lacks essential featuresUnfortunately happy dom is currently not fully tested and linkedom will not really work with solid testing library so using them is discouraged at the moment jsdomSince jsdom is basically meant to be used like this registering it is simple import JSDOM from jsdom const window new JSDOM lt doctype html gt lt html gt lt head gt lt head gt lt body gt lt body gt lt html gt url https localhost Object assign globalThis window happy domimport Window from happy dom const window new Window window location href https localhost for const key of Object keys window if globalThis as any key undefined amp amp key undefined globalThis as any key window as any key linkedomTo create our DOM environment the following will suffice prerequisitesconst parseHTML require linkedom parseHTML const emptyHTML lt doctype html gt lt html lang en gt lt head gt lt title gt lt title gt lt head gt lt body gt lt body gt lt html gt create DOMconst window document Node HTMLElement requestAnimationFrame cancelAnimationFrame navigator parseHTML emptyHTML put DOM into global contextObject assign globalThis window document Node HTMLElement requestAnimationFrame cancelAnimationFrame navigator Lastly you can put all this together with some config reading function like I did If you ever have to create a similar package for your own custom transpiled framework I hope you ll stumble over this article and it ll help you Thanks for your patience I hope I didn t wear it out too much 2021-10-24 19:07:23
Apple AppleInsider - Frontpage News Apple execs excited about M1 Max MacBook Pro video editing capabilities https://appleinsider.com/articles/21/10/24/apple-execs-excited-about-m1-max-macbook-pro-video-editing-capabilities?utm_medium=rss Apple execs excited about M Max MacBook Pro video editing capabilitiesThe M Max is a game changing chip for video editing and graphics heavy workflows Apple executives have said in a podcast about the new MacBook Pro models with the top end chip capable of some video production feats that some Mac Pro variants cannot match Apple s inch MacBook Pro and inch MacBook Pro include some hefty processing capabilities in the form of the M Pro and M Max chips In an interview Pro Mac Product Line Manager Shruti Haldea along with Luke Tristram spoke about the chips and the various benefits introduced with the new notebooks For the M Max Haldea says it has a pretty game changing memory bandwidth of GB s along with the configurable gigabytes of unified memory according to the Same Brain podcast The level is such that while you can do K video playback on an M MacBook Pro and can do K video editing on a MacBook Air there s more that can be done at the higher end of the product spectrum Read more 2021-10-24 19:59:35
医療系 医療介護 CBnews 結論、回復期リハ病棟は民間に任せた方がいい-先が見えない時代の戦略的病院経営(157) https://www.cbnews.jp/news/entry/20211022165824 千葉大学医学部附属病院 2021-10-25 05:00:00
ニュース BBC News - Home Colombian drug lord Otoniel to be extradited to US https://www.bbc.co.uk/news/world-latin-america-59032300?at_medium=RSS&at_campaign=KARANGA bounty 2021-10-24 19:02:16
ニュース BBC News - Home ‘It won't happen again in a long time, if ever’ – Klopp lauds Liverpool’s ‘special’ victory https://www.bbc.co.uk/sport/football/59032150?at_medium=RSS&at_campaign=KARANGA It won x t happen again in a long time if ever Klopp lauds Liverpool s special victoryLiverpool boss Jurgen Klopp says he did not expect their win at Old Trafford and called the result insane 2021-10-24 19:06:44
ビジネス ダイヤモンド・オンライン - 新着記事 懲戒解雇になる場合も…「副業」で絶対やってはいけない2つのこと - 転職で幸せになる人、不幸になる人 丸山貴宏 https://diamond.jp/articles/-/285464 懲戒解雇 2021-10-25 04:55:00
ビジネス ダイヤモンド・オンライン - 新着記事 三井・住友“世紀の大合併”から20年、「名門2大財閥」権力闘争の全内幕 - 三井住友 名門「財閥」の野望 https://diamond.jp/articles/-/285267 三井・住友“世紀の大合併から年、「名門大財閥」権力闘争の全内幕三井住友名門「財閥」の野望三井と住友。 2021-10-25 04:50:00
ビジネス ダイヤモンド・オンライン - 新着記事 日本企業がワールドクラスになれない理由の1つ「不幸な事業売却」から脱却せよ【入山章栄×BCG日置圭介・動画】 - ワールドクラスの経営 https://diamond.jp/articles/-/285576 2021-10-25 04:45:00
ビジネス ダイヤモンド・オンライン - 新着記事 岸田版「新しい資本主義」は本当に新しい?明確にすべき2つのポイント - 政策・マーケットラボ https://diamond.jp/articles/-/285515 資本主義 2021-10-25 04:35:00
ビジネス ダイヤモンド・オンライン - 新着記事 年収が高い会社ランキング2021【大阪府・トップ5】3位武田薬品、2位伊藤忠、1位は? - ニッポンなんでもランキング! https://diamond.jp/articles/-/285519 上場企業 2021-10-25 04:30:00
ビジネス ダイヤモンド・オンライン - 新着記事 年収が高い会社ランキング2021【大阪府/完全版】 - ニッポンなんでもランキング! https://diamond.jp/articles/-/285453 上場企業 2021-10-25 04:30:00
ビジネス ダイヤモンド・オンライン - 新着記事 相続税の平均は1714万円!今なら間に合う「駆け込み贈与」節税術 - 今週の週刊ダイヤモンド ここが見どころ https://diamond.jp/articles/-/285479 生前贈与 2021-10-25 04:25:00
ビジネス ダイヤモンド・オンライン - 新着記事 「強制力のない緊急事態宣言」でも日本で感染者数が減少した理由 - 原田泰 データアナリシス https://diamond.jp/articles/-/285218 緊急事態 2021-10-25 04:20:00
ビジネス ダイヤモンド・オンライン - 新着記事 JR東海が「堅くない取り組み」を次々と打ち出す狙いとは - News&Analysis https://diamond.jp/articles/-/285573 newsampampanalysis 2021-10-25 04:15:00
ビジネス ダイヤモンド・オンライン - 新着記事 就活中の子どもに、活動資金として「現金」を渡してはいけない理由 - 採用のプロが明かす「親必読」最新就活事情 https://diamond.jp/articles/-/285623 就職活動 2021-10-25 04:10:00
ビジネス ダイヤモンド・オンライン - 新着記事 バズる記事には「型」があった!1万本を研究してわかった文章のコツ - 要約の達人 from flier https://diamond.jp/articles/-/285561 バズる記事には「型」があった万本を研究してわかった文章のコツ要約の達人fromflierSNSが発達し、誰もが自由に発信できるようになった現在。 2021-10-25 04:05:00
ビジネス 東洋経済オンライン 入試から読みとる「大学が受験生に求める学力」 早慶上理・MARCH・関関同立の将来像が見えてくる | 最新の週刊東洋経済 | 東洋経済オンライン https://toyokeizai.net/articles/-/464132?utm_source=rss&utm_medium=http&utm_campaign=link_back march 2021-10-25 04:30:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)